|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.basex.util.hash.ASet
org.basex.util.hash.TokenSet
public class TokenSet
This is an efficient and memory-saving hash set for storing tokens. The first entry of the token set (offset 0) is always empty.
Field Summary | |
---|---|
protected byte[][] |
keys
Hashed keys. |
Fields inherited from class org.basex.util.hash.ASet |
---|
bucket, next, size |
Constructor Summary | |
---|---|
TokenSet()
Default constructor. |
|
TokenSet(byte[]... key)
Constructor, specifying initial keys. |
|
TokenSet(DataInput in)
Constructor, specifying some initial input. |
Method Summary | |
---|---|
boolean |
add(byte[] key)
Stores the specified key if it has not been stored before. |
boolean |
add(java.lang.String key)
Stores the specified string as key if it has not been stored before. |
void |
clear()
Resets the data structure. |
boolean |
contains(byte[] key)
Checks if the set contains the specified key. |
int |
delete(byte[] key)
Deletes the specified key. |
protected int |
hash(int id)
Returns the hash value of the element with the specified id. |
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 id)
Returns the key with the specified id. |
int |
put(byte[] key)
Stores the specified key and returns its id. |
protected void |
read(DataInput in)
Reads the data structure from the specified input. |
protected void |
rehash(int newSize)
Rehashes all entries. |
java.lang.String |
toString()
|
void |
write(DataOutput out)
Writes the data structure to the specified output. |
Methods inherited from class org.basex.util.hash.ASet |
---|
checkSize, isEmpty, size |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected byte[][] keys
Constructor Detail |
---|
public TokenSet()
public TokenSet(byte[]... key)
key
- initial keyspublic TokenSet(DataInput in) throws java.io.IOException
in
- input stream
java.io.IOException
- I/O exceptionMethod Detail |
---|
protected void read(DataInput in) throws java.io.IOException
in
- input stream
java.io.IOException
- I/O exceptionpublic void write(DataOutput out) throws java.io.IOException
out
- output stream
java.io.IOException
- I/O exceptionpublic final boolean add(byte[] key)
key
- key to be added
public boolean add(java.lang.String key)
key
- string to be added
public final int put(byte[] key)
key
- key to be added
public final boolean contains(byte[] key)
key
- key to be looked up
public final int id(byte[] key)
0
if the key does not exist.
key
- key to be looked up
0
if key does not existpublic final byte[] key(int id)
1
instead of 0
.
id
- id of the key to return
public int delete(byte[] key)
ASet.size
is called after
deletions, the original number of entries will be returned.
key
- key
protected int hash(int id)
ASet
hash
in class ASet
id
- id of the element
protected void rehash(int newSize)
ASet
rehash
in class ASet
newSize
- new hash sizepublic final void clear()
ASet
clear
in class ASet
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
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |