@Test public void testRehash() { ColorMap map = new ColorMap(16); assertEquals(16, map.table.length); for (int i = 1; i < 20; i++) { map.put(255, 255, 255, i, i); } assertEquals(64, map.table.length); assertEquals((int) (64 * ColorMap.DEFAULT_LOAD_FACTOR), map.threshold); for (int i = 1; i < 20; i++) { assertEquals(i, map.get(255, 255, 255, i)); } }
private void rehash(int newLength) { ColorEntry[] oldTable = table; this.table = new ColorEntry[newLength]; for (ColorEntry bucketStart : oldTable) { for (ColorEntry e = bucketStart; e != null; e = e.next) { int index = indexFor(hash(e.color), table.length); ColorEntry newEntry = new ColorEntry(e.color, e.value, table[index]); table[index] = newEntry; } } }
ColorMap implements Iterable<ColorEntry> { private void rehash(int newLength) { ColorEntry[] oldTable = table; this.table = new ColorEntry[newLength]; for (ColorEntry bucketStart : oldTable) { for (ColorEntry e = bucketStart; e != null; e = e.next) { int index = indexFor(hash(e.color), table.length); ColorEntry newEntry = new ColorEntry(e.color, e.value, table[index]); table[index] = newEntry; } } } }
ColorMap implements Iterable<ColorEntry> { private void rehash(int newLength) { ColorEntry[] oldTable = table; this.table = new ColorEntry[newLength]; for (ColorEntry bucketStart : oldTable) { for (ColorEntry e = bucketStart; e != null; e = e.next) { int index = indexFor(hash(e.color), table.length); ColorEntry newEntry = new ColorEntry(e.color, e.value, table[index]); table[index] = newEntry; } } } ColorMap(int initialCapacity);  ColorMap(); }
ColorMap implements Iterable<ColorEntry> { private void rehash(int newLength) { ColorEntry[] oldTable = table; this.table = new ColorEntry[newLength]; for (ColorEntry bucketStart : oldTable) { for (ColorEntry e = bucketStart; e != null; e = e.next) { int index = indexFor(hash(e.color), table.length); ColorEntry newEntry = new ColorEntry(e.color, e.value, table[index]); table[index] = newEntry; } } } ColorMap(int initialCapacity);  ColorMap(); void increment(int red, int green, int blue, int alpha); void increment(int r, int g, int b, int a, int increment); int get(int r, int g, int b, int a); int put(int r, int g, int b, int a, int value); boolean remove(int r, int g, int b, int a); @Override Iterator<ColorEntry> iterator(); void reset(ColorMap other); void printStats(); }
ColorMap implements Iterable<ColorEntry> { private void rehash(int newLength) { ColorEntry[] oldTable = table; this.table = new ColorEntry[newLength]; for (ColorEntry bucketStart : oldTable) { for (ColorEntry e = bucketStart; e != null; e = e.next) { int index = indexFor(hash(e.color), table.length); ColorEntry newEntry = new ColorEntry(e.color, e.value, table[index]); table[index] = newEntry; } } } ColorMap(int initialCapacity);  ColorMap(); void increment(int red, int green, int blue, int alpha); void increment(int r, int g, int b, int a, int increment); int get(int r, int g, int b, int a); int put(int r, int g, int b, int a, int value); boolean remove(int r, int g, int b, int a); @Override Iterator<ColorEntry> iterator(); void reset(ColorMap other); void printStats();  }