com.inxar.syntacs.util
Class SingletonIntSet

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

public class SingletonIntSet
extends Object
implements IntSet, IntIterator, IntArray

Concrete implementation of IntSet which may only hold a single element.


Constructor Summary
SingletonIntSet(int val)
          Constructs the SingletonIntSet on the given singleton value.
 
Method Summary
 int at(int index)
          Returns the value at the given index.
 Object clone()
          Clones the IntSet.
 boolean contains(int val)
          Returns true if the given value is already in this IntSet.
 boolean equals(Object other)
           
 int getValue()
           
 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 val)
          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
 

Constructor Detail

SingletonIntSet

public SingletonIntSet(int val)
Constructs the SingletonIntSet on the given singleton value. This value cannot change over the life of the SingletonIntSet.
Method Detail

contains

public boolean contains(int val)
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 val)
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

toArray

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

toIntArray

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

equals

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

hashCode

public int hashCode()
Overrides:
hashCode in class Object

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

getValue

public int getValue()