|
||||||||||
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.IntSet
public class IntSet
This is an efficient and memory-saving hash map for storing primitive integers.
It is related to the TokenSet
class.
Field Summary | |
---|---|
protected int[] |
keys
Hashed keys. |
Fields inherited from class org.basex.util.hash.ASet |
---|
bucket, next, size |
Constructor Summary | |
---|---|
IntSet()
Default constructor. |
|
IntSet(int capacity)
Default constructor. |
Method Summary | |
---|---|
boolean |
add(int key)
Stores the specified key if it has not been stored before. |
boolean |
contains(int key)
Checks if the set contains the specified key. |
int |
delete(int key)
Deletes the specified key. |
protected int |
hash(int id)
Returns the hash value of the element with the specified id. |
int |
id(int key)
Returns the id of the specified key, or 0 if the key does not exist. |
int |
key(int id)
Returns the key with the specified id. |
int |
put(int key)
Stores the specified key and returns its id. |
protected void |
rehash(int newSize)
Rehashes all entries. |
int[] |
toArray()
Returns an array with all elements. |
Methods inherited from class org.basex.util.hash.ASet |
---|
checkSize, clear, isEmpty, size |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected int[] keys
Constructor Detail |
---|
public IntSet()
public IntSet(int capacity)
capacity
- initial array capacityMethod Detail |
---|
public final boolean add(int key)
key
- key to be added
public final int put(int key)
key
- key to be added
public final boolean contains(int key)
key
- key to be looked up
public final int id(int key)
0
if the key does not exist.
key
- key to be looked up
0
if key does not existpublic final int key(int id)
1
instead of 0
.
id
- id of the key to return
public int delete(int 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 int[] toArray()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |