Package pascal.taie.util.collection
Class ArraySet<E>
java.lang.Object
java.util.AbstractCollection<E>
java.util.AbstractSet<E>
pascal.taie.util.collection.AbstractSetEx<E>
pascal.taie.util.collection.ArraySet<E>
- All Implemented Interfaces:
Serializable
,Iterable<E>
,Collection<E>
,Set<E>
,SetEx<E>
,Copyable<SetEx<E>>
Set implementation based on ArrayList. This class should only be
used for small set. Elements cannot be null.
Note that remove(Object) will shift the rest elements to the end.
TODO: if necessary, optimize remove(Object) and let add(Object) add
element to empty hole of the array.
- See Also:
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
boolean
addAll
(Collection<? extends E> c) addAllDiff
(Collection<? extends E> c) Adds all elements in collectionc
, and returns the difference set betweenc
and this set (before the call).void
clear()
boolean
boolean
containsAll
(Collection<?> c) copy()
Creates and returns a copy of this object.boolean
isEmpty()
iterator()
boolean
boolean
retainAll
(Collection<?> c) int
size()
Object[]
toArray()
<T> T[]
toArray
(T[] a) Methods inherited from class pascal.taie.util.collection.AbstractSetEx
hasOverlapWith, newSet
Methods inherited from class java.util.AbstractSet
equals, hashCode, removeAll
Methods inherited from class java.util.AbstractCollection
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
equals, hashCode, removeAll, spliterator
-
Field Details
-
DEFAULT_CAPACITY
public static final int DEFAULT_CAPACITY- See Also:
-
-
Constructor Details
-
ArraySet
public ArraySet() -
ArraySet
public ArraySet(int initialCapacity) -
ArraySet
public ArraySet(int initialCapacity, boolean fixedCapacity) -
ArraySet
Takes given array list as elements. Note that the caller should ensure thatelements
contains no duplicate elements. -
ArraySet
-
-
Method Details
-
isEmpty
public boolean isEmpty()- Specified by:
isEmpty
in interfaceCollection<E>
- Specified by:
isEmpty
in interfaceSet<E>
- Overrides:
isEmpty
in classAbstractCollection<E>
-
contains
- Specified by:
contains
in interfaceCollection<E>
- Specified by:
contains
in interfaceSet<E>
- Overrides:
contains
in classAbstractCollection<E>
-
toArray
- Specified by:
toArray
in interfaceCollection<E>
- Specified by:
toArray
in interfaceSet<E>
- Overrides:
toArray
in classAbstractCollection<E>
-
toArray
@Nonnull public <T> T[] toArray(@Nonnull T[] a) - Specified by:
toArray
in interfaceCollection<E>
- Specified by:
toArray
in interfaceSet<E>
- Overrides:
toArray
in classAbstractCollection<E>
-
add
- Specified by:
add
in interfaceCollection<E>
- Specified by:
add
in interfaceSet<E>
- Overrides:
add
in classAbstractCollection<E>
-
remove
- Specified by:
remove
in interfaceCollection<E>
- Specified by:
remove
in interfaceSet<E>
- Overrides:
remove
in classAbstractCollection<E>
-
containsAll
- Specified by:
containsAll
in interfaceCollection<E>
- Specified by:
containsAll
in interfaceSet<E>
- Overrides:
containsAll
in classAbstractCollection<E>
-
addAll
- Specified by:
addAll
in interfaceCollection<E>
- Specified by:
addAll
in interfaceSet<E>
- Overrides:
addAll
in classAbstractCollection<E>
-
retainAll
- Specified by:
retainAll
in interfaceCollection<E>
- Specified by:
retainAll
in interfaceSet<E>
- Overrides:
retainAll
in classAbstractCollection<E>
-
clear
public void clear()- Specified by:
clear
in interfaceCollection<E>
- Specified by:
clear
in interfaceSet<E>
- Overrides:
clear
in classAbstractCollection<E>
-
iterator
-
size
public int size()- Specified by:
size
in interfaceCollection<E>
- Specified by:
size
in interfaceSet<E>
- Specified by:
size
in classAbstractCollection<E>
-
copy
Description copied from interface:Copyable
Creates and returns a copy of this object. -
addAllDiff
Description copied from interface:SetEx
Adds all elements in collectionc
, and returns the difference set betweenc
and this set (before the call).- Specified by:
addAllDiff
in interfaceSetEx<E>
- Overrides:
addAllDiff
in classAbstractSetEx<E>
- Returns:
- a set of elements that are contained in
c
but not in this set before the call.
-