net.cscott.jutil
public class WorkSet<E> extends AbstractSet<E> implements Serializable
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.2 2004/01/13 01:28:37 cananian Exp $
Constructor Summary | |
---|---|
WorkSet() Creates a new, empty WorkSet with a default capacity
and load factor. | |
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. | |
<T extends E> | WorkSet(Collection<T> c) Constructs a new WorkSet with the contents of the
specified Collection . |
Method Summary | |
---|---|
boolean | add(E o) Adds the object to the set and returns true if the element
is not already present. |
boolean | addFirst(E o) Adds an element to the front of the (ordered) set and returns true,
if the element is not already present in the set. |
boolean | addLast(E o) Adds an element to the end of the (ordered) set and returns true,
if the element is not already present in the set. |
void | clear() Removes all elements from the set. |
boolean | contains(Object o) Determines if this contains an item.
|
E | getFirst() Returns the first element in the ordered set. |
E | getLast() Returns the last element in the ordered set. |
boolean | isEmpty() Determines if there are any more items left in this.
|
Iterator<E> | iterator() Efficient set iterator. |
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. |
void | push(E item) Pushes item onto the top of this WorkSet (treating
it as a Stack ), if it is not already there.
|
boolean | remove(Object o) |
E | removeFirst() Removes the first element in the ordered set and returns it. |
E | removeLast() Removes the last element in the ordered set and returns it. |
int | size() |
WorkSet
with a default capacity
and load factor.WorkSet
with the specified
initial capacity and default load factor.WorkSet
with the specified
initial capacity and the specified load factor.WorkSet
with the contents of the
specified Collection
.o
is an element of
this
, returns true.
Else returns false.this
has any elements,
returns true. Else returns false.WorkSet
(treating it as a Stack
) without removing it
from the set/stack.WorkSet
(treating it as a Stack
) and returns that object
as the value of this function.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.
this
item
is not already an
element of this
, adds
item
to this
.
Else does nothing.