public final class ColorMap extends Object implements Iterable<ColorMap.ColorEntry>
HashMap
replacement especially designed to map an (eventually packed) color to a non negative integer value, which can be in our use
cases a count or a palette index.
It uses significant less resources than a normal HashMap
as it avoids the usage of object wrappers and other redundant information that we
don't need in this particular application
Modifier and Type | Class and Description |
---|---|
static class |
ColorMap.ColorEntry
Class representing a single
ColorMap entry |
Constructor and Description |
---|
ColorMap() |
ColorMap(int initialCapacity) |
Modifier and Type | Method and Description |
---|---|
int |
get(int r,
int g,
int b,
int a)
Returns the value for the specified color, or -1 if the color is not found
|
void |
increment(int red,
int green,
int blue,
int alpha)
Increments the counter associated to the specified color by one, or sets the count of such color to one if missing
|
void |
increment(int r,
int g,
int b,
int a,
int increment)
Increments the counter associated to the specified color by one
|
Iterator<ColorMap.ColorEntry> |
iterator() |
void |
printStats()
Prints out statistics about the color map, number of buckes, empty buckets count, number of entries per bucket, number of access operations and
number of average color entries accessed each time
|
int |
put(int r,
int g,
int b,
int a,
int value)
Associates the specified value with a color
|
boolean |
remove(int r,
int g,
int b,
int a)
Removes the specified color from the map
|
void |
reset(ColorMap other)
Reset its own status to the one of the other color map.
|
public void increment(int red, int green, int blue, int alpha)
public void increment(int r, int g, int b, int a, int increment)
public int get(int r, int g, int b, int a)
r
- g
- b
- a
- public int put(int r, int g, int b, int a, int value)
r
- g
- b
- a
- public boolean remove(int r, int g, int b, int a)
r
- g
- b
- a
- public Iterator<ColorMap.ColorEntry> iterator()
iterator
in interface Iterable<ColorMap.ColorEntry>
public void reset(ColorMap other)
ColorMap.ColorEntry
are shared, so the other color map should not be used anymore
after this callpublic void printStats()
Copyright © 2006–2017 GeoSolutions. All rights reserved.