com.inxar.syntacs.util
Class EmptyIntSet

java.lang.Object
  |
  +--com.inxar.syntacs.util.EmptyIntSet
All Implemented Interfaces:
Cloneable, IntArray, IntIterator, IntSet

public class EmptyIntSet
extends Object
implements IntSet, IntIterator, IntArray

Concrete implementation of IntSet which may never contain elements. Used when a IntSet will always be empty and you want to conserve memory. Any attempt to modify the set will result in a RuntimeException.


Field Summary
static IntSet EMPTY_SET
          Returns a statically cached copy of the EmptyIntSet.
 
Method Summary
 int at(int index)
          Returns the value at the given index.
 Object clone()
          Clones the IntSet.
 boolean contains(int id)
          Returns true if the given value is already in this IntSet.
 boolean equals(Object other)
           
 int hashCode()
           
 boolean hasNext()
          Returns true if there is at least one more element, false otherwise (at the end of the list).
 boolean isEmpty()
          Returns true if there are no members in this IntSet (the empty set).
 IntIterator iterator()
          Returns an IntIterator view of the members in the IntSet.
 int length()
          Returns the length of the array.
 int next()
          Moves the index pointer forward by one and returns the value at that position.
 void put(int id)
          Puts the given int value in the IntSet.
 void put(IntIterator iter)
           
 int size()
          Returns the number of members in this IntSet.
 int[] toArray()
          Returns a new primitive-typed copy of the array.
 IntArray toIntArray()
          Returns the list of set members as an IntArray.
 String toString()
           
 void union(IntSet other)
          All the members of the given other IntSet are added to this IntSet.
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

EMPTY_SET

public static final IntSet EMPTY_SET
Returns a statically cached copy of the EmptyIntSet.
Method Detail

contains

public boolean contains(int id)
Description copied from interface: IntSet
Returns true if the given value is already in this IntSet.
Specified by:
contains in interface IntSet

isEmpty

public boolean isEmpty()
Description copied from interface: IntSet
Returns true if there are no members in this IntSet (the empty set).
Specified by:
isEmpty in interface IntSet

put

public void put(int id)
Description copied from interface: IntSet
Puts the given int value in the IntSet.
Specified by:
put in interface IntSet

put

public void put(IntIterator iter)

iterator

public IntIterator iterator()
Description copied from interface: IntSet
Returns an IntIterator view of the members in the IntSet.
Specified by:
iterator in interface IntSet

union

public void union(IntSet other)
Description copied from interface: IntSet
All the members of the given other IntSet are added to this IntSet.
Specified by:
union in interface IntSet

size

public int size()
Description copied from interface: IntSet
Returns the number of members in this IntSet.
Specified by:
size in interface IntSet

length

public int length()
Description copied from interface: IntArray
Returns the length of the array.
Specified by:
length in interface IntArray

at

public int at(int index)
Description copied from interface: IntArray
Returns the value at the given index.
Specified by:
at in interface IntArray

equals

public boolean equals(Object other)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

toIntArray

public IntArray toIntArray()
Description copied from interface: IntSet
Returns the list of set members as an IntArray.
Specified by:
toIntArray in interface IntSet

toArray

public int[] toArray()
Description copied from interface: IntArray
Returns a new primitive-typed copy of the array.
Specified by:
toArray in interface IntArray

toString

public String toString()
Overrides:
toString in class Object

clone

public Object clone()
             throws CloneNotSupportedException
Description copied from interface: IntSet
Clones the IntSet.
Specified by:
clone in interface IntSet

hasNext

public boolean hasNext()
Description copied from interface: IntIterator
Returns true if there is at least one more element, false otherwise (at the end of the list).
Specified by:
hasNext in interface IntIterator

next

public int next()
Description copied from interface: IntIterator
Moves the index pointer forward by one and returns the value at that position.
Specified by:
next in interface IntIterator