Skip to content

Commit

Permalink
Previous is AbstractTuple as well (AbstractTuple is used in interface…
Browse files Browse the repository at this point in the history
… though)
  • Loading branch information
lucamolteni committed Aug 7, 2023
1 parent 4bbfac5 commit 4af1e8c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public abstract class AbstractTuple implements Tuple {
protected Tuple stagedNext;
protected Tuple stagedPrevious;

private Tuple previous;
private AbstractTuple previous;
private AbstractTuple next;

protected Sink sink;
Expand Down Expand Up @@ -104,11 +104,11 @@ public void setStagedPrevious( Tuple stagedPrevious ) {
this.stagedPrevious = stagedPrevious;
}

public Tuple getPrevious() {
public AbstractTuple getPrevious() {
return previous;
}

public void setPrevious(Tuple previous) {
public void setPrevious(AbstractTuple previous) {
this.previous = previous;
}

Expand Down
4 changes: 2 additions & 2 deletions drools-core/src/main/java/org/drools/core/reteoo/Tuple.java
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,9 @@ default boolean isDeleted() {

void setPropagationContext( PropagationContext propagationContext );

Tuple getPrevious();
AbstractTuple getPrevious();

void setPrevious( Tuple previous );
void setPrevious( AbstractTuple previous );

<S extends Sink> S getTupleSink();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public class TupleList<C> implements TupleMemory, Entry<TupleList<C>>, Serializa
private TupleList<C> next;

private Tuple first;
private Tuple last;
private AbstractTuple last;

private TupleHashTableIterator iterator;

Expand All @@ -51,7 +51,7 @@ public TupleList(C c) {

public TupleList( Tuple first, Tuple last, int size ) {
this.first = first;
this.last = last;
this.last = (AbstractTuple) last;
this.size = size;
}

Expand Down Expand Up @@ -81,12 +81,13 @@ public void clear() {
size = 0;
}

public void removeAdd(Tuple tuple) {
public void removeAdd(Tuple t) {
AbstractTuple tuple = (AbstractTuple) t;
if (this.last == tuple) {
return;
}

AbstractTuple previous = (AbstractTuple) tuple.getPrevious();
AbstractTuple previous = tuple.getPrevious();
AbstractTuple next = tuple.getNext();
if (previous == null) {
next.setPrevious( null );
Expand All @@ -96,15 +97,16 @@ public void removeAdd(Tuple tuple) {
next.setPrevious( previous );
}

this.last.setNext((AbstractTuple) tuple);
tuple.setPrevious( this.last );
this.last.setNext(tuple);
tuple.setPrevious( this.last);
tuple.setNext( null );
this.last = tuple;
}

public void add(final Tuple tuple) {
public void add(final Tuple t) {
AbstractTuple tuple = (AbstractTuple) t;
if ( this.last != null ) {
this.last.setNext( (AbstractTuple) tuple );
this.last.setNext(tuple);
tuple.setPrevious( this.last );
this.last = tuple;
} else {
Expand All @@ -117,7 +119,7 @@ public void add(final Tuple tuple) {
}

public void remove(final Tuple tuple) {
Tuple previous = tuple.getPrevious();
AbstractTuple previous = tuple.getPrevious();
AbstractTuple next = tuple.getNext();

if ( previous != null && next != null ) {
Expand Down

0 comments on commit 4af1e8c

Please sign in to comment.