|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface LongSet
A collection that contains no duplicates. In other words, for two set
elements e1 and e2, e1.equals(e2)
returns false. There
are additional stipulations on add
, equals
and hashCode
, as well as the requirements that constructors
do not permit duplicate elements. The Set interface is incompatible with
List; you cannot implement both simultaneously.
Note: Be careful about using mutable objects in sets. In particular, if a mutable object changes to become equal to another set element, you have violated the contract. As a special case of this, a Set is not allowed to be an element of itself, without risking undefined behavior.
LongCollection
,
AbstractLongSet
Method Summary | |
---|---|
boolean |
add(long o)
Adds the specified element to the set if it is not already present (optional operation). |
boolean |
addAll(LongCollection c)
Adds all of the elements of the given collection to this set (optional operation). |
void |
clear()
Removes all elements from this set (optional operation). |
boolean |
contains(long o)
Returns true if the set contains the specified element. |
boolean |
containsAll(LongCollection c)
Returns true if this set contains all elements in the specified collection. |
boolean |
equals(java.lang.Object o)
Compares the specified object to this for equality. |
int |
hashCode()
Returns the hash code for this set. |
boolean |
isEmpty()
Returns true if the set contains no elements. |
LongIterator |
iterator()
Returns an iterator over the set. |
boolean |
remove(long o)
Removes the specified element from this set (optional operation). |
boolean |
removeAll(LongCollection c)
Removes from this set all elements contained in the specified collection (optional operation). |
boolean |
retainAll(LongCollection c)
Retains only the elements in this set that are also in the specified collection (optional operation). |
int |
size()
Returns the number of elements in the set. |
long[] |
toArray()
Returns an array containing the elements of this set. |
long[] |
toArray(long[] a)
Returns an array containing the elements of this set, of the same runtime type of the argument. |
Method Detail |
---|
boolean add(long o)
o == null ? e == null : o.equals(e)
. Sets need not permit
all values, and may document what exceptions will be thrown if
a value is not permitted.
add
in interface LongCollection
o
- the object to add
java.lang.UnsupportedOperationException
- if this operation is not allowed
java.lang.ClassCastException
- if the class of o prevents it from being added
java.lang.IllegalArgumentException
- if some aspect of o prevents it from
being added
java.lang.NullPointerException
- if null is not permitted in this setboolean addAll(LongCollection c)
addAll
in interface LongCollection
c
- the collection to add
java.lang.UnsupportedOperationException
- if this operation is not allowed
java.lang.ClassCastException
- if the class of an element prevents it from
being added
java.lang.IllegalArgumentException
- if something about an element prevents
it from being added
java.lang.NullPointerException
- if null is not permitted in this set, or
if the argument c is nulladd(long)
void clear()
clear
in interface LongCollection
java.lang.UnsupportedOperationException
- if this operation is not allowedboolean contains(long o)
o == null ? e == null : o.equals(e)
.
contains
in interface LongCollection
o
- the object to look for
java.lang.ClassCastException
- if the type of o is not a valid type
for this set.
java.lang.NullPointerException
- if o is null and this set doesn't
support null values.boolean containsAll(LongCollection c)
containsAll
in interface LongCollection
c
- the collection to check membership in
java.lang.NullPointerException
- if c is null
java.lang.ClassCastException
- if the type of any element in c is not
a valid type for this set.
java.lang.NullPointerException
- if some element of c is null and this
set doesn't support null values.contains(long)
boolean equals(java.lang.Object o)
equals
in interface LongCollection
equals
in class java.lang.Object
o
- the object to compare to
int hashCode()
hashCode
in interface LongCollection
hashCode
in class java.lang.Object
equals(Object)
boolean isEmpty()
isEmpty
in interface LongCollection
LongIterator iterator()
iterator
in interface LongCollection
iterator
in interface LongIterable
boolean remove(long o)
o == null ? e == null : o.equals(e)
,
it is removed from the set.
remove
in interface LongCollection
o
- the object to remove
java.lang.UnsupportedOperationException
- if this operation is not allowed
java.lang.ClassCastException
- if the type of o is not a valid type
for this set.
java.lang.NullPointerException
- if o is null and this set doesn't allow
the removal of a null value.boolean removeAll(LongCollection c)
removeAll
in interface LongCollection
c
- the collection to remove from this set
java.lang.UnsupportedOperationException
- if this operation is not allowed
java.lang.NullPointerException
- if c is null
java.lang.ClassCastException
- if the type of any element in c is not
a valid type for this set.
java.lang.NullPointerException
- if some element of c is null and this
set doesn't support removing null values.remove(long)
boolean retainAll(LongCollection c)
retainAll
in interface LongCollection
c
- the collection to keep
java.lang.UnsupportedOperationException
- if this operation is not allowed
java.lang.NullPointerException
- if c is null
java.lang.ClassCastException
- if the type of any element in c is not
a valid type for this set.
java.lang.NullPointerException
- if some element of c is null and this
set doesn't support retaining null values.remove(long)
int size()
size
in interface LongCollection
long[] toArray()
toArray
in interface LongCollection
toArray(long[])
long[] toArray(long[] a)
toArray
in interface LongCollection
a
- the array to determine the return type; if it is big enough
it is used and returned
java.lang.ArrayStoreException
- if the runtime type of a is not a supertype
of all elements in the set
java.lang.NullPointerException
- if a is nulltoArray()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |