edu.mit.csail.sdg.alloy4
Class ConstSet<K>

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractSet<K>
          extended by edu.mit.csail.sdg.alloy4.ConstSet<K>
Type Parameters:
K - - the type of element
All Implemented Interfaces:
java.io.Serializable, java.lang.Iterable<K>, java.util.Collection<K>, java.util.Set<K>

public final class ConstSet<K>
extends java.util.AbstractSet<K>
implements java.io.Serializable

Immutable; implements a set based on hashCode() and equals(); null value is allowed.

See Also:
Serialized Form

Method Summary
 boolean contains(java.lang.Object element)
          Returns true if the given object is in this set.
 java.util.Iterator<K> iterator()
          Returns a read-only iterator over this set.
static
<K> ConstSet<K>
make()
          Returns an unmodifiable empty set.
static
<K> ConstSet<K>
make(java.lang.Iterable<K> collection)
          Returns an unmodifiable set with the same elements and traversal order as the given set.
 int size()
          Returns the number of objects in this set.
 
Methods inherited from class java.util.AbstractSet
equals, hashCode, removeAll
 
Methods inherited from class java.util.AbstractCollection
add, addAll, clear, containsAll, isEmpty, remove, retainAll, toArray, toArray, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Set
add, addAll, clear, containsAll, isEmpty, remove, retainAll, toArray, toArray
 

Method Detail

make

public static <K> ConstSet<K> make()
Returns an unmodifiable empty set.


make

public static <K> ConstSet<K> make(java.lang.Iterable<K> collection)
Returns an unmodifiable set with the same elements and traversal order as the given set. (If set==null, we'll return an unmodifiable empty set)


size

public int size()
Returns the number of objects in this set.

Specified by:
size in interface java.util.Collection<K>
Specified by:
size in interface java.util.Set<K>
Specified by:
size in class java.util.AbstractCollection<K>

iterator

public java.util.Iterator<K> iterator()
Returns a read-only iterator over this set.

Specified by:
iterator in interface java.lang.Iterable<K>
Specified by:
iterator in interface java.util.Collection<K>
Specified by:
iterator in interface java.util.Set<K>
Specified by:
iterator in class java.util.AbstractCollection<K>

contains

public boolean contains(java.lang.Object element)
Returns true if the given object is in this set.

Specified by:
contains in interface java.util.Collection<K>
Specified by:
contains in interface java.util.Set<K>
Overrides:
contains in class java.util.AbstractCollection<K>