harpoon.Util.Collections
Class WorkSet<E>

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractSet<E>
          extended by net.cscott.jutil.WorkSet<E>
              extended by harpoon.Util.Collections.WorkSet<E>
All Implemented Interfaces:
Worklist<E>, Serializable, Iterable<E>, Collection<E>, Set<E>

public class WorkSet<E>
extends WorkSet<E>
implements Worklist<E>

A WorkSet is a Set offering constant-time access to the first/last element inserted, and an iterator whose speed is not dependent on the total capacity of the underlying hashtable.

Conforms to the JDK 1.2 Collections API.

Version:
$Id: WorkSet.java,v 1.7 2004/02/08 01:56:38 cananian Exp $
Author:
C. Scott Ananian <cananian@alumni.princeton.edu>
See Also:
Serialized Form

Constructor Summary
WorkSet()
           
WorkSet(Collection<? extends E> c)
          Constructs a new WorkSet with the contents of the specified Collection.
WorkSet(int initialCapacity)
          Constructs a new, empty WorkSet with the specified initial capacity and default load factor.
WorkSet(int initialCapacity, float loadFactor)
          Constructs a new, empty WorkSet with the specified initial capacity and the specified load factor.
 
Method Summary
 E peek()
          Looks at the object as the top of this WorkSet (treating it as a Stack) without removing it from the set/stack.
 E pop()
          Removes the item at the top of this WorkSet (treating it as a Stack) and returns that object as the value of this function.
 E pull()
          Removes some item from this and return it (Worklist adaptor method).
 void push(E item)
          Pushes item onto the top of this WorkSet (treating it as a Stack), if it is not already there.
 
Methods inherited from class net.cscott.jutil.WorkSet
add, addFirst, addLast, clear, contains, getFirst, getLast, isEmpty, iterator, remove, removeFirst, removeLast, size
 
Methods inherited from class java.util.AbstractSet
equals, hashCode, removeAll
 
Methods inherited from class java.util.AbstractCollection
addAll, containsAll, retainAll, toArray, toArray, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface harpoon.Util.Worklist
contains, isEmpty
 
Methods inherited from interface java.util.Set
addAll, containsAll, retainAll, toArray, toArray
 

Constructor Detail

WorkSet

public WorkSet()

WorkSet

public WorkSet(int initialCapacity)
Constructs a new, empty WorkSet with the specified initial capacity and default load factor.


WorkSet

public WorkSet(int initialCapacity,
               float loadFactor)
Constructs a new, empty WorkSet with the specified initial capacity and the specified load factor.


WorkSet

public WorkSet(Collection<? extends E> c)
Constructs a new WorkSet with the contents of the specified Collection.

Method Detail

peek

public E peek()
Looks at the object as the top of this WorkSet (treating it as a Stack) without removing it from the set/stack.

Overrides:
peek in class WorkSet<E>

pull

public E pull()
Removes some item from this and return it (Worklist adaptor method).
modifies: this
effects: If there exists an Object, item, that is an element of this, removes item from this and returns item. Else does nothing.

Specified by:
pull in interface Worklist<E>

pop

public E pop()
Removes the item at the top of this WorkSet (treating it as a Stack) and returns that object as the value of this function.

Overrides:
pop in class WorkSet<E>

push

public void push(E item)
Pushes item onto the top of this WorkSet (treating it as a Stack), if it is not already there. If the item is already in the set/on the stack, then this method does nothing.
modifies: this
effects: If item is not already an element of this, adds item to this. Else does nothing.

Specified by:
push in interface Worklist<E>
Overrides:
push in class WorkSet<E>