Package org.drools.core.reteoo
Class LeftTupleSinkNodeList
- java.lang.Object
-
- org.drools.core.reteoo.LeftTupleSinkNodeList
-
- All Implemented Interfaces:
java.io.Externalizable,java.io.Serializable
public class LeftTupleSinkNodeList extends java.lang.Object implements java.io.ExternalizableThis is a simple linked linked implementation. Each node must implement LinkedListNodeso 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.remove() ) { }Iterator that pops the first entry:for ( LinkedListNode node = list.removeFirst(); node != null; node = list.removeFirst() ) { }- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description LeftTupleSinkNodeList()Construct an emptyLinkedList
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(LeftTupleSinkNode node)Add aTupleSinkNodeto the list.voidclear()Iterates the list removing all the nodes until there are no more nodes to remove.LeftTupleSinkNodegetFirst()Return the first node in the listLeftTupleSinkNodegetLast()Return the last node in the listbooleanisEmpty()java.util.Iteratoriterator()Returns a list iteratorvoidreadExternal(java.io.ObjectInput in)voidremove(LeftTupleSinkNode node)Removes aTupleSinkNodefrom the list.LeftTupleSinkNoderemoveFirst()Remove the first node from the list.LeftTupleSinkNoderemoveLast()Remove the last node from the list.intsize()voidwriteExternal(java.io.ObjectOutput out)
-
-
-
Method Detail
-
readExternal
public void readExternal(java.io.ObjectInput in) throws java.io.IOException, java.lang.ClassNotFoundException- Specified by:
readExternalin interfacejava.io.Externalizable- Throws:
java.io.IOExceptionjava.lang.ClassNotFoundException
-
writeExternal
public void writeExternal(java.io.ObjectOutput out) throws java.io.IOException- Specified by:
writeExternalin interfacejava.io.Externalizable- Throws:
java.io.IOException
-
add
public void add(LeftTupleSinkNode node)
Add aTupleSinkNodeto the list. If theLinkedListis empty then the first and last nodes are set to the added node.- Parameters:
node- TheTupleSinkNodeto be added
-
remove
public void remove(LeftTupleSinkNode node)
Removes aTupleSinkNodefrom the list. This works by attach the previous reference to the child reference. When the node to be removed is the first node it callsremoveFirst(). When the node to be removed is the last node it callsremoveLast().- Parameters:
node- TheTupleSinkNodeto be removed.
-
getFirst
public final LeftTupleSinkNode getFirst()
Return the first node in the list- Returns:
- The first
TupleSinkNode.
-
getLast
public final LeftTupleSinkNode getLast()
Return the last node in the list- Returns:
- The last
TupleSinkNode.
-
removeFirst
public LeftTupleSinkNode 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
TupleSinkNode.
-
removeLast
public LeftTupleSinkNode 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
TupleSinkNode.
-
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
-
iterator
public java.util.Iterator iterator()
Returns a list iterator- Returns:
-
-