|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.util.AbstractCollection<E>
java.util.AbstractSet<V>
kodkod.util.collections.SingletonIdentitySet<V>
public final class SingletonIdentitySet<V>
This is an immutable singleton set implementation that tests for membership using reference-equality in place of object-equality when comparing elements.
element: V |
Constructor Summary | |
---|---|
SingletonIdentitySet(java.util.Collection<? extends V> collection)
Constructs a SingletonIdentitySet that will hold the first element returned by the given collection's iterator. |
|
SingletonIdentitySet(V element)
Constructs a SingletonIdentitySet that will hold the given element. |
Method Summary | |
---|---|
boolean |
contains(java.lang.Object obj)
Returns true iff this.element and obj are the same object. |
boolean |
containsAll(java.util.Collection<?> collection)
|
boolean |
equals(java.lang.Object o)
Compares the specified object with this set for equality. |
int |
hashCode()
Returns 0 if this.element is null; otherwise returns this.element.hashCode(). |
boolean |
isEmpty()
Returns false. |
java.util.Iterator<V> |
iterator()
|
int |
size()
Returns 1. |
Methods inherited from class java.util.AbstractSet |
---|
removeAll |
Methods inherited from class java.util.AbstractCollection |
---|
add, addAll, clear, remove, retainAll, toArray, toArray, toString |
Methods inherited from class java.lang.Object |
---|
getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface java.util.Set |
---|
add, addAll, clear, remove, retainAll, toArray, toArray |
Constructor Detail |
---|
public SingletonIdentitySet(V element)
this.element' = element |
public SingletonIdentitySet(java.util.Collection<? extends V> collection)
java.util.NoSuchElementException
- - collection.isEmpty()this.element' = collection.iterator().next() |
Method Detail |
---|
public boolean contains(java.lang.Object obj)
contains
in interface java.util.Collection<V>
contains
in interface java.util.Set<V>
contains
in class java.util.AbstractCollection<V>
public boolean containsAll(java.util.Collection<?> collection)
containsAll
in interface java.util.Collection<V>
containsAll
in interface java.util.Set<V>
containsAll
in class java.util.AbstractCollection<V>
Set.containsAll(java.util.Collection)
public boolean isEmpty()
isEmpty
in interface java.util.Collection<V>
isEmpty
in interface java.util.Set<V>
isEmpty
in class java.util.AbstractCollection<V>
public java.util.Iterator<V> iterator()
iterator
in interface java.lang.Iterable<V>
iterator
in interface java.util.Collection<V>
iterator
in interface java.util.Set<V>
iterator
in class java.util.AbstractCollection<V>
Set.iterator()
public int size()
size
in interface java.util.Collection<V>
size
in interface java.util.Set<V>
size
in class java.util.AbstractCollection<V>
public boolean equals(java.lang.Object o)
Owing to the reference-equality-based semantics of this set it is possible that the symmetry and transitivity requirements of the Object.equals contract may be violated if this set is compared to a normal set. However, the Object.equals contract is guaranteed to hold among SingletonHashSet instances.
equals
in interface java.util.Collection<V>
equals
in interface java.util.Set<V>
equals
in class java.util.AbstractSet<V>
Object.equals(Object)
public int hashCode()
hashCode
in interface java.util.Collection<V>
hashCode
in interface java.util.Set<V>
hashCode
in class java.util.AbstractSet<V>
AbstractSet.hashCode()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |