Class ArraySet<T>
java.lang.Object
java.util.AbstractCollection<T>
java.util.AbstractSet<T>
com.ibm.wala.util.collections.ArraySet<T>
- All Implemented Interfaces:
Serializable
,Iterable<T>
,Collection<T>
,Set<T>
A set implementation backed by an array. This implementation is space-efficient for small sets,
but several operations like
contains(Object)
are linear time.- See Also:
-
Nested Class Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
boolean
void
clear()
boolean
static final <T> ArraySet
<T> empty()
void
forall
(ObjectVisitor<T> visitor) get
(int i) boolean
intersects
(ArraySet<T> other) iterator()
static <T> ArraySet
<T> make()
static <T> ArraySet
<T> make
(Collection<T> other) boolean
remove
(int ind) boolean
int
size()
Methods inherited from class java.util.AbstractSet
equals, hashCode, removeAll
Methods inherited from class java.util.AbstractCollection
addAll, containsAll, isEmpty, retainAll, toArray, toArray, toString
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArray
Methods inherited from interface java.util.Set
addAll, containsAll, isEmpty, retainAll, spliterator, toArray, toArray
-
Constructor Details
-
ArraySet
public ArraySet(int n, boolean checkDupes) -
ArraySet
public ArraySet() -
ArraySet
- Throws:
IllegalArgumentException
-
-
Method Details
-
empty
-
add
- Specified by:
add
in interfaceCollection<T>
- Specified by:
add
in interfaceSet<T>
- Overrides:
add
in classAbstractCollection<T>
- Throws:
UnsupportedOperationException
- if thisArraySet
is immutable (optional)
-
addAll
- Throws:
IllegalArgumentException
-
contains
- Specified by:
contains
in interfaceCollection<T>
- Specified by:
contains
in interfaceSet<T>
- Overrides:
contains
in classAbstractCollection<T>
-
intersects
- Throws:
IllegalArgumentException
-
forall
-
size
public int size()- Specified by:
size
in interfaceCollection<T>
- Specified by:
size
in interfaceSet<T>
- Specified by:
size
in classAbstractCollection<T>
-
get
- Throws:
IndexOutOfBoundsException
- if the index is out of range (index < 0 || index >= size()).
-
remove
- Specified by:
remove
in interfaceCollection<T>
- Specified by:
remove
in interfaceSet<T>
- Overrides:
remove
in classAbstractCollection<T>
-
remove
public boolean remove(int ind) - Returns:
true
(SJF: So why return a value?)
-
clear
public void clear()- Specified by:
clear
in interfaceCollection<T>
- Specified by:
clear
in interfaceSet<T>
- Overrides:
clear
in classAbstractCollection<T>
-
iterator
-
make
-
make
- Throws:
IllegalArgumentException
-