public class TokenSet
extends java.lang.Object
implements java.lang.Iterable<byte[]>
TokenMap class extends it to a hash map.| Modifier and Type | Field and Description |
|---|---|
protected static int |
CAP
Initial hash capacity.
|
byte[][] |
keys
Hashed keys.
|
int |
size
Hash entries.
|
| Constructor and Description |
|---|
TokenSet()
Constructor.
|
TokenSet(byte[]... init)
Constructor.
|
TokenSet(DataInput in)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
int |
add(byte[] key)
Indexes the specified key and returns the offset of the added key.
|
int |
delete(byte[] key)
Deletes the specified key.
|
int |
id(byte[] key)
Returns the id of the specified key or 0 if the key does not exist.
|
java.util.Iterator<byte[]> |
iterator() |
byte[] |
key(int i)
Returns the specified key.
|
byte[][] |
keys()
Returns the hash keys.
|
protected void |
read(DataInput in)
Reads the token set from the specified input.
|
protected void |
rehash()
Resizes the hash table.
|
int |
size()
Returns the number of entries.
|
java.lang.String |
toString() |
void |
write(DataOutput out)
Writes the token set to the specified output.
|
protected static final int CAP
public int size
size - 1.public byte[][] keys
public TokenSet()
public TokenSet(byte[]... init)
init - initial tokenspublic TokenSet(DataInput in) throws java.io.IOException
in - input streamjava.io.IOException - I/O exceptionprotected void read(DataInput in) throws java.io.IOException
in - input streamjava.io.IOException - I/O exceptionpublic void write(DataOutput out) throws java.io.IOException
out - output streamjava.io.IOException - I/O exceptionpublic final int add(byte[] key)
key - keypublic int delete(byte[] key)
null
entries, and the total number of entries will not reflect the number
of valid entries anymore.key - keypublic final int id(byte[] key)
key - key to be foundpublic final byte[] key(int i)
i - key indexpublic final byte[][] keys()
public final int size()
protected void rehash()
public final java.util.Iterator<byte[]> iterator()
iterator in interface java.lang.Iterable<byte[]>public java.lang.String toString()
toString in class java.lang.Object