public class IndexedHashSet<E>
extends java.lang.Object
implements java.util.Set<E>, java.util.List<E>, java.util.RandomAccess, java.io.Externalizable
Additionally, this class offers:
During construction, you can specify:
| Constructor and Description |
|---|
IndexedHashSet()
Constructs a new `IndexedHashSet`.
|
IndexedHashSet(boolean nullValuesAllowed)
Constructs a new `IndexedHashSet` with the specified option.
|
IndexedHashSet(boolean nullValuesAllowed,
boolean referenceEquality)
Constructs a new `IndexedHashSet` with the specified options.
|
IndexedHashSet(java.util.Collection<? extends E> c)
Constructs a new `IndexedHashSet` containing the elements of the specified collection.
|
IndexedHashSet(java.util.Collection<? extends E> c,
boolean nullValuesAllowed)
Constructs a new `IndexedHashSet` containing the elements of the specified collection,
with the specified option.
|
IndexedHashSet(java.util.Collection<? extends E> c,
boolean nullValuesAllowed,
boolean referenceEquality)
Constructs a new `IndexedHashSet` containing the elements of the specified collection,
with the specified options.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
add(E o) |
void |
add(int index,
E o) |
boolean |
addAll(java.util.Collection<? extends E> c) |
boolean |
addAll(int index,
java.util.Collection<? extends E> c) |
void |
clear() |
boolean |
contains(java.lang.Object o) |
boolean |
containsAll(java.util.Collection<?> c) |
boolean |
equals(java.lang.Object o) |
E |
first()
Returns the first element in the set, or null if the set is empty
|
E |
get(int index) |
int |
indexOf(java.lang.Object o) |
boolean |
isEmpty() |
boolean |
isNullValuesAllowed()
Returns whether null values are allowed in the set
|
boolean |
isReferenceEquality()
Returns whether reference equality is being used instead of object equality
|
java.util.Iterator<E> |
iterator() |
E |
last()
Returns the last element in the set, or null if the set is empty
|
int |
lastIndexOf(java.lang.Object o) |
java.util.ListIterator<E> |
listIterator() |
java.util.ListIterator<E> |
listIterator(int index) |
void |
readExternal(java.io.ObjectInput s) |
E |
remove(int index) |
boolean |
remove(java.lang.Object o) |
boolean |
removeAll(java.util.Collection<?> c) |
boolean |
retainAll(java.util.Collection<?> c) |
E |
set(int index,
E o) |
void |
setNullValuesAllowed(boolean b)
Sets whether null values are allowed in the set.
|
void |
setReferenceEquality(boolean b)
Sets whether to use reference equality instead of object equality
|
int |
size() |
java.util.Spliterator<E> |
spliterator() |
java.util.List<E> |
subList(int fromIndex,
int toIndex)
This implementation throws an
UnsupportedOperationException because
it is not possible to efficiently implement a modifiable subList view for an IndexedHashSet. |
IndexedHashSet<E> |
testIntegrity()
Performs integrity checks on the internal data structures for testing purposes
|
java.lang.Object[] |
toArray() |
<T> T[] |
toArray(T[] a) |
java.util.List<E> |
toList()
Returns an unmodifiable view of the list backing this set
|
void |
truncateToSize(int toSize)
Truncates the set to the specified size, removing elements from the end if necessary
|
void |
writeExternal(java.io.ObjectOutput s) |
public IndexedHashSet()
public IndexedHashSet(boolean nullValuesAllowed)
nullValuesAllowed - Whether null values are allowed in the set.public IndexedHashSet(boolean nullValuesAllowed,
boolean referenceEquality)
nullValuesAllowed - Whether null values are allowed in the set.referenceEquality - Whether to use reference equality instead of object equality.public IndexedHashSet(java.util.Collection<? extends E> c)
c - The collection whose elements are to be placed into this set.public IndexedHashSet(java.util.Collection<? extends E> c, boolean nullValuesAllowed)
c - The collection whose elements are to be placed into this set.nullValuesAllowed - Whether null values are allowed in the set.public IndexedHashSet(java.util.Collection<? extends E> c, boolean nullValuesAllowed, boolean referenceEquality)
c - The collection whose elements are to be placed into this set.nullValuesAllowed - Whether null values are allowed in the set.referenceEquality - Whether to use reference equality instead of object equality.public java.util.Spliterator<E> spliterator()
public void setNullValuesAllowed(boolean b)
b - `true` if null values are allowed, `false` otherwise.java.lang.IllegalStateException - If setting `nullValuesAllowed` to `false` while the set contains null elements.public boolean isNullValuesAllowed()
public void setReferenceEquality(boolean b)
b - true to use reference equality, false to use object equalitypublic boolean isReferenceEquality()
public boolean add(E o)
public boolean addAll(java.util.Collection<? extends E> c)
public void clear()
public void truncateToSize(int toSize)
toSize - the new size of the setpublic boolean contains(java.lang.Object o)
public boolean containsAll(java.util.Collection<?> c)
public boolean equals(java.lang.Object o)
public boolean isEmpty()
public java.util.Iterator<E> iterator()
public boolean remove(java.lang.Object o)
public boolean removeAll(java.util.Collection<?> c)
public boolean retainAll(java.util.Collection<?> c)
public int size()
public java.lang.Object[] toArray()
public <T> T[] toArray(T[] a)
public java.util.List<E> toList()
public boolean addAll(int index,
java.util.Collection<? extends E> c)
addAll in interface java.util.List<E>public E first()
public E last()
public int indexOf(java.lang.Object o)
indexOf in interface java.util.List<E>public int lastIndexOf(java.lang.Object o)
lastIndexOf in interface java.util.List<E>public java.util.ListIterator<E> listIterator()
listIterator in interface java.util.List<E>public java.util.ListIterator<E> listIterator(int index)
listIterator in interface java.util.List<E>public java.util.List<E> subList(int fromIndex, int toIndex)
This implementation throws an UnsupportedOperationException because
it is not possible to efficiently implement a modifiable subList view for an IndexedHashSet.
Allowing modifications to the subList would require building a special list implementation
that understands it is backed by an IndexedHashSet, which would add significant complexity.
subList in interface java.util.List<E>java.lang.UnsupportedOperationException - alwayspublic IndexedHashSet<E> testIntegrity()
java.lang.IllegalStateException - if any integrity checks failpublic void writeExternal(java.io.ObjectOutput s)
throws java.io.IOException
writeExternal in interface java.io.Externalizablejava.io.IOExceptionpublic void readExternal(java.io.ObjectInput s)
throws java.io.IOException,
java.lang.ClassNotFoundException
readExternal in interface java.io.Externalizablejava.io.IOExceptionjava.lang.ClassNotFoundExceptionCopyright © 2000-2025 OAshi S.à r.l. All Rights Reserved.