Package toxi.util.datatypes
Class ArraySet<E>
java.lang.Object
java.util.AbstractCollection<E>
java.util.AbstractSet<E>
toxi.util.datatypes.ArraySet<E>
- All Implemented Interfaces:
Iterable<E>,Collection<E>,Set<E>
- Direct Known Subclasses:
DelaunayTriangle
An ArrayList implementation of Set. An ArraySet is good for small sets; it
has less overhead than a HashSet or a TreeSet.
- Author:
- Paul Chew Created December 2007. For use with Voronoi/Delaunay applet.
-
Constructor Summary
ConstructorsConstructorDescriptionArraySet()Create an empty set (default initial capacity is 3).ArraySet(int initialCapacity) Create an empty set with the specified initial capacity.ArraySet(Collection<? extends E> collection) Create a set containing the items of the collection. -
Method Summary
Modifier and TypeMethodDescriptionbooleanbooleancontainsAny(Collection<?> collection) True if any member of the collection is also in the ArraySet.get(int index) Get the item at the specified index.iterator()intsize()Methods inherited from class java.util.AbstractSet
equals, hashCode, removeAllMethods inherited from class java.util.AbstractCollection
addAll, clear, contains, containsAll, isEmpty, remove, retainAll, toArray, toArray, toStringMethods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArray
-
Constructor Details
-
ArraySet
public ArraySet()Create an empty set (default initial capacity is 3). -
ArraySet
Create a set containing the items of the collection. Any duplicate items are discarded.- Parameters:
collection- the source for the items of the small set
-
ArraySet
public ArraySet(int initialCapacity) Create an empty set with the specified initial capacity.- Parameters:
initialCapacity- the initial capacity
-
-
Method Details
-
add
- Specified by:
addin interfaceCollection<E>- Specified by:
addin interfaceSet<E>- Overrides:
addin classAbstractCollection<E>
-
containsAny
True if any member of the collection is also in the ArraySet.- Parameters:
collection- the Collection to check- Returns:
- true if any member of collection appears in this ArraySet
-
get
Get the item at the specified index.- Parameters:
index- where the item is located in the ListSet- Returns:
- the item at the specified index
- Throws:
IndexOutOfBoundsException- if the index is out of bounds
-
iterator
-
size
public int size()- Specified by:
sizein interfaceCollection<E>- Specified by:
sizein interfaceSet<E>- Specified by:
sizein classAbstractCollection<E>
-