public class ObjectSet<T> extends Object implements Iterable<T>
clear(int)
and shrink(int)
can be used to reduce
the capacity. OrderedSet
provides much faster iteration.Modifier and Type | Class and Description |
---|---|
static class |
ObjectSet.ObjectSetIterator<K> |
Modifier and Type | Field and Description |
---|---|
int |
size |
Constructor and Description |
---|
ObjectSet()
Creates a new set with an initial capacity of 51 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.
|
ObjectSet(ObjectSet set)
Creates a new set identical to the specified set.
|
Modifier and Type | Method and Description |
---|---|
boolean |
add(T key)
Returns true if the key was not already in the set.
|
void |
addAll(Array<? extends T> array) |
void |
addAll(Array<? extends T> array,
int offset,
int length) |
void |
addAll(ObjectSet<T> set) |
void |
addAll(T... array) |
void |
addAll(T[] array,
int offset,
int length) |
void |
clear()
Clears the set, leaving the backing arrays at the current capacity.
|
void |
clear(int maximumCapacity)
Clears the set 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 accommodate the specified number of additional items.
|
boolean |
equals(Object obj) |
T |
first() |
T |
get(T key) |
int |
hashCode() |
boolean |
isEmpty()
Returns true if the set is empty.
|
ObjectSet.ObjectSetIterator<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) |
static <T> ObjectSet<T> |
with(T... array) |
forEach, spliterator
public ObjectSet()
public ObjectSet(int initialCapacity)
initialCapacity
- If not a power of two, it is increased to the next nearest power of two.public ObjectSet(int initialCapacity, float loadFactor)
initialCapacity
- If not a power of two, it is increased to the next nearest power of two.public ObjectSet(ObjectSet set)
public boolean add(T key)
public void addAll(T... array)
public void addAll(T[] array, int offset, int length)
public boolean remove(T key)
public boolean isEmpty()
public void shrink(int maximumCapacity)
public void clear(int maximumCapacity)
public void clear()
clear(int)
can be used to reduce the capacity.public boolean contains(T key)
public T first()
public void ensureCapacity(int additionalCapacity)
public ObjectSet.ObjectSetIterator<T> iterator()
ObjectSet.ObjectSetIterator
constructor for nested or multithreaded iteration.public static <T> ObjectSet<T> with(T... array)
Copyright © 2018. All rights reserved.