org.ofbiz.base.util.collections
Class LifoSet<V>

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractSet<V>
          extended by org.ofbiz.base.util.collections.LifoSet<V>
All Implemented Interfaces:
java.io.Serializable, java.lang.Iterable<V>, java.util.Collection<V>, java.util.Set<V>

public class LifoSet<V>
extends java.util.AbstractSet<V>
implements java.io.Serializable

LifoSet - Set interface wrapper around a LinkedList

See Also:
Serialized Form

Constructor Summary
LifoSet()
          Constructs a set containing the elements of the specified collection, in the order they are returned by the collection's iterator.
LifoSet(int capacity)
          Constructs a set containing the elements of the specified collection, in the order they are returned by the collection's iterator.
 
Method Summary
 boolean add(V obj)
           
 boolean empty()
           
 java.util.Iterator<V> iterator()
           
 V peek()
           
 V pop()
           
 void push(V item)
           
 int search(java.lang.Object item)
           
 void setCapactity(int capacity)
          Sets the max capacity for this LifoSet
 int size()
           
 
Methods inherited from class java.util.AbstractSet
equals, hashCode, removeAll
 
Methods inherited from class java.util.AbstractCollection
addAll, clear, contains, containsAll, isEmpty, remove, retainAll, toArray, toArray, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Set
addAll, clear, contains, containsAll, isEmpty, remove, retainAll, toArray, toArray
 

Constructor Detail

LifoSet

public LifoSet()
Constructs a set containing the elements of the specified collection, in the order they are returned by the collection's iterator.


LifoSet

public LifoSet(int capacity)
Constructs a set containing the elements of the specified collection, in the order they are returned by the collection's iterator.

Parameters:
capacity - the collection whose elements are to be placed into this set.
Method Detail

setCapactity

public void setCapactity(int capacity)
Sets the max capacity for this LifoSet

Parameters:
capacity - Max Size (as integer)

size

public int size()
Specified by:
size in interface java.util.Collection<V>
Specified by:
size in interface java.util.Set<V>
Specified by:
size in class java.util.AbstractCollection<V>
See Also:
Collection.size()

add

public boolean add(V obj)
Specified by:
add in interface java.util.Collection<V>
Specified by:
add in interface java.util.Set<V>
Overrides:
add in class java.util.AbstractCollection<V>
See Also:
Collection.add(java.lang.Object)

iterator

public java.util.Iterator<V> iterator()
Specified by:
iterator in interface java.lang.Iterable<V>
Specified by:
iterator in interface java.util.Collection<V>
Specified by:
iterator in interface java.util.Set<V>
Specified by:
iterator in class java.util.AbstractCollection<V>
See Also:
Collection.iterator()

empty

public boolean empty()
Returns:
true if and only if this stack contains no items; false otherwise
See Also:
Stack.empty()

push

public void push(V item)
Parameters:
item - The item to be pushed onto this stack
See Also:
Stack.push(java.lang.Object)

pop

public V pop()
      throws java.util.EmptyStackException
Returns:
The object at the top of this stack
Throws:
java.util.EmptyStackException - If this stack is empty
See Also:
Stack.pop()

peek

public V peek()
       throws java.util.EmptyStackException
Returns:
The object at the top of this stack
Throws:
java.util.EmptyStackException - If this stack is empty
See Also:
Stack.peek()

search

public int search(java.lang.Object item)
Parameters:
item - The desired object
Returns:
The 1-based position from the top of the stack where the object is located; the return value -1 indicates that the object is not on the stack
See Also:
Stack.search(java.lang.Object)