Package com.ibm.wala.util.collections
Class ArraySet<T>
- java.lang.Object
-
- java.util.AbstractCollection<E>
-
- java.util.AbstractSet<T>
-
- com.ibm.wala.util.collections.ArraySet<T>
-
- Type Parameters:
T
-
- All Implemented Interfaces:
Iterable<T>
,Collection<T>
,Set<T>
public class ArraySet<T> extends AbstractSet<T>
A set implementation backed by an array. This implementation is space-efficient for small sets, but several operations likecontains(Object)
are linear time.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description class
ArraySet.ArraySetIterator
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
add(T o)
boolean
addAll(ArraySet<T> other)
void
clear()
boolean
contains(Object obj_)
static <T> ArraySet<T>
empty()
void
forall(ObjectVisitor<T> visitor)
T
get(int i)
boolean
intersects(ArraySet<T> other)
Iterator<T>
iterator()
static <T> ArraySet<T>
make()
static <T> ArraySet<T>
make(Collection<T> other)
boolean
remove(int ind)
boolean
remove(Object obj_)
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 Detail
-
ArraySet
public ArraySet(int n, boolean checkDupes)
-
ArraySet
public ArraySet()
-
ArraySet
public ArraySet(ArraySet<T> other) throws IllegalArgumentException
- Throws:
IllegalArgumentException
-
-
Method Detail
-
empty
public static final <T> ArraySet<T> empty()
-
add
public boolean add(T o)
- 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
public boolean addAll(ArraySet<T> other) throws IllegalArgumentException
- Throws:
IllegalArgumentException
-
contains
public boolean contains(Object obj_)
- Specified by:
contains
in interfaceCollection<T>
- Specified by:
contains
in interfaceSet<T>
- Overrides:
contains
in classAbstractCollection<T>
-
intersects
public boolean intersects(ArraySet<T> other) throws IllegalArgumentException
- Throws:
IllegalArgumentException
-
forall
public void forall(ObjectVisitor<T> visitor)
-
size
public int size()
- Specified by:
size
in interfaceCollection<T>
- Specified by:
size
in interfaceSet<T>
- Specified by:
size
in classAbstractCollection<T>
-
get
public T get(int i)
- Throws:
IndexOutOfBoundsException
- if the index is out of range (index < 0 || index >= size()).
-
remove
public boolean remove(Object obj_)
- 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>
-
make
public static <T> ArraySet<T> make()
-
make
public static <T> ArraySet<T> make(Collection<T> other) throws IllegalArgumentException
- Throws:
IllegalArgumentException
-
-