com.cosylab.epics.caj.util
Class ArrayFIFO

java.lang.Object
  extended by com.cosylab.epics.caj.util.ArrayFIFO

public class ArrayFIFO
extends Object

FIFO "stack".


Constructor Summary
ArrayFIFO()
          Constructs an empty array deque with an initial capacity sufficient to hold 16 elements.
ArrayFIFO(int numElements)
          Constructs an empty array deque with an initial capacity sufficient to hold the specified number of elements.
 
Method Summary
 void addFirst(Object e)
          Inserts the specified element at the front of this deque.
 void addLast(Object e)
          Inserts the specified element at the end of this deque.
 void clear()
          Removes all of the elements from this deque.
 boolean isEmpty()
          Returns true if this deque contains no elements.
 Object peek()
          Looks at the object at the top of this stack without removing it from the stack.
 Object peekFirst()
           
 Object peekLast()
           
 Object pollFirst()
           
 Object pollLast()
           
 Object pop()
          Pops an element from the stack represented by this deque.
 void push(Object e)
          Pushes an element onto the stack represented by this deque.
 boolean remove(Object o)
          Removes the first occurrence of the specified element in this deque (when traversing the deque from head to tail).
 int size()
          Returns the number of elements in this deque.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ArrayFIFO

public ArrayFIFO()
Constructs an empty array deque with an initial capacity sufficient to hold 16 elements.


ArrayFIFO

public ArrayFIFO(int numElements)
Constructs an empty array deque with an initial capacity sufficient to hold the specified number of elements.

Parameters:
numElements - lower bound on initial capacity of the deque
Method Detail

addFirst

public void addFirst(Object e)
Inserts the specified element at the front of this deque.

Parameters:
e - the element to add
Throws:
NullPointerException - if the specified element is null

addLast

public void addLast(Object e)
Inserts the specified element at the end of this deque.

This method is equivalent to #add.

Parameters:
e - the element to add
Throws:
NullPointerException - if the specified element is null

pollFirst

public Object pollFirst()

pollLast

public Object pollLast()

peekFirst

public Object peekFirst()

peekLast

public Object peekLast()

push

public void push(Object e)
Pushes an element onto the stack represented by this deque. In other words, inserts the element at the front of this deque.

Parameters:
e - the element to push
Throws:
NullPointerException - if the specified element is null

pop

public Object pop()
Pops an element from the stack represented by this deque. In other words, removes and returns the first element of this deque.

Returns:
the element at the front of this deque (which is the top of the stack represented by this deque), null if no element available.

peek

public Object peek()
Looks at the object at the top of this stack without removing it from the stack.

Returns:
the object at the top of this stack (the last item of the Vector object).

size

public int size()
Returns the number of elements in this deque.

Returns:
the number of elements in this deque

isEmpty

public boolean isEmpty()
Returns true if this deque contains no elements.

Returns:
true if this deque contains no elements

clear

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


remove

public boolean remove(Object o)
Removes the first occurrence of the specified element in this deque (when traversing the deque from head to tail). If the deque does not contain the element, it is unchanged. More formally, removes the first element e such that o.equals(e) (if such an element exists). Returns true if this deque contained the specified element (or equivalently, if this deque changed as a result of the call).

Parameters:
o - element to be removed from this deque, if present
Returns:
true if the deque contained the specified element


Copyright © 2004-2013 Cosylab. All Rights Reserved.