public class TokenSet extends ASet implements Iterable<byte[]>
Modifier and Type | Field and Description |
---|---|
protected byte[][] |
keys
Hashed keys.
|
Constructor and Description |
---|
TokenSet()
Default constructor.
|
TokenSet(byte[]... key)
Constructor, specifying initial keys.
|
TokenSet(DataInput in)
Constructor, specifying some initial input.
|
Modifier and Type | Method and Description |
---|---|
boolean |
add(byte[] key)
Stores the specified key if it has not been stored before.
|
boolean |
add(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.
|
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. |
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.
|
void |
read(DataInput in)
Reads the data structure from the specified input.
|
protected void |
rehash(int newSize)
Rehashes all entries.
|
int |
remove(byte[] key)
Removes the entry with the specified key.
|
String |
toString() |
void |
write(DataOutput out)
Writes the data structure to the specified output.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
forEach, spliterator
public TokenSet()
public TokenSet(byte[]... key)
key
- initial keyspublic TokenSet(DataInput in) throws IOException
in
- input streamIOException
- I/O exceptionpublic void read(DataInput in) throws IOException
in
- input streamIOException
- I/O exceptionpublic void write(DataOutput out) throws IOException
out
- output streamIOException
- I/O exceptionpublic final boolean add(byte[] key)
key
- key to be addedtrue
if the key did not exist yet and was storedpublic final boolean add(String key)
key
- string to be addedtrue
if the key did not exist yet and was storedpublic final int put(byte[] key)
key
- key to be addedpublic final boolean contains(byte[] key)
key
- key to be looked uppublic final int id(byte[] key)
0
if the key does not exist.key
- key to be looked up0
if key does not existpublic final byte[] key(int id)
1
instead of 0
.id
- id of the key to returnpublic int remove(byte[] key)
ASet.size
is called after
deletions, the original number of entries will be returned.key
- key0
if the key did not existprotected int hash(int id)
ASet
protected void rehash(int newSize)
ASet
public void clear()
ASet
public final Iterator<byte[]> iterator()
Copyright © 2005–2019 BaseX Team. All rights reserved.