Tabnine Logo
LinkedList
Code IndexAdd Tabnine to your IDE (free)

How to use
LinkedList
in
org.drools.core.util

Best Java code snippets using org.drools.core.util.LinkedList (Showing top 20 results out of 315)

origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.drools

public JavaUtilIterator(final LinkedList list,
            final boolean immutable) {
  this.list = list;
  this.nextNode = this.list.getFirst();
  this.immutable = immutable;
}
origin: org.drools/drools-core

  protected BetaNodeFieldConstraint[] convertToConstraints(LinkedList list) {
    final BetaNodeFieldConstraint[] array = new BetaNodeFieldConstraint[list.size()];
    int i = 0;
    for ( LinkedListEntry entry = (LinkedListEntry) list.getFirst(); entry != null; entry = (LinkedListEntry) entry.getNext() ) {
      array[i++] = (BetaNodeFieldConstraint) entry.getObject();
    }
    return array;
  }
}
origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.drools

public void addLogicalDependency(final LogicalDependency node) {
  if ( this.justified == null ) {
    this.justified = new LinkedList<LogicalDependency>();
  }
  this.justified.add( node );
}
origin: org.drools/drools-core

@Test
public void testClear() {
  this.list.add( this.node1 );
  this.list.add( this.node2 );
  this.list.add( this.node3 );
  assertEquals( "List size should be 3",
             this.list.size(),
             3 );
  this.list.clear();
  assertEquals( "Empty list should have size 0",
             this.list.size(),
             0 );
}
origin: org.drools/drools-core

@Test
public void testRemoveFirst() {
  this.list.add( this.node1 );
  this.list.add( this.node2 );
  this.list.add( this.node3 );
  assertSame( "List should return node1 on getFirst()",
            this.list.getFirst(),
            this.node1 );
  this.list.removeFirst();
  assertSame( "List should return node2 on getFirst()",
            this.list.getFirst(),
            this.node2 );
  this.list.removeFirst();
  assertSame( "List should return node3 on getFirst()",
            this.list.getFirst(),
            this.node3 );
  this.list.removeFirst();
  assertNull( "Empty list should return null on getFirst()",
            this.list.getFirst() );
}
origin: org.drools/drools-core

@Test
public void testSize() {
  this.list.add( this.node1 );
  assertEquals( "LinkedList should have 1 node",
             this.list.size(),
             1 );
  this.list.add( this.node2 );
  assertEquals( "LinkedList should have 2 nodes",
             this.list.size(),
             2 );
  this.list.add( this.node3 );
  assertEquals( "LinkedList should have 3 nodes",
             this.list.size(),
             3 );
}
origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.drools

/**
 * An Activation is no longer true so it no longer justifies  any  of the logical facts
 * it logically  asserted. It iterates  over the Activation's LinkedList of DependencyNodes
 * it retrieves the justitication  set for each  DependencyNode's FactHandle and  removes
 * itself. If the Set is empty it retracts the FactHandle from the WorkingMemory.
 *
 * @param activation
 * @param context
 * @param rule
 * @throws FactException
 */
public void removeLogicalDependencies(final Activation activation,
                   final PropagationContext context,
                   final Rule rule) throws FactException {
  final LinkedList<LogicalDependency> list = activation.getLogicalDependencies();
  if ( list == null || list.isEmpty() ) {
    return;
  }
  for ( LogicalDependency node = list.getFirst(); node != null; node = node.getNext() ) {
    removeLogicalDependency( activation, node, context );
  }
}
origin: org.drools/drools-core

@Test
public void testAdd() {
  this.list.add( this.node1 );
  assertNull( "Node1 previous should be null",
            this.node1.getPrevious() );
            this.node1.getNext() );
  assertSame( "First node should be node1",
            this.list.getFirst(),
            this.node1 );
  assertSame( "Last node should be node1",
            this.list.getLast(),
            this.node1 );
  this.list.add( this.node2 );
  assertSame( "node1 next should be node2",
            this.node1.getNext(),
            this.node1 );
  assertSame( "First node should be node1",
            this.list.getFirst(),
            this.node1 );
  assertSame( "Last node should be node2",
            this.list.getLast(),
            this.node2 );
  this.list.add( this.node3 );
  assertSame( "node2 next should be node3",
            this.node2.getNext(),
origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.drools

public void cancelRemainingPreviousLogicalDependencies() {
  if ( this.previousJustified != null ) {
    for ( LogicalDependency dep = (LogicalDependency) this.previousJustified.getFirst(); dep != null; dep = (LogicalDependency) dep.getNext() ) {
      this.workingMemory.getTruthMaintenanceSystem().removeLogicalDependency( activation, dep, activation.getPropagationContext() );
    }
  }
  if ( this.previousBlocked != null ) {
    for ( LogicalDependency dep = this.previousBlocked.getFirst(); dep != null; ) {
      LogicalDependency tmp = dep.getNext();
      this.previousBlocked.remove( dep );
      AgendaItem justified = ( AgendaItem ) dep.getJustified();
      justified.getBlockers().remove( dep.getJustifierEntry() );
      if (justified.getBlockers().isEmpty() ) {
        // the match is no longer blocked, so stage it
        ((DefaultAgenda)workingMemory.getAgenda()).getStageActivationsGroup().addActivation( justified );
      }
      dep = tmp;
    }
  }
}
origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.drools

public void blockActivation(org.drools.runtime.rule.Activation act) {
  AgendaItem targetMatch = ( AgendaItem ) act;
  // iterate to find previous equal logical insertion
  LogicalDependency dep = null;
  if ( this.previousJustified != null ) {
    for ( dep = this.previousJustified.getFirst(); dep != null; dep = dep.getNext() ) {
      if ( targetMatch ==  dep.getJustified() ) {
        this.previousJustified.remove( dep );
        break;
      }
    }
  }
  if ( dep == null ) {
    dep = new SimpleLogicalDependency( activation, targetMatch );
  }
  this.activation.addBlocked(  dep );
  if ( targetMatch.getBlockers().size() == 1 && targetMatch.isActive()  ) {
    // it wasn't blocked before, but is now, so we must remove it from all groups, so it cannot be executed.
    targetMatch.remove();
    if ( targetMatch.getActivationGroupNode() != null ) {
      targetMatch.getActivationGroupNode().getActivationGroup().removeActivation( targetMatch );
    }
    if ( targetMatch.getActivationNode() != null ) {
      final InternalRuleFlowGroup ruleFlowGroup = (InternalRuleFlowGroup) targetMatch.getActivationNode().getParentContainer();
      ruleFlowGroup.removeActivation( targetMatch );
    }
  }
}
origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.drools

public void addBlocked(final LogicalDependency dep) {
  // Adds the blocked to the blockers list
  if ( this.blocked == null ) {
    this.blocked = new LinkedList<LogicalDependency>();
  }
  this.blocked.add( dep );
  // now ad the blocker to the blocked's list - we need to check that references are null first
  AgendaItem blocked = (AgendaItem)dep.getJustified();
  if ( blocked.blockers == null ) {
    blocked.blockers = new LinkedList<LinkedListEntry<LogicalDependency>>();
    blocked.blockers.add( dep.getJustifierEntry() );
  } else if ( dep.getJustifierEntry().getNext() == null && dep.getJustifierEntry().getPrevious() == null && blocked.getBlockers().getFirst() != dep.getJustifierEntry() ) {
    blocked.blockers.add( dep.getJustifierEntry() );
  }
}

origin: org.drools/drools-core

@Test
public void testGetFirst() {
  assertNull( "Empty list should return null on getFirst()",
            this.list.getFirst() );
  this.list.add( this.node1 );
  assertSame( "List should return node1 on getFirst()",
            this.list.getFirst(),
            this.node1 );
  this.list.add( this.node2 );
  assertSame( "List should return node1 on getFirst()",
            this.list.getFirst(),
            this.node1 );
  this.list.add( this.node3 );
  assertSame( "List should return node1 on getFirst()",
            this.list.getFirst(),
            this.node1 );
}
origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.drools

public int size() {
  return this.list.size();
}
origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.drools

public Activation getNext() {
  Activation activation = null;
  while ( this.index <= lastIndex ) {
    LinkedList<LinkedListEntry<Activation>> list = this.array[this.index];
    if ( list != null ) {
      activation = list.removeFirst().getObject();
      if ( list.isEmpty()) {
        this.array[this.index++] = null;
      }
      this.size--;
      break;
    }
    this.index++;
  }
  return activation;
}
origin: org.drools/drools-core

@Test
public void testRemoveLast() {
  this.list.add( this.node1 );
  this.list.add( this.node2 );
  this.list.add( this.node3 );
  assertSame( "List should return node1 on getLast()",
            this.list.getLast(),
            this.node3 );
  this.list.removeLast();
  assertSame( "List should return node2 on getLast()",
            this.list.getLast(),
            this.node2 );
  this.list.removeLast();
  assertSame( "List should return node3 on getLast()",
            this.list.getLast(),
            this.node1 );
  this.list.removeLast();
  assertNull( "Empty list should return null on getLast()",
            this.list.getLast() );
}
origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.drools

for ( dep = this.previousJustified.getFirst(); dep != null; dep = dep.getNext() ) {
  if ( object.equals( ((InternalFactHandle) dep.getJustified()).getObject() ) ) {
    this.previousJustified.remove( dep );
    break;
origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.drools

  public void remove() {
    if ( this.immutable ) {
      throw new UnsupportedOperationException( "This  Iterator is immutable, you cannot call remove()" );
    }
    if ( this.currentNode != null ) {
      this.list.remove( this.currentNode );
      this.currentNode = null;
    } else {
      throw new IllegalStateException( "No item to remove. Call next() before calling remove()." );
    }
  }
}
origin: org.drools/drools-core

@Test
public void testIsEmpty() {
  assertTrue( "Empty list should return true on isEmpty()",
            this.list.isEmpty() );
  this.list.add( this.node1 );
  assertFalse( "Not empty list should return false on isEmpty()",
            this.list.isEmpty() );
}
origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.drools

public void setAutoDeactivate(final boolean autoDeactivate) {
  this.autoDeactivate = autoDeactivate;
  if ( autoDeactivate && this.active && this.list.isEmpty() ) {
    this.active = false;
  }
}
origin: org.drools/drools-core

@Before
public void setUp() throws Exception {
  this.list = new LinkedList();
  this.node1 = new AbstractBaseLinkedListNodeMock();
  this.node2 = new AbstractBaseLinkedListNodeMock();
  this.node3 = new AbstractBaseLinkedListNodeMock();
}
org.drools.core.utilLinkedList

Javadoc

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() ) { 
} 

Most used methods

  • getFirst
    Return the first node in the list
  • size
  • <init>
    Construct an empty LinkedList
  • add
    Add a LinkedListNode to the list. If the LinkedList is empty then the first and last nodes are set t
  • clear
    Iterates the list removing all the nodes until there are no more nodes to remove.
  • isEmpty
  • remove
    Removes a LinkedListNode from the list. This works by attach the previous reference to the child ref
  • removeFirst
    Remove the first node from the list. The next node then becomes the first node. If this is the last
  • removeLast
    Remove the last node from the list. The previous node then becomes the last node. If this is the las
  • get
  • getLast
    Return the last node in the list
  • insertAfter
  • getLast,
  • insertAfter,
  • iterator,
  • javaUtilIterator

Popular in Java

  • Updating database using SQL prepared statement
  • compareTo (BigDecimal)
  • findViewById (Activity)
  • getContentResolver (Context)
  • ObjectMapper (com.fasterxml.jackson.databind)
    ObjectMapper provides functionality for reading and writing JSON, either to and from basic POJOs (Pl
  • ServerSocket (java.net)
    This class represents a server-side socket that waits for incoming client connections. A ServerSocke
  • URI (java.net)
    A Uniform Resource Identifier that identifies an abstract or physical resource, as specified by RFC
  • ResourceBundle (java.util)
    ResourceBundle is an abstract class which is the superclass of classes which provide Locale-specifi
  • Notification (javax.management)
  • JCheckBox (javax.swing)
  • Best plugins for Eclipse
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now