站内搜索: 请输入搜索关键词
当前页面: 在线文档首页 > JBoss RULES 4.0.0.11754MR2 API 英文版文档

LinkedList (Drools 4.0.0.11754MR2 API) - JBoss RULES 4.0.0.11754MR2 API 英文版文档


org.drools.util
Class LinkedList

java.lang.Object
  extended by org.drools.util.LinkedList
All Implemented Interfaces:
Serializable

public class LinkedList
extends Object
implements Serializable

This is a simple linked linked implementation. Each node must implement LinkedListNode so that it references the node before and after it. This way a node can be removed without having to scan the list to find it. This class does not provide an Iterator implementation as its designed for efficiency and not genericity. There are a number of ways to iterate the list.

Simple iterator:

 for ( LinkedListNode node = list.getFirst(); node != null; node =  node.getNext() ) {
 }
 
Iterator that pops the first entry:
 for ( LinkedListNode node = list.removeFirst(); node != null; node = list.removeFirst() ) {
 }
 

Author:
Mark Proctor, Bob McWhirter
See Also:
Serialized Form

Nested Class Summary
static class LinkedList.JavaUtilIterator
           
 class LinkedList.LinkedListIterator
          Returns a list iterator
 
Constructor Summary
LinkedList()
          Construct an empty LinkedList
 
Method Summary
 void add(LinkedListNode node)
          Add a LinkedListNode to the list.
 void clear()
          Iterates the list removing all the nodes until there are no more nodes to remove.
 boolean equals(Object object)
           
 LinkedListNode getFirst()
          Return the first node in the list
 LinkedListNode getLast()
          Return the last node in the list
 int hashCode()
           
 void insertAfter(LinkedListNode existingNode, LinkedListNode newNode)
           
 boolean isEmpty()
           
 LinkedList.LinkedListIterator iterator()
           
 Iterator javaUtilIterator()
           
 void remove(LinkedListNode node)
          Removes a LinkedListNode from the list.
 LinkedListNode removeFirst()
          Remove the first node from the list.
 LinkedListNode removeLast()
          Remove the last node from the list.
 int size()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LinkedList

public LinkedList()
Construct an empty LinkedList

Method Detail

add

public void add(LinkedListNode node)
Add a LinkedListNode to the list. If the LinkedList is empty then the first and last nodes are set to the added node.

Parameters:
node - The LinkedListNode to be added

remove

public void remove(LinkedListNode node)
Removes a LinkedListNode from the list. This works by attach the previous reference to the child reference. When the node to be removed is the first node it calls removeFirst(). When the node to be removed is the last node it calls removeLast().

Parameters:
node - The LinkedListNode to be removed.

getFirst

public final LinkedListNode getFirst()
Return the first node in the list

Returns:
The first LinkedListNode.

getLast

public final LinkedListNode getLast()
Return the last node in the list

Returns:
The last LinkedListNode.

removeFirst

public LinkedListNode removeFirst()
Remove the first node from the list. The next node then becomes the first node. If this is the last node then both first and last node references are set to null.

Returns:
The first LinkedListNode.

insertAfter

public void insertAfter(LinkedListNode existingNode,
                        LinkedListNode newNode)

removeLast

public LinkedListNode removeLast()
Remove the last node from the list. The previous node then becomes the last node. If this is the last node then both first and last node references are set to null.

Returns:
The first LinkedListNode.

isEmpty

public final boolean isEmpty()
Returns:
boolean value indicating the empty status of the list

clear

public void clear()
Iterates the list removing all the nodes until there are no more nodes to remove.


size

public final int size()
Returns:
return size of the list as an int

hashCode

public int hashCode()
Overrides:
hashCode in class Object

equals

public boolean equals(Object object)
Overrides:
equals in class Object

iterator

public LinkedList.LinkedListIterator iterator()

javaUtilIterator

public Iterator javaUtilIterator()


Copyright © 2001-2007 JBoss Inc.. All Rights Reserved.