|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.badlogic.gdx.utils.ObjectSet<T>
public class ObjectSet<T>
An unordered set where the keys are objects. This implementation uses cuckoo hashing using 3 hashes, random walking, and a
small stash for problematic keys. Null keys are not allowed. No allocation is done except when growing the table size.
This set performs very fast contains and remove (typically O(1), worst case O(log(n))). Add may be a bit slower, depending on
hash collisions. Load factors greater than 0.91 greatly increase the chances the set will have to rehash to the next higher POT
size.
Nested Class Summary | |
---|---|
static class |
ObjectSet.SetIterator<K>
|
Field Summary | |
---|---|
int |
size
|
Constructor Summary | |
---|---|
ObjectSet()
Creates a new set with an initial capacity of 32 and a load factor of 0.8. |
|
ObjectSet(int initialCapacity)
Creates a new set with a load factor of 0.8. |
|
ObjectSet(int initialCapacity,
float loadFactor)
Creates a new set with the specified initial capacity and load factor. |
Method Summary | |
---|---|
boolean |
add(T key)
Returns true if the key was not already in the set. |
void |
addAll(Array<T> array)
|
void |
addAll(ObjectSet<T> set)
|
void |
clear()
|
void |
clear(int maximumCapacity)
Clears the map and reduces the size of the backing arrays to be the specified capacity if they are larger. |
boolean |
contains(T key)
|
void |
ensureCapacity(int additionalCapacity)
Increases the size of the backing array to acommodate the specified number of additional items. |
ObjectSet.SetIterator<T> |
iterator()
Returns an iterator for the keys in the set. |
boolean |
remove(T key)
Returns true if the key was removed. |
void |
shrink(int maximumCapacity)
Reduces the size of the backing arrays to be the specified capacity or less. |
String |
toString()
|
String |
toString(String separator)
|
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public int size
Constructor Detail |
---|
public ObjectSet()
public ObjectSet(int initialCapacity)
public ObjectSet(int initialCapacity, float loadFactor)
Method Detail |
---|
public boolean add(T key)
public void addAll(Array<T> array)
public void addAll(ObjectSet<T> set)
public boolean remove(T key)
public void shrink(int maximumCapacity)
public void clear(int maximumCapacity)
public void clear()
public boolean contains(T key)
public void ensureCapacity(int additionalCapacity)
public String toString()
toString
in class Object
public String toString(String separator)
public ObjectSet.SetIterator<T> iterator()
ObjectSet.SetIterator
constructor for nested or multithreaded iteration.
iterator
in interface Iterable<T>
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |