org.objectweb.dream.queue
Class ListAddRemoveFirstLastFastImpl

java.lang.Object
  extended byorg.objectweb.dream.AbstractComponent
      extended byorg.objectweb.dream.queue.ListAddRemoveFirstLastFastImpl
All Implemented Interfaces:
BindingController, LifeCycleController, List, ListAddFirstLast, ListRemoveFirstLast, Loggable

public class ListAddRemoveFirstLastFastImpl
extends AbstractComponent
implements List, ListAddFirstLast, ListRemoveFirstLast

The ListAddRemoveFirstLastFastImpl class is just a linked list that supports very efficient insertion and deletion, as well as an Enumeration interface.

Note: None of the methods in this linked list are synchronized.

This class is freely inspired from code belonging to the SEDA project (see http://sourceforge.net/projects/seda/).


Nested Class Summary
static class ListAddRemoveFirstLastFastImpl.Element
          This class represents elements of a linked list.
 class ListAddRemoveFirstLastFastImpl.FastLinkedListEnumeration
          A FastLinkedListEnumeration is a java.util.Enumeration over the ListAddRemoveFirstLastFastImpl elements.
 
Field Summary
protected  ObjectPool objectPoolItf
          The client interface used to access the pool of ListAddRemoveFirstLastFastImpl.Elementinstances.
 
Fields inherited from class org.objectweb.dream.AbstractComponent
bindingLogger, componentDesc, fcState, firstStart, lifeCycleLogger, logger, weaveableC
 
Fields inherited from interface org.objectweb.dream.queue.List
ITF_NAME
 
Fields inherited from interface org.objectweb.dream.queue.ListAddFirstLast
ITF_NAME
 
Fields inherited from interface org.objectweb.dream.queue.ListRemoveFirstLast
ITF_NAME
 
Fields inherited from interface org.objectweb.fractal.api.control.LifeCycleController
STARTED, STOPPED
 
Constructor Summary
ListAddRemoveFirstLastFastImpl()
          Allocates a brand new ListAddRemoveFirstLastFastImpl.
 
Method Summary
 void add(Object o)
          Adds the specified element to the list.
 void addFirst(Object o)
          Inserts the given element at the beginning of this list.
 void addLast(Object o)
          Appends the given element to the end of this list.
 void bindFc(String clientItfName, Object serverItf)
           
 Enumeration elements()
          Returns a java.util.Enumeration enumeration over the elements of the linked list.
 Object getFirst()
          Returns the first element in this list.
 Object getItem(Object known)
          Returns the first object that is "equal" to the given object, based on the response of the Object.equals() method.
 Object getLast()
          Returns the last element in this list.
 boolean isEmpty()
          Returns true if the list is empty.
 String[] listFc()
           
 Object remove()
          Removes an object from the list.
 Object removeFirst()
          Removes and returns the first element from this list.
 Object removeItem(Object known)
          Removes the first object that is "equal" to the given object, based on the response of the Object.equals() method.
 Object removeLast()
          Removes and returns the last element from this list.
 String toString()
           
 
Methods inherited from class org.objectweb.dream.AbstractComponent
beforeFirstStart, getFcState, initComponent, lookupFc, setLogger, startFc, stopFc, unbindFc
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

objectPoolItf

protected ObjectPool objectPoolItf
The client interface used to access the pool of ListAddRemoveFirstLastFastImpl.Elementinstances.

Constructor Detail

ListAddRemoveFirstLastFastImpl

public ListAddRemoveFirstLastFastImpl()
Allocates a brand new ListAddRemoveFirstLastFastImpl.

Method Detail

add

public void add(Object o)
Description copied from interface: List
Adds the specified element to the list.

Specified by:
add in interface List
Parameters:
o - element to be added to this list.
See Also:
List.add(Object)

remove

public Object remove()
Description copied from interface: List
Removes an object from the list.

Specified by:
remove in interface List
Returns:
the removed object, or null if the list is empty.
See Also:
List.remove()

isEmpty

public boolean isEmpty()
Description copied from interface: List
Returns true if the list is empty.

Specified by:
isEmpty in interface List
Returns:
true if the list is empty.
See Also:
List.isEmpty()

addLast

public void addLast(Object o)
Description copied from interface: ListAddFirstLast
Appends the given element to the end of this list.

Specified by:
addLast in interface ListAddFirstLast
Parameters:
o - the element to be inserted at the end of this list.
See Also:
ListAddFirstLast.addLast(Object)

addFirst

public void addFirst(Object o)
Description copied from interface: ListAddFirstLast
Inserts the given element at the beginning of this list.

Specified by:
addFirst in interface ListAddFirstLast
Parameters:
o - the element to be inserted at the beginning of this list.
See Also:
ListAddFirstLast.addFirst(Object)

getLast

public Object getLast()
Description copied from interface: ListRemoveFirstLast
Returns the last element in this list.

Specified by:
getLast in interface ListRemoveFirstLast
Returns:
the last element in this list.
See Also:
ListRemoveFirstLast.getLast()

removeLast

public Object removeLast()
Description copied from interface: ListRemoveFirstLast
Removes and returns the last element from this list.

Specified by:
removeLast in interface ListRemoveFirstLast
Returns:
the last element from this list.
See Also:
ListRemoveFirstLast.removeLast()

getFirst

public Object getFirst()
Description copied from interface: ListRemoveFirstLast
Returns the first element in this list.

Specified by:
getFirst in interface ListRemoveFirstLast
Returns:
the first element in this list.
See Also:
ListRemoveFirstLast.getFirst()

removeFirst

public Object removeFirst()
Description copied from interface: ListRemoveFirstLast
Removes and returns the first element from this list.

Specified by:
removeFirst in interface ListRemoveFirstLast
Returns:
the first element from this list.
See Also:
ListRemoveFirstLast.removeFirst()

getItem

public Object getItem(Object known)
Returns the first object that is "equal" to the given object, based on the response of the Object.equals() method.

Parameters:
known - the object to which an element must be equal.
Returns:
the matching object, or null if there is nothing that matches.

removeItem

public Object removeItem(Object known)
Removes the first object that is "equal" to the given object, based on the response of the Object.equals() method.

Parameters:
known - the object to which an element must be equal.
Returns:
the match, or null if there is nothing that matches.

elements

public Enumeration elements()
Returns a java.util.Enumeration enumeration over the elements of the linked list. If you modify the list while enumerating over it, you get what you deserve (i.e. undefined behaviour).

Returns:
the enumeration over the elements
See Also:
Enumeration

toString

public String toString()
See Also:
Object.toString()

bindFc

public void bindFc(String clientItfName,
                   Object serverItf)
            throws NoSuchInterfaceException,
                   IllegalBindingException,
                   IllegalLifeCycleException
Specified by:
bindFc in interface BindingController
Throws:
NoSuchInterfaceException
IllegalBindingException
IllegalLifeCycleException
See Also:
BindingController.bindFc(String, Object)

listFc

public String[] listFc()
Specified by:
listFc in interface BindingController
See Also:
BindingController.listFc()


Copyright © 2003, 2004 - INRIA Rhone-Alpes - All Rights Reserved.