Index: main/java/org/drools/reteoo/AlphaNode.java =================================================================== --- main/java/org/drools/reteoo/AlphaNode.java (revision 30647) +++ main/java/org/drools/reteoo/AlphaNode.java (working copy) @@ -91,15 +91,11 @@ ClassNotFoundException { super.readExternal( in ); constraint = (AlphaNodeFieldConstraint) in.readObject(); - previousRightTupleSinkNode = (ObjectSinkNode) in.readObject(); - nextRightTupleSinkNode = (ObjectSinkNode) in.readObject(); } public void writeExternal(ObjectOutput out) throws IOException { super.writeExternal( out ); out.writeObject( constraint ); - out.writeObject( previousRightTupleSinkNode ); - out.writeObject( nextRightTupleSinkNode ); } /** Index: main/java/org/drools/reteoo/BetaNode.java =================================================================== --- main/java/org/drools/reteoo/BetaNode.java (revision 30647) +++ main/java/org/drools/reteoo/BetaNode.java (working copy) @@ -125,10 +125,6 @@ behavior = (BehaviorManager) in.readObject(); leftInput = (LeftTupleSource) in.readObject(); rightInput = (ObjectSource) in.readObject(); - previousTupleSinkNode = (LeftTupleSinkNode) in.readObject(); - nextTupleSinkNode = (LeftTupleSinkNode) in.readObject(); - previousObjectSinkNode = (ObjectSinkNode) in.readObject(); - nextObjectSinkNode = (ObjectSinkNode) in.readObject(); objectMemory = in.readBoolean(); tupleMemoryEnabled = in.readBoolean(); concurrentRightTupleMemory = in.readBoolean(); @@ -141,10 +137,6 @@ out.writeObject( behavior ); out.writeObject( leftInput ); out.writeObject( rightInput ); - out.writeObject( previousTupleSinkNode ); - out.writeObject( nextTupleSinkNode ); - out.writeObject( previousObjectSinkNode ); - out.writeObject( nextObjectSinkNode ); out.writeBoolean( objectMemory ); out.writeBoolean( tupleMemoryEnabled ); out.writeBoolean( concurrentRightTupleMemory ); Index: main/java/org/drools/reteoo/EvalConditionNode.java =================================================================== --- main/java/org/drools/reteoo/EvalConditionNode.java (revision 30647) +++ main/java/org/drools/reteoo/EvalConditionNode.java (working copy) @@ -105,8 +105,6 @@ condition = (EvalCondition) in.readObject(); tupleSource = (LeftTupleSource) in.readObject(); tupleMemoryEnabled = in.readBoolean(); - previousTupleSinkNode = (LeftTupleSinkNode) in.readObject(); - nextTupleSinkNode = (LeftTupleSinkNode) in.readObject(); } public void writeExternal(ObjectOutput out) throws IOException { @@ -114,8 +112,6 @@ out.writeObject( condition ); out.writeObject( tupleSource ); out.writeBoolean( tupleMemoryEnabled ); - out.writeObject( previousTupleSinkNode ); - out.writeObject( nextTupleSinkNode ); } /** Index: main/java/org/drools/reteoo/FromNode.java =================================================================== --- main/java/org/drools/reteoo/FromNode.java (revision 30647) +++ main/java/org/drools/reteoo/FromNode.java (working copy) @@ -68,8 +68,6 @@ tupleSource = (LeftTupleSource) in.readObject(); alphaConstraints = (AlphaNodeFieldConstraint[]) in.readObject(); betaConstraints = (BetaConstraints) in.readObject(); - previousTupleSinkNode = (LeftTupleSinkNode) in.readObject(); - nextTupleSinkNode = (LeftTupleSinkNode) in.readObject(); tupleMemoryEnabled = in.readBoolean(); } @@ -79,8 +77,6 @@ out.writeObject( tupleSource ); out.writeObject( alphaConstraints ); out.writeObject( betaConstraints ); - out.writeObject( previousTupleSinkNode ); - out.writeObject( nextTupleSinkNode ); out.writeBoolean( tupleMemoryEnabled ); } Index: main/java/org/drools/reteoo/LeftInputAdapterNode.java =================================================================== --- main/java/org/drools/reteoo/LeftInputAdapterNode.java (revision 30647) +++ main/java/org/drools/reteoo/LeftInputAdapterNode.java (working copy) @@ -84,16 +84,12 @@ ClassNotFoundException { super.readExternal( in ); objectSource = (ObjectSource) in.readObject(); - previousRightTupleSinkNode = (ObjectSinkNode) in.readObject(); - nextRightTupleSinkNode = (ObjectSinkNode) in.readObject(); leftTupleMemoryEnabled = in.readBoolean(); } public void writeExternal(ObjectOutput out) throws IOException { super.writeExternal( out ); out.writeObject( objectSource ); - out.writeObject( previousRightTupleSinkNode ); - out.writeObject( nextRightTupleSinkNode ); out.writeBoolean( leftTupleMemoryEnabled ); } Index: main/java/org/drools/reteoo/LeftTupleSinkNodeList.java =================================================================== --- main/java/org/drools/reteoo/LeftTupleSinkNodeList.java (revision 30647) +++ main/java/org/drools/reteoo/LeftTupleSinkNodeList.java (working copy) @@ -24,7 +24,8 @@ */ /** - * This is a simple linked linked implementation. Each node must implement LinkedListNode so that it references + * 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. @@ -34,211 +35,257 @@ * 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 * @author Bob McWhirter - * + * */ -public class LeftTupleSinkNodeList - implements - Externalizable { - private static final long serialVersionUID = 400L; +public class LeftTupleSinkNodeList implements Externalizable +{ + private static final long serialVersionUID = 400L; - private LeftTupleSinkNode firstNode; - private LeftTupleSinkNode lastNode; + private LeftTupleSinkNode firstNode; + private LeftTupleSinkNode lastNode; - private int size; + private int size; - /** - * Construct an empty LinkedList - */ - public LeftTupleSinkNodeList() { - } + /** + * Construct an empty LinkedList + */ + public LeftTupleSinkNodeList() + {} - public void readExternal(ObjectInput in) throws IOException, - ClassNotFoundException { - firstNode = (LeftTupleSinkNode) in.readObject(); - lastNode = (LeftTupleSinkNode) in.readObject(); - size = in.readInt(); - } + public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException + { + firstNode = (LeftTupleSinkNode) in.readObject(); + lastNode = (LeftTupleSinkNode) in.readObject(); + size = in.readInt(); - public void writeExternal(ObjectOutput out) throws IOException { - out.writeObject( firstNode ); - out.writeObject( lastNode ); - out.writeInt( size ); - } + LeftTupleSinkNode current = firstNode; + while (current != null) + { + LeftTupleSinkNode previous = (LeftTupleSinkNode) in.readObject(); + LeftTupleSinkNode next = (LeftTupleSinkNode) in.readObject(); + current.setPreviousLeftTupleSinkNode(previous); + current.setNextLeftTupleSinkNode(next); + current = next; + } + } - /** - * Add a TupleSinkNode to the list. If the LinkedList is empty then the first and - * last nodes are set to the added node. - * - * @param node - * The TupleSinkNode to be added - */ - public void add(final LeftTupleSinkNode node) { - if ( this.firstNode == null ) { - this.firstNode = node; - this.lastNode = node;; - } else { - this.lastNode.setNextLeftTupleSinkNode( node ); - node.setPreviousLeftTupleSinkNode( this.lastNode ); - this.lastNode = node; - } - this.size++; - } + public void writeExternal(ObjectOutput out) throws IOException + { + out.writeObject(firstNode); + out.writeObject(lastNode); + out.writeInt(size); - /** - * Removes a TupleSinkNode 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(). - * - * @param node - * The TupleSinkNode to be removed. - */ - public void remove(final LeftTupleSinkNode node) { - if ( (this.firstNode != node) && (this.lastNode != node) ) { - node.getPreviousLeftTupleSinkNode().setNextLeftTupleSinkNode( node.getNextLeftTupleSinkNode() ); - node.getNextLeftTupleSinkNode().setPreviousLeftTupleSinkNode( node.getPreviousLeftTupleSinkNode() ); - this.size--; - node.setPreviousLeftTupleSinkNode( null ); - node.setNextLeftTupleSinkNode( null ); + for (LeftTupleSinkNode node = firstNode; node != null; node = node.getNextLeftTupleSinkNode()) + { + out.writeObject(node.getPreviousLeftTupleSinkNode()); + out.writeObject(node.getNextLeftTupleSinkNode()); + } + } - } else { - if ( this.firstNode == node ) { - removeFirst(); - } else if ( this.lastNode == node ) { - removeLast(); - } - } - } + /** + * Add a TupleSinkNode to the list. If the LinkedList is empty then + * the first and last nodes are set to the added node. + * + * @param node + * The TupleSinkNode to be added + */ + public void add(final LeftTupleSinkNode node) + { + if (this.firstNode == null) + { + this.firstNode = node; + this.lastNode = node; + ; + } + else + { + this.lastNode.setNextLeftTupleSinkNode(node); + node.setPreviousLeftTupleSinkNode(this.lastNode); + this.lastNode = node; + } + this.size++; + } - /** - * Return the first node in the list - * @return - * The first TupleSinkNode. - */ - public final LeftTupleSinkNode getFirst() { - return this.firstNode; - } + /** + * Removes a TupleSinkNode 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(). + * + * @param node + * The TupleSinkNode to be removed. + */ + public void remove(final LeftTupleSinkNode node) + { + if ((this.firstNode != node) && (this.lastNode != node)) + { + node.getPreviousLeftTupleSinkNode().setNextLeftTupleSinkNode(node.getNextLeftTupleSinkNode()); + node.getNextLeftTupleSinkNode().setPreviousLeftTupleSinkNode(node.getPreviousLeftTupleSinkNode()); + this.size--; + node.setPreviousLeftTupleSinkNode(null); + node.setNextLeftTupleSinkNode(null); - /** - * Return the last node in the list - * @return - * The last TupleSinkNode. - */ - public final LeftTupleSinkNode getLast() { - return this.lastNode; - } + } + else + { + if (this.firstNode == node) + { + removeFirst(); + } + else if (this.lastNode == node) + { + removeLast(); + } + } + } - /** - * 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. - * - * @return - * The first TupleSinkNode. - */ - public LeftTupleSinkNode removeFirst() { - if ( this.firstNode == null ) { - return null; - } - final LeftTupleSinkNode node = this.firstNode; - this.firstNode = node.getNextLeftTupleSinkNode(); - node.setNextLeftTupleSinkNode( null ); - if ( this.firstNode != null ) { - this.firstNode.setPreviousLeftTupleSinkNode( null ); - } else { - this.lastNode = null; - } - this.size--; - return node; - } + /** + * Return the first node in the list + * + * @return The first TupleSinkNode. + */ + public final LeftTupleSinkNode getFirst() + { + return this.firstNode; + } - /** - * 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. - * - * @return - * The first TupleSinkNode. - */ - public LeftTupleSinkNode removeLast() { - if ( this.lastNode == null ) { - return null; - } - final LeftTupleSinkNode node = this.lastNode; - this.lastNode = node.getPreviousLeftTupleSinkNode(); - node.setPreviousLeftTupleSinkNode( null ); - if ( this.lastNode != null ) { - this.lastNode.setNextLeftTupleSinkNode( null ); - } else { - this.firstNode = this.lastNode; - } - this.size--; - return node; - } + /** + * Return the last node in the list + * + * @return The last TupleSinkNode. + */ + public final LeftTupleSinkNode getLast() + { + return this.lastNode; + } - /** - * @return - * boolean value indicating the empty status of the list - */ - public final boolean isEmpty() { - return (this.firstNode == null); - } + /** + * 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. + * + * @return The first TupleSinkNode. + */ + public LeftTupleSinkNode removeFirst() + { + if (this.firstNode == null) { return null; } + final LeftTupleSinkNode node = this.firstNode; + this.firstNode = node.getNextLeftTupleSinkNode(); + node.setNextLeftTupleSinkNode(null); + if (this.firstNode != null) + { + this.firstNode.setPreviousLeftTupleSinkNode(null); + } + else + { + this.lastNode = null; + } + this.size--; + return node; + } - /** - * Iterates the list removing all the nodes until there are no more nodes to remove. - */ - public void clear() { - while ( removeFirst() != null ) { - } - } + /** + * 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. + * + * @return The first TupleSinkNode. + */ + public LeftTupleSinkNode removeLast() + { + if (this.lastNode == null) { return null; } + final LeftTupleSinkNode node = this.lastNode; + this.lastNode = node.getPreviousLeftTupleSinkNode(); + node.setPreviousLeftTupleSinkNode(null); + if (this.lastNode != null) + { + this.lastNode.setNextLeftTupleSinkNode(null); + } + else + { + this.firstNode = this.lastNode; + } + this.size--; + return node; + } - /** - * @return - * return size of the list as an int - */ - public final int size() { - return this.size; - } + /** + * @return boolean value indicating the empty status of the list + */ + public final boolean isEmpty() + { + return (this.firstNode == null); + } - /** - * Returns a list iterator - * @return - */ - public Iterator iterator() { - return new Iterator() { - private LeftTupleSinkNode currentNode = null; - private LeftTupleSinkNode nextNode = getFirst(); + /** + * Iterates the list removing all the nodes until there are no more nodes to remove. + */ + public void clear() + { + while (removeFirst() != null) + {} + } - public boolean hasNext() { - return (this.nextNode != null); - } + /** + * @return return size of the list as an int + */ + public final int size() + { + return this.size; + } - public Object next() { - this.currentNode = this.nextNode; - if ( this.currentNode != null ) { - this.nextNode = this.currentNode.getNextLeftTupleSinkNode(); - } else { - throw new NoSuchElementException( "No more elements to return" ); - } - return this.currentNode; - } + /** + * Returns a list iterator + * + * @return + */ + public Iterator iterator() + { + return new Iterator() + { + private LeftTupleSinkNode currentNode = null; + private LeftTupleSinkNode nextNode = getFirst(); - public void remove() { - if ( this.currentNode != null ) { - LeftTupleSinkNodeList.this.remove( this.currentNode ); - this.currentNode = null; - } else { - throw new IllegalStateException( "No item to remove. Call next() before calling remove()." ); - } - } - }; - } + public boolean hasNext() + { + return (this.nextNode != null); + } + public Object next() + { + this.currentNode = this.nextNode; + if (this.currentNode != null) + { + this.nextNode = this.currentNode.getNextLeftTupleSinkNode(); + } + else + { + throw new NoSuchElementException("No more elements to return"); + } + return this.currentNode; + } + + public void remove() + { + if (this.currentNode != null) + { + LeftTupleSinkNodeList.this.remove(this.currentNode); + this.currentNode = null; + } + else + { + throw new IllegalStateException("No item to remove. Call next() before calling remove()."); + } + } + }; + } + } Index: main/java/org/drools/reteoo/ObjectSinkNodeList.java =================================================================== --- main/java/org/drools/reteoo/ObjectSinkNodeList.java (revision 30647) +++ main/java/org/drools/reteoo/ObjectSinkNodeList.java (working copy) @@ -24,7 +24,8 @@ */ /** - * This is a simple linked linked implementation. Each node must implement
LinkedListNode so that it references + * 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. @@ -34,212 +35,258 @@ * 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 * @author Bob McWhirter - * + * */ -public class ObjectSinkNodeList - implements - Externalizable { - private static final long serialVersionUID = 400L; +public class ObjectSinkNodeList implements Externalizable +{ + private static final long serialVersionUID = 400L; - private ObjectSinkNode firstNode; - private ObjectSinkNode lastNode; + private ObjectSinkNode firstNode; + private ObjectSinkNode lastNode; - private int size; + private int size; - /** - * Construct an empty LinkedList - */ - public ObjectSinkNodeList() { + /** + * Construct an empty LinkedList + */ + public ObjectSinkNodeList() + { - } + } - public void readExternal(ObjectInput in) throws IOException, - ClassNotFoundException { - firstNode = (ObjectSinkNode) in.readObject(); - lastNode = (ObjectSinkNode) in.readObject(); - size = in.readInt(); - } + public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException + { + firstNode = (ObjectSinkNode) in.readObject(); + lastNode = (ObjectSinkNode) in.readObject(); + size = in.readInt(); - public void writeExternal(ObjectOutput out) throws IOException { - out.writeObject( firstNode ); - out.writeObject( lastNode ); - out.writeInt( size ); - } + ObjectSinkNode current = firstNode; + while (current != null) + { + ObjectSinkNode previous = (ObjectSinkNode) in.readObject(); + ObjectSinkNode next = (ObjectSinkNode) in.readObject(); + current.setPreviousObjectSinkNode(previous); + current.setNextObjectSinkNode(next); + current = next; + } + } - /** - * Add a ObjectSinkNode to the list. If the LinkedList is empty then the first and - * last nodes are set to the added node. - * - * @param node - * The ObjectSinkNode to be added - */ - public void add(final ObjectSinkNode node) { - if ( this.firstNode == null ) { - this.firstNode = node; - this.lastNode = node; - } else { - this.lastNode.setNextObjectSinkNode( node ); - node.setPreviousObjectSinkNode( this.lastNode ); - this.lastNode = node; - } - this.size++; - } + public void writeExternal(ObjectOutput out) throws IOException + { + out.writeObject(firstNode); + out.writeObject(lastNode); + out.writeInt(size); + + for (ObjectSinkNode node = firstNode; node != null; node = node.getNextObjectSinkNode()) + { + out.writeObject(node.getPreviousObjectSinkNode()); + out.writeObject(node.getNextObjectSinkNode()); + } + } - /** - * Removes a ObjectSinkNode 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(). - * - * @param node - * The ObjectSinkNode to be removed. - */ - public void remove(final ObjectSinkNode node) { - if ( (this.firstNode != node) && (this.lastNode != node) ) { - node.getPreviousObjectSinkNode().setNextObjectSinkNode( node.getNextObjectSinkNode() ); - node.getNextObjectSinkNode().setPreviousObjectSinkNode( node.getPreviousObjectSinkNode() ); - this.size--; - node.setPreviousObjectSinkNode( null ); - node.setNextObjectSinkNode( null ); + /** + * Add a ObjectSinkNode to the list. If the LinkedList is empty then + * the first and last nodes are set to the added node. + * + * @param node + * The ObjectSinkNode to be added + */ + public void add(final ObjectSinkNode node) + { + if (this.firstNode == null) + { + this.firstNode = node; + this.lastNode = node; + } + else + { + this.lastNode.setNextObjectSinkNode(node); + node.setPreviousObjectSinkNode(this.lastNode); + this.lastNode = node; + } + this.size++; + } - } else { - if ( this.firstNode == node ) { - removeFirst(); - } else { - removeLast(); - } - } - } + /** + * Removes a ObjectSinkNode 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(). + * + * @param node + * The ObjectSinkNode to be removed. + */ + public void remove(final ObjectSinkNode node) + { + if ((this.firstNode != node) && (this.lastNode != node)) + { + node.getPreviousObjectSinkNode().setNextObjectSinkNode(node.getNextObjectSinkNode()); + node.getNextObjectSinkNode().setPreviousObjectSinkNode(node.getPreviousObjectSinkNode()); + this.size--; + node.setPreviousObjectSinkNode(null); + node.setNextObjectSinkNode(null); - /** - * Return the first node in the list - * @return - * The first ObjectSinkNode. - */ - public final ObjectSinkNode getFirst() { - return this.firstNode; - } + } + else + { + if (this.firstNode == node) + { + removeFirst(); + } + else + { + removeLast(); + } + } + } - /** - * Return the last node in the list - * @return - * The last ObjectSinkNode. - */ - public final ObjectSinkNode getLast() { - return this.lastNode; - } + /** + * Return the first node in the list + * + * @return The first ObjectSinkNode. + */ + public final ObjectSinkNode getFirst() + { + return this.firstNode; + } - /** - * 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. - * - * @return - * The first ObjectSinkNode. - */ - public ObjectSinkNode removeFirst() { - if ( this.firstNode == null ) { - return null; - } - final ObjectSinkNode node = this.firstNode; - this.firstNode = node.getNextObjectSinkNode(); - node.setNextObjectSinkNode( null ); - if ( this.firstNode != null ) { - this.firstNode.setPreviousObjectSinkNode( null ); - } else { - this.lastNode = null; - } - this.size--; - return node; - } + /** + * Return the last node in the list + * + * @return The last ObjectSinkNode. + */ + public final ObjectSinkNode getLast() + { + return this.lastNode; + } - /** - * 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. - * - * @return - * The first ObjectSinkNode. - */ - public ObjectSinkNode removeLast() { - if ( this.lastNode == null ) { - return null; - } - final ObjectSinkNode node = this.lastNode; - this.lastNode = node.getPreviousObjectSinkNode(); - node.setPreviousObjectSinkNode( null ); - if ( this.lastNode != null ) { - this.lastNode.setNextObjectSinkNode( null ); - } else { - this.firstNode = this.lastNode; - } - this.size--; - return node; - } + /** + * 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. + * + * @return The first ObjectSinkNode. + */ + public ObjectSinkNode removeFirst() + { + if (this.firstNode == null) { return null; } + final ObjectSinkNode node = this.firstNode; + this.firstNode = node.getNextObjectSinkNode(); + node.setNextObjectSinkNode(null); + if (this.firstNode != null) + { + this.firstNode.setPreviousObjectSinkNode(null); + } + else + { + this.lastNode = null; + } + this.size--; + return node; + } - /** - * @return - * boolean value indicating the empty status of the list - */ - public final boolean isEmpty() { - return (this.firstNode == null); - } + /** + * 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. + * + * @return The first ObjectSinkNode. + */ + public ObjectSinkNode removeLast() + { + if (this.lastNode == null) { return null; } + final ObjectSinkNode node = this.lastNode; + this.lastNode = node.getPreviousObjectSinkNode(); + node.setPreviousObjectSinkNode(null); + if (this.lastNode != null) + { + this.lastNode.setNextObjectSinkNode(null); + } + else + { + this.firstNode = this.lastNode; + } + this.size--; + return node; + } - /** - * Iterates the list removing all the nodes until there are no more nodes to remove. - */ - public void clear() { - while ( removeFirst() != null ) { - } - } + /** + * @return boolean value indicating the empty status of the list + */ + public final boolean isEmpty() + { + return (this.firstNode == null); + } - /** - * @return - * return size of the list as an int - */ - public final int size() { - return this.size; - } + /** + * Iterates the list removing all the nodes until there are no more nodes to remove. + */ + public void clear() + { + while (removeFirst() != null) + {} + } - /** - * Returns a list iterator - * @return - */ - public Iterator iterator() { - return new Iterator() { - private ObjectSinkNode currentNode = null; - private ObjectSinkNode nextNode = getFirst(); + /** + * @return return size of the list as an int + */ + public final int size() + { + return this.size; + } - public boolean hasNext() { - return (this.nextNode != null); - } + /** + * Returns a list iterator + * + * @return + */ + public Iterator iterator() + { + return new Iterator() + { + private ObjectSinkNode currentNode = null; + private ObjectSinkNode nextNode = getFirst(); - public Object next() { - this.currentNode = this.nextNode; - if ( this.currentNode != null ) { - this.nextNode = this.currentNode.getNextObjectSinkNode(); - } else { - throw new NoSuchElementException( "No more elements to return" ); - } - return this.currentNode; - } + public boolean hasNext() + { + return (this.nextNode != null); + } - public void remove() { - if ( this.currentNode != null ) { - ObjectSinkNodeList.this.remove( this.currentNode ); - this.currentNode = null; - } else { - throw new IllegalStateException( "No item to remove. Call next() before calling remove()." ); - } - } - }; - } + public Object next() + { + this.currentNode = this.nextNode; + if (this.currentNode != null) + { + this.nextNode = this.currentNode.getNextObjectSinkNode(); + } + else + { + throw new NoSuchElementException("No more elements to return"); + } + return this.currentNode; + } + public void remove() + { + if (this.currentNode != null) + { + ObjectSinkNodeList.this.remove(this.currentNode); + this.currentNode = null; + } + else + { + throw new IllegalStateException("No item to remove. Call next() before calling remove()."); + } + } + }; + } + } Index: main/java/org/drools/reteoo/PropagationQueuingNode.java =================================================================== --- main/java/org/drools/reteoo/PropagationQueuingNode.java (revision 30647) +++ main/java/org/drools/reteoo/PropagationQueuingNode.java (working copy) @@ -77,15 +77,11 @@ public void readExternal( ObjectInput in ) throws IOException, ClassNotFoundException { super.readExternal( in ); - previousObjectSinkNode = (ObjectSinkNode) in.readObject(); - nextObjectSinkNode = (ObjectSinkNode) in.readObject(); action = (PropagateAction) in.readObject(); } public void writeExternal( ObjectOutput out ) throws IOException { super.writeExternal( out ); - out.writeObject( previousObjectSinkNode ); - out.writeObject( nextObjectSinkNode ); out.writeObject( action ); } Index: main/java/org/drools/reteoo/QueryTerminalNode.java =================================================================== --- main/java/org/drools/reteoo/QueryTerminalNode.java (revision 30647) +++ main/java/org/drools/reteoo/QueryTerminalNode.java (working copy) @@ -103,8 +103,6 @@ subrule = (GroupElement) in.readObject(); tupleSource = (LeftTupleSource) in.readObject(); tupleMemoryEnabled = in.readBoolean(); - previousTupleSinkNode = (LeftTupleSinkNode) in.readObject(); - nextTupleSinkNode = (LeftTupleSinkNode) in.readObject(); } public void writeExternal(ObjectOutput out) throws IOException { @@ -113,8 +111,6 @@ out.writeObject( subrule ); out.writeObject( tupleSource ); out.writeBoolean( tupleMemoryEnabled ); - out.writeObject( previousTupleSinkNode ); - out.writeObject( nextTupleSinkNode ); } /** Index: main/java/org/drools/reteoo/RightInputAdapterNode.java =================================================================== --- main/java/org/drools/reteoo/RightInputAdapterNode.java (revision 30647) +++ main/java/org/drools/reteoo/RightInputAdapterNode.java (working copy) @@ -83,17 +83,12 @@ super.readExternal( in ); tupleSource = (LeftTupleSource) in.readObject(); tupleMemoryEnabled = in.readBoolean(); - previousTupleSinkNode = (LeftTupleSinkNode) in.readObject(); - nextTupleSinkNode = (LeftTupleSinkNode) in.readObject(); } public void writeExternal(ObjectOutput out) throws IOException { super.writeExternal( out ); out.writeObject( tupleSource ); out.writeBoolean( tupleMemoryEnabled ); - out.writeObject( previousTupleSinkNode ); - out.writeObject( nextTupleSinkNode ); - } /** Index: main/java/org/drools/reteoo/RuleTerminalNode.java =================================================================== --- main/java/org/drools/reteoo/RuleTerminalNode.java (revision 30647) +++ main/java/org/drools/reteoo/RuleTerminalNode.java (working copy) @@ -121,8 +121,6 @@ rule = (Rule) in.readObject(); subrule = (GroupElement) in.readObject(); tupleSource = (LeftTupleSource) in.readObject(); - previousTupleSinkNode = (LeftTupleSinkNode) in.readObject(); - nextTupleSinkNode = (LeftTupleSinkNode) in.readObject(); } public void writeExternal(ObjectOutput out) throws IOException { @@ -131,8 +129,6 @@ out.writeObject( rule ); out.writeObject( subrule ); out.writeObject( tupleSource ); - out.writeObject( previousTupleSinkNode ); - out.writeObject( nextTupleSinkNode ); } /**