coins.alias.util
Class BriggsSet

java.lang.Object
  extended bycoins.alias.util.BriggsSet

public class BriggsSet
extends java.lang.Object

Set of unsigned integers implemented using two arrays. It has constant time performance for search, insertion, deletion, and initialization (emptying) operations. Scanning all the elements takes time proportional to the size of the set. The largest integer (plus 1) that can enter the set has to be specified when instatiating this class, and the instatiation itself takes time proportional to the number specified.

See Also:
"D. Morgan, Building an Optimizing Compiler, pp.90-92"

Constructor Summary
BriggsSet(int pSize)
          Creates a new instance of BriggsSet
 
Method Summary
 boolean deleteElement(int pElem)
          Tries to delete the given element from this set.
 boolean findElement(int pElem)
          Searches for the given element.
 boolean insertElement(int pElem)
          Tries to insert the given element into this set.
 void makeSetEmpty()
          Initializes the set.
 Scanner scanner()
          Returns the scanner that iterates through this set.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BriggsSet

public BriggsSet(int pSize)
Creates a new instance of BriggsSet

Parameters:
pSize - the grand upper size, or the largest number that can enter the set plus one.
Method Detail

makeSetEmpty

public void makeSetEmpty()
Initializes the set.


findElement

public boolean findElement(int pElem)
Searches for the given element.

Parameters:
pElem - the element to search for.
Returns:
true if the element was found.

insertElement

public boolean insertElement(int pElem)
Tries to insert the given element into this set.

Parameters:
pElem - the element to insert.
Returns:
true if insertion really took place.

deleteElement

public boolean deleteElement(int pElem)
Tries to delete the given element from this set.

Parameters:
pElem - the element to delete.
Returns:
true if deletion really took place.

scanner

public Scanner scanner()
Returns the scanner that iterates through this set.