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
ConstructorDescriptionArraySet()
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 TypeMethodDescriptionboolean
boolean
containsAny
(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()
int
size()
Methods inherited from class java.util.AbstractSet
equals, hashCode, removeAll
Methods inherited from class java.util.AbstractCollection
addAll, clear, contains, containsAll, isEmpty, remove, retainAll, toArray, toArray, toString
Methods 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:
add
in interfaceCollection<E>
- Specified by:
add
in interfaceSet<E>
- Overrides:
add
in 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:
size
in interfaceCollection<E>
- Specified by:
size
in interfaceSet<E>
- Specified by:
size
in classAbstractCollection<E>
-