@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 ); }
@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 ); }
@Test public void testGetLast() { assertNull( "Empty list should return null on getLast()", this.list.getLast() ); this.list.add( this.node1 ); assertSame( "List should return node1 on getLast()", this.list.getLast(), this.node1 ); this.list.add( this.node2 ); assertSame( "List should return node2 on getLast()", this.list.getLast(), this.node2 ); this.list.add( this.node3 ); assertSame( "List should return node3 on getLast()", this.list.getLast(), this.node3 ); }
@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() ); }
@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() ); }
@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() ); }
public void addLogicalDependency(final LogicalDependency node) { if ( this.justified == null ) { this.justified = new LinkedList<LogicalDependency>(); } this.justified.add( node ); }
public void addActivation(final Activation activation) { final ActivationGroupNode node = new ActivationGroupNode( activation, this ); activation.setActivationGroupNode( node ); this.list.add( node ); }
@Test public void testAdd() { this.list.add( this.node1 ); assertNull( "Node1 previous should be null", this.node1.getPrevious() ); this.node1 ); this.list.add( this.node2 ); assertSame( "node1 next should be node2", this.node1.getNext(), this.node2 ); this.list.add( this.node3 ); assertSame( "node2 next should be node3", this.node2.getNext(),
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() ); } }
public void add(final Activation activation) { AgendaItem item = (AgendaItem) activation; this.size++; int seq = item.getSequenence(); if ( seq < this.index ) { this.index = seq; } if ( seq > this.lastIndex ) { this.lastIndex = seq; } LinkedList<LinkedListEntry<Activation>> list = this.array[seq]; if ( list == null ) { list = new LinkedList<LinkedListEntry<Activation>>(); this.array[item.getSequenence()] = list; } list.add( new LinkedListEntry<Activation>( activation ) ); }
public void addActivation(final Activation activation) { assert activation.getActivationNode() == null; final ActivationNode node = new ActivationNode( activation, this ); activation.setActivationNode( node ); this.list.add( node ); if ( this.active ) { ((InternalAgendaGroup) activation.getAgendaGroup()).add( activation ); } }
/** * Schedule an agenda item for delayed firing. * * @param item * The item to schedule. */ public void scheduleItem(final ScheduledAgendaItem item, final InternalWorkingMemory wm) { this.scheduledActivations.add( item ); item.setEnqueued( true ); if( item.getPropagationContext().getReaderContext() == null ) { // this is not a serialization propagation, so schedule it // otherwise the timer will be correlated with this activation later during the // deserialization of timers Scheduler.scheduleAgendaItem( item, this, wm ); } }