org.openorb.util
Class MergeStack

java.lang.Object
  extended byjava.util.AbstractCollection
      extended byjava.util.AbstractList
          extended byjava.util.AbstractSequentialList
              extended byorg.openorb.util.MergeStack
All Implemented Interfaces:
java.util.Collection, java.util.List

public class MergeStack
extends java.util.AbstractSequentialList

A weak set. This does not prevent it's members being reclaimed by the garbage collector.

Version:
$Revision: 1.2 $ $Date: 2001/08/09 11:28:46 $
Author:
Chris Wood <wood@intalio.com>

Constructor Summary
MergeStack()
          Constructs a new, empty list.
MergeStack(int allocInc)
          Constructs a new, empty list with the given allocation increment
 
Method Summary
 boolean add(java.lang.Object obj)
          Appends the specified element to the end of this stack (optional operation).
 void addFirst(java.lang.Object obj)
          Add a new element to the front of the stack.
 void addLast(java.lang.Object obj)
          Add a new element to the end of the stack.
 void append(MergeStack next)
          Append another MergeStack onto this one.
 void clear()
          Removes all of the elements from this collection.
 java.lang.Object getFirst()
          Get the first element in the list.
 java.lang.Object getLast()
          Get the first element in the list.
 java.util.ListIterator listIterator(int index)
          Returns a list iterator over the elements in this list (in proper sequence).
static void main(java.lang.String[] args)
           
 java.lang.Object removeFirst()
          Remove and return the first element in the list.
 java.lang.Object removeLast()
          Remove and return the last element in the list.
 int size()
          Returns the number of elements in this collection.
 
Methods inherited from class java.util.AbstractSequentialList
add, addAll, get, iterator, remove, set
 
Methods inherited from class java.util.AbstractList
equals, hashCode, indexOf, lastIndexOf, listIterator, subList
 
Methods inherited from class java.util.AbstractCollection
addAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray, toString
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.List
addAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray
 

Constructor Detail

MergeStack

public MergeStack()
Constructs a new, empty list.


MergeStack

public MergeStack(int allocInc)
Constructs a new, empty list with the given allocation increment

Method Detail

clear

public void clear()
Removes all of the elements from this collection. The collection will be empty after this call returns.


listIterator

public java.util.ListIterator listIterator(int index)
Returns a list iterator over the elements in this list (in proper sequence).

Returns:
a list iterator over the elements in this list (in proper sequence).

size

public int size()
Returns the number of elements in this collection. If the collection contains more than Integer.MAX_VALUE elements, returns Integer.MAX_VALUE.

Returns:
the number of elements in this collection.

add

public boolean add(java.lang.Object obj)
Appends the specified element to the end of this stack (optional operation).

Returns:
true (as per the general contract of Collection.add).

getFirst

public java.lang.Object getFirst()
Get the first element in the list.

Throws:
java.util.NoSuchElementException - if the list is empty.

addFirst

public void addFirst(java.lang.Object obj)
Add a new element to the front of the stack.


removeFirst

public java.lang.Object removeFirst()
Remove and return the first element in the list.

Throws:
java.util.NoSuchElementException - if the list is empty.

getLast

public java.lang.Object getLast()
Get the first element in the list.

Throws:
java.util.NoSuchElementException - if the list is empty.

addLast

public void addLast(java.lang.Object obj)
Add a new element to the end of the stack.


removeLast

public java.lang.Object removeLast()
Remove and return the last element in the list.

Throws:
java.util.NoSuchElementException - if the list is empty.

append

public void append(MergeStack next)
Append another MergeStack onto this one. The other merge stack will end up empty.


main

public static void main(java.lang.String[] args)
                 throws java.lang.Throwable
Throws:
java.lang.Throwable