com.virtuosotechnologies.lib.container
Interface ObjectDeque

All Superinterfaces:
ObjectContainer
All Known Subinterfaces:
ModifiableObjectDeque
All Known Implementing Classes:
BasicModifiableObjectDeque, PseudoModifiableObjectDeque

public interface ObjectDeque
extends ObjectContainer

A scaled-down double-ended queue interface with listeners. This is like java.util.List, except it includes constraints on values and listeners on state changes, and should be implemented in such a way that adds and removes on both ends are efficient. Many applications will use the ModifiableObjectDeque subinterface, which adds mutation methods.

This interface itself does not specify thread-safety semantics. The particular implementation or use in a larger interface should specify this. For example, standalone ObjectDeques may be fully synchronized and thread-safe. ObjectDeques related to AWT or Swing objects may require that all interaction be done on the AWT event thread.


Method Summary
 void addObjectDequeListener(ObjectDequeListener listener)
          Add an ObjectDequeListener.
 Object getBack()
          Get the object in back of the deque.
 Object getFront()
          Get the object in front of the deque.
 Object getNthObject(int n)
          Get the indexed object.
 void removeObjectDequeListener(ObjectDequeListener listener)
          Remove an ObjectDequeListener.
 
Methods inherited from interface com.virtuosotechnologies.lib.container.ObjectContainer
getConstraints, getContentsAsArray, getSize
 

Method Detail

getFront

public Object getFront()
Get the object in front of the deque. This is an atomic shorthand for getNthObject(0).

Returns:
the front object, or null if the deque is empty.

getBack

public Object getBack()
Get the object in back of the deque. This is an atomic shorthand for getNthObject(getSize()-1).

Returns:
the back object, or null if the deque is empty.

getNthObject

public Object getNthObject(int n)
Get the indexed object.

Parameters:
n - index.
Returns:
the nth object.
Throws:
IndexOutOfBoundsException - index out of bounds

addObjectDequeListener

public void addObjectDequeListener(ObjectDequeListener listener)
Add an ObjectDequeListener. Listeners should be added via weak references.

Parameters:
listener - new listener

removeObjectDequeListener

public void removeObjectDequeListener(ObjectDequeListener listener)
Remove an ObjectDequeListener. Does nothing if the listener is not already present.

Parameters:
listener - listener to remove