32package com.jogamp.common.util;
34import java.io.IOException;
35import java.util.HashMap;
36import java.util.Iterator;
37import java.util.Map.Entry;
39import org.junit.BeforeClass;
42import com.jogamp.common.os.Platform;
43import com.jogamp.junit.util.SingletonJunitCase;
45import static org.junit.Assert.*;
52import org.junit.FixMethodOrder;
53import org.junit.runners.MethodSorters;
55@FixMethodOrder(MethodSorters.NAME_ASCENDING)
58 private static int iterations;
62 public static void init() {
74 final HashMap<Integer, IntCloneable> map =
new HashMap<Integer, IntCloneable>();
77 for (
int i = 0; i < iterations; i++) {
84 for (
int i = 0; i < iterations; i++) {
88 assertEquals(map.size(), intmap.size());
90 for (
final Entry<Integer, IntCloneable> entry : map.entrySet()) {
96 for (
final Entry<Integer, IntCloneable> entry : map.entrySet()) {
97 assertEquals(entry.getValue(), intmap.
remove(entry.getKey()));
98 assertEquals(map.size() - i - 1, intmap.size());
109 for (
int i = 0; i < iterations; i++) {
114 assertNotNull(iterator);
115 assertTrue(iterator.hasNext());
118 while (iterator.hasNext()) {
119 final IntObjectHashMap.Entry entry = iterator.next();
120 assertNotNull(entry);
123 assertEquals(intmap.size(), n);
134 for (
int i = 0; i < iterations; i++) {
140 assertEquals(intmap.size(), intmapCopy.size());
144 assertNotNull(iterator);
145 assertTrue(iterator.hasNext());
148 assertNotNull(iteratorCopy);
149 assertTrue(iteratorCopy.hasNext());
152 while (iterator.hasNext()) {
153 assertTrue(iteratorCopy.hasNext());
154 final IntObjectHashMap.Entry entry = iterator.next();
155 final IntObjectHashMap.Entry entryCopy = iteratorCopy.next();
156 assertNotNull(entry);
157 assertNotNull(entryCopy);
158 assertEquals(entry.key, entryCopy.key);
159 assertEquals(entry.value, entryCopy.value);
162 assertTrue(!iteratorCopy.hasNext());
164 assertEquals(intmap.size(), n);
165 assertEquals(intmapCopy.size(), n);
167 for (
int i = 0; i < iterations; i++) {
178 public static void main(
final String args[])
throws IOException {
An entry mapping a key to a value.
Fast HashMap for primitive data.
Iterator< Entry > iterator()
Returns a new Iterator.
Object put(final int key, final Object value)
Maps the key to the specified value.
boolean containsKey(final int key)
Object remove(final int key)
Removes the key-value mapping from this map.
Object getKeyNotFoundValue()
Returns the value which is returned if no value has been found for the specified key.
boolean containsValue(final Object value)
Object clone()
Disclaimer: If the value type doesn't implement clone(), only the reference is copied.
static void main(final String args[])
void testPutRemove()
Test of put method, of class IntObjectHashMap.