public class IntMultiMap
extends Object
Modifier and Type | Class and Description |
---|---|
private class |
IntMultiMap.Block
Keeps track of a block of values, with links to the following values.
|
Modifier and Type | Field and Description |
---|---|
private static int |
BLOCK_SIZE |
private IntMultiMap.Block[] |
blocks |
private IntMultiMap.Block |
curBlock |
private short |
curBlockNum |
private short |
curBlockTop |
private int[] |
keyLinks |
static Tester |
tester
Basic regression test
|
Constructor and Description |
---|
IntMultiMap(int maxKey)
Initialize the mapping table.
|
Modifier and Type | Method and Description |
---|---|
void |
add(int key,
int value)
Add a new association between a key and a value.
|
long |
byteSize()
Calculate the size in bytes of the major structures of the map.
|
int |
firstPos(int key)
For iteration: get the first position for the given key, or -1 if it has none.
|
int |
getValue(int pos)
Retrieve the value for a given link.
|
int |
nextPos(int prevPos)
For iteration: get the next position after the given pos, or -1 if we're at
the end of the chain.
|
void |
reverseOrder()
Reverse the order of all links.
|
private int[] keyLinks
private static final int BLOCK_SIZE
private IntMultiMap.Block[] blocks
private short curBlockNum
private IntMultiMap.Block curBlock
private short curBlockTop
public static final Tester tester
public IntMultiMap(int maxKey)
maxKey
- One larger than the largest key value that will ever be
passed to add(int, int)
. Note that the mapping
cannot be expanded.public long byteSize()
public void add(int key, int value)
public void reverseOrder()
public final int firstPos(int key)
public final int nextPos(int prevPos)
public final int getValue(int pos)