Lightweight Bartering Grid

lbg.common.queueing.priority
Class DoublyLinkedList<E>

java.lang.Object
  extended by lbg.common.queueing.priority.DoublyLinkedList<E>

public class DoublyLinkedList<E>
extends java.lang.Object

Helper class used to create double-linked lists.

Author:
Cyril Briquet

Constructor Summary
DoublyLinkedList()
           
 
Method Summary
 DoublyLinkedNode<E> append(E e)
          Appends target element to the tail of the doubly-linked list.
 DoublyLinkedNode<E> appendAndTrim(E e, int limit)
          Appends target element to the tail of the doubly-linked list, removing as many elements as required from the head of the list so that its size does not exceed the target limit, after appending the target element.
 DoublyLinkedNode<E> head()
           
 void removeHead()
          Removes the head element from the head of the doubly-linked list.
 int size()
           
 DoublyLinkedNode<E> tail()
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DoublyLinkedList

public DoublyLinkedList()
Method Detail

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

size

public int size()

head

public DoublyLinkedNode<E> head()

tail

public DoublyLinkedNode<E> tail()

append

public DoublyLinkedNode<E> append(E e)
                           throws GridException
Appends target element to the tail of the doubly-linked list.

Parameters:
e - target element
Returns:
doubly-linked node that was appended
Throws:
GridException - if target element is illegal

appendAndTrim

public DoublyLinkedNode<E> appendAndTrim(E e,
                                         int limit)
                                  throws GridException
Appends target element to the tail of the doubly-linked list, removing as many elements as required from the head of the list so that its size does not exceed the target limit, after appending the target element.

Parameters:
e - target element
limit - target size
Returns:
doubly-linked node that was appended
Throws:
GridException - if target element is illegal

removeHead

public void removeHead()
                throws GridException
Removes the head element from the head of the doubly-linked list.

Throws:
GridException - if internal data is corrupted

Lightweight Bartering Grid

Copyright (c) 2005-2008, Cyril Briquet, parts Xavier Dalem.