public class ArraySet
extends java.util.ArrayList
implements java.util.Set
Set
interface from the collections framework. A set cannot contain duplicate elements.
For the util
package documentation, see Package java.util.
Constructor and Description |
---|
ArraySet()
Creates an empty set.
|
ArraySet(java.util.Collection c)
Creates a set that contains all of the elements of the specified
Collection in the order returned by the iterator of the Collection . |
ArraySet(int initialCapacity)
Creates an empty set whose size is the specified initial capacity.
|
Modifier and Type | Method and Description |
---|---|
boolean |
add(java.lang.Object o)
Adds the specified element to the end of the set if the element is not already present in the set.
|
boolean |
equals(java.lang.Object o)
Determines whether the specified
Object contains the same set of elements as this ArraySet . |
int |
hashCode()
Gets the hash code value for the
ArraySet , which is the sum of all of the hash codes of the elements of the set. |
add, addAll, addAll, clear, clone, contains, ensureCapacity, forEach, get, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, removeIf, removeRange, replaceAll, retainAll, set, size, sort, spliterator, subList, toArray, toArray, trimToSize
finalize, getClass, notify, notifyAll, wait, wait, wait
public ArraySet()
public ArraySet(java.util.Collection c)
Collection
in the order returned by the iterator of the Collection
.c
- A Collection
that has the elements that you want the ArraySet
to have.public ArraySet(int initialCapacity)
initialCapacity
- An integer that specifies an initial size for the ArraySet
.public boolean add(java.lang.Object o)
add
in interface java.util.Collection
add
in interface java.util.List
add
in interface java.util.Set
add
in class java.util.ArrayList
o
- The element to add to the set.boolean
that is true
if this method adds the element to the set or false
if it does not.public boolean equals(java.lang.Object o)
Object
contains the same set of elements as this ArraySet
.equals
in interface java.util.Collection
equals
in interface java.util.List
equals
in interface java.util.Set
equals
in class java.util.AbstractList
o
- The Object
to compare to the ArraySet
.boolean
that is true
if the elements of the ArraySet
are the same as the specified Object
or false
if they are not.public int hashCode()
ArraySet
, which is the sum of all of the hash codes of the elements of the set. The hash code of a null
element is zero.hashCode
in interface java.util.Collection
hashCode
in interface java.util.List
hashCode
in interface java.util.Set
hashCode
in class java.util.AbstractList
ArraySet
.