public class ArrayHashSet<E> extends Object implements Cloneable, Collection<E>, List<E>
Object.hashCode()
for O(1) operations, see below.List
functionality,
ie List.indexOf(java.lang.Object)
and List.get(int)
, hence object identity can be implemented.get(java.lang.Object)
RecursiveLock
.Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_INITIAL_CAPACITY
The default initial capacity: 16
|
static float |
DEFAULT_LOAD_FACTOR
Default load factor: 0.75f
|
Constructor and Description |
---|
ArrayHashSet()
Deprecated.
|
ArrayHashSet(ArrayHashSet<E> o) |
ArrayHashSet(boolean supportNullValue,
int initialCapacity,
float loadFactor) |
ArrayHashSet(int initialCapacity)
Deprecated.
|
ArrayHashSet(int initialCapacity,
float loadFactor)
Deprecated.
|
Modifier and Type | Method and Description |
---|---|
boolean |
add(E element)
Add element at the end of this list, if it is not contained yet.
|
void |
add(int index,
E element)
Add element at the given index in this list, if it is not contained yet.
|
boolean |
addAll(Collection<? extends E> c)
Add all elements of given
Collection at the end of this list. |
boolean |
addAll(int index,
Collection<? extends E> c)
|
void |
clear() |
Object |
clone() |
boolean |
contains(Object element)
Test for containment
This is an O(1) operation. |
boolean |
containsAll(Collection<?> c)
Test for containment of given
Collection
This is an O(n) operation, over the given Collection size. |
boolean |
containsSafe(Object element)
Test for containment
This is an O(n) operation, using equals operation over the list. |
boolean |
equals(Object arrayHashSet)
This is an O(n) operation.
|
E |
get(int index) |
E |
get(Object element)
Identity method allowing to get the identical object, using the internal hash map.
|
ArrayList<E> |
getData()
Returns this object ordered ArrayList.
|
HashMap<E,E> |
getMap()
Returns this object hash map.
|
E |
getOrAdd(E element)
Identity method allowing to get the identical object, using the internal hash map.
If the element is not yet contained, add it. |
int |
hashCode()
This is an O(n) operation over the size of this list.
|
int |
indexOf(Object element) |
boolean |
isEmpty() |
Iterator<E> |
iterator() |
int |
lastIndexOf(Object o)
Since this list is unique, equivalent to
indexOf(java.lang.Object) . |
ListIterator<E> |
listIterator() |
ListIterator<E> |
listIterator(int index) |
E |
remove(int index)
Remove element at given index from this list.
|
boolean |
remove(Object element)
Remove element from this list.
|
boolean |
removeAll(Collection<?> c)
Remove all elements of given
Collection from this list. |
boolean |
retainAll(Collection<?> c)
Retain all elements of the given
Collection c, ie
remove all elements not contained by the given Collection c. |
E |
set(int index,
E element)
|
int |
size() |
List<E> |
subList(int fromIndex,
int toIndex) |
boolean |
supportsNullValue()
Returns
true for default behavior, i.e. |
Object[] |
toArray() |
<T> T[] |
toArray(T[] a) |
ArrayList<E> |
toArrayList() |
String |
toString() |
public static final float DEFAULT_LOAD_FACTOR
public static final int DEFAULT_INITIAL_CAPACITY
public ArrayHashSet()
ArrayHashSet(boolean, int, float)
public ArrayHashSet(int initialCapacity)
ArrayHashSet(boolean, int, float)
initialCapacity
- public ArrayHashSet(int initialCapacity, float loadFactor)
ArrayHashSet(boolean, int, float)
initialCapacity
- loadFactor
- public ArrayHashSet(boolean supportNullValue, int initialCapacity, float loadFactor)
supportNullValue
- Use true
for default behavior, i.e. null
can be a valid value.
Use false
if null
is not a valid value,
here #remove(E)
and getOrAdd(Object)
will be optimized.initialCapacity
- use DEFAULT_INITIAL_CAPACITY
for defaultloadFactor
- use DEFAULT_LOAD_FACTOR
for defaultsupportsNullValue()
public ArrayHashSet(ArrayHashSet<E> o)
public final boolean supportsNullValue()
true
for default behavior, i.e. null
can be a valid value.
Returns false
if null
is not a valid value,
here #remove(E)
and getOrAdd(Object)
are optimized operations.
ArrayHashSet(boolean, int, float)
public final Object clone()
public final ArrayList<E> getData()
public final HashMap<E,E> getMap()
public final void clear()
public final boolean add(E element) throws NullPointerException
add
in interface Collection<E>
add
in interface List<E>
NullPointerException
- if element
is null
but supportsNullValue()
== false
public final boolean remove(Object element) throws NullPointerException
remove
in interface Collection<E>
remove
in interface List<E>
NullPointerException
- if element
is null
but supportsNullValue()
== false
public final boolean addAll(Collection<? extends E> c)
Collection
at the end of this list.
public final boolean contains(Object element)
public final boolean containsAll(Collection<?> c)
containsAll
in interface Collection<E>
containsAll
in interface List<E>
public final boolean removeAll(Collection<?> c)
public final boolean retainAll(Collection<?> c)
Collection
c, ie
remove all elements not contained by the given Collection
c.
public final boolean equals(Object arrayHashSet)
public final int hashCode()
hashCode
in interface Collection<E>
hashCode
in interface List<E>
hashCode
in class Object
List.hashCode()
,
ie hashing all elements of this list.public final boolean isEmpty()
public final int size()
public final Object[] toArray()
public final <T> T[] toArray(T[] a)
public final void add(int index, E element) throws IllegalArgumentException, NullPointerException
add
in interface List<E>
IllegalArgumentException
- if the given element was already containedNullPointerException
- if element
is null
but supportsNullValue()
== false
public final boolean addAll(int index, Collection<? extends E> c) throws UnsupportedOperationException
addAll
in interface List<E>
UnsupportedOperationException
public final E remove(int index)
public final int lastIndexOf(Object o)
lastIndexOf
in interface List<E>
public final ListIterator<E> listIterator()
listIterator
in interface List<E>
public final ListIterator<E> listIterator(int index)
listIterator
in interface List<E>
public final ArrayList<E> toArrayList()
public final E get(Object element)
element
- hash source to find the identical Object within this listkey
hash code,
or null if not containedpublic final E getOrAdd(E element) throws NullPointerException
element
is not yet contained, add it.
element
- hash source to find the identical Object within this listkey
hash code,
or add the given key
and return it.NullPointerException
- if element
is null
but supportsNullValue()
== false
public final boolean containsSafe(Object element)
contains(java.lang.Object)
and containsSafe(java.lang.Object)
shall have the same result.