Search in sources :

Example 41 with Tuple

use of org.drools.core.spi.Tuple in project drools by kiegroup.

the class TupleIndexHashTable method toString.

public String toString() {
    StringBuilder builder = new StringBuilder();
    Iterator it = iterator();
    for (Tuple leftTuple = (Tuple) it.next(); leftTuple != null; leftTuple = (Tuple) it.next()) {
        builder.append(leftTuple).append("\n");
    }
    return builder.toString();
}
Also used : FastIterator(org.drools.core.util.FastIterator) Iterator(org.drools.core.util.Iterator) Tuple(org.drools.core.spi.Tuple)

Example 42 with Tuple

use of org.drools.core.spi.Tuple in project drools by kiegroup.

the class TupleList method toArray.

public Tuple[] toArray() {
    Tuple[] tuples = new Tuple[this.size];
    Tuple current = first;
    for (int i = 0; i < this.size; i++) {
        tuples[i] = current;
        current = current.getNext();
    }
    return tuples;
}
Also used : Tuple(org.drools.core.spi.Tuple)

Example 43 with Tuple

use of org.drools.core.spi.Tuple in project drools by kiegroup.

the class TupleList method copyStateInto.

protected void copyStateInto(TupleList other) {
    other.next = next;
    other.first = first;
    other.last = last;
    other.iterator = iterator;
    other.size = size;
    for (Tuple current = first; current != null; current = current.getNext()) {
        current.setMemory(other);
    }
}
Also used : Tuple(org.drools.core.spi.Tuple)

Example 44 with Tuple

use of org.drools.core.spi.Tuple in project drools by kiegroup.

the class TupleList method remove.

public void remove(final Tuple tuple) {
    Tuple previous = tuple.getPrevious();
    Tuple next = tuple.getNext();
    if (previous != null && next != null) {
        // remove from middle
        previous.setNext(next);
        next.setPrevious(previous);
    } else if (next != null) {
        // remove from first
        this.first = next;
        next.setPrevious(null);
    } else if (previous != null) {
        // remove from end
        this.last = previous;
        previous.setNext(null);
    } else {
        // remove everything
        this.last = null;
        this.first = null;
    }
    tuple.clear();
    this.size--;
}
Also used : Tuple(org.drools.core.spi.Tuple)

Example 45 with Tuple

use of org.drools.core.spi.Tuple in project drools by kiegroup.

the class TupleIndexRBTree method toArray.

public Entry[] toArray() {
    FastIterator it = tree.fastIterator();
    if (it == null) {
        return new Entry[0];
    }
    List<Comparable> toBeRemoved = new ArrayList<Comparable>();
    List<Tuple> result = new ArrayList<Tuple>();
    TupleList list = null;
    while ((list = (TupleList) it.next(list)) != null) {
        Tuple entry = list.getFirst();
        while (entry != null) {
            result.add(entry);
            entry = (Tuple) entry.getNext();
        }
    }
    return result.toArray(new Tuple[result.size()]);
}
Also used : Entry(org.drools.core.util.Entry) ArrayList(java.util.ArrayList) FastIterator(org.drools.core.util.FastIterator) Tuple(org.drools.core.spi.Tuple)

Aggregations

Tuple (org.drools.core.spi.Tuple)54 InternalFactHandle (org.drools.core.common.InternalFactHandle)17 LeftTuple (org.drools.core.reteoo.LeftTuple)16 RightTuple (org.drools.core.reteoo.RightTuple)14 FastIterator (org.drools.core.util.FastIterator)14 Declaration (org.drools.core.rule.Declaration)9 InternalWorkingMemory (org.drools.core.common.InternalWorkingMemory)8 WorkingMemory (org.drools.core.WorkingMemory)7 RightTupleImpl (org.drools.core.reteoo.RightTupleImpl)7 Cheese (org.drools.core.test.model.Cheese)7 Test (org.junit.Test)7 DefaultFactHandle (org.drools.core.common.DefaultFactHandle)6 FieldIndex (org.drools.core.util.AbstractHashTable.FieldIndex)6 AccumulateContext (org.drools.core.reteoo.AccumulateNode.AccumulateContext)5 AccumulateMemory (org.drools.core.reteoo.AccumulateNode.AccumulateMemory)5 BetaMemory (org.drools.core.reteoo.BetaMemory)5 RuleTerminalNode (org.drools.core.reteoo.RuleTerminalNode)5 TupleMemory (org.drools.core.reteoo.TupleMemory)5 MethodVisitor (org.mvel2.asm.MethodVisitor)5 FromMemory (org.drools.core.reteoo.FromNode.FromMemory)4