public function testAddRemove()
 {
     $item1 = 'item 1';
     $item2 = 'item 2';
     $item3 = 'item 3';
     $items = [$item1, $item2];
     $queue = new Queue();
     $queue->enqueue($item1);
     $this->assertEquals(1, $queue->size());
     $this->assertEquals($item1, $queue->poll());
     $this->assertEquals(0, $queue->size());
     $queue->enqueueAll($items);
     $this->assertEquals(2, $queue->size());
     $queue->enqueue($item3);
     $this->assertEquals(3, $queue->size());
 }
示例#2
0
 public function calculateImportance(Skill $skill)
 {
     if ($this->processedImportanceSkills->contains($skill)) {
         return;
     }
     // 		$importanceDump = $skill->getImportance();
     $descendents = $this->getDescendents($skill);
     $importance = count($descendents);
     $skill->setImportance($importance);
     $this->modifiedSkills->add($skill);
     $this->processedImportanceSkills->add($skill);
     // 		if ($importance !== $importanceDump || $importance == 0) {
     // 			$this->queuedImportanceSkills->enqueueAll($skill->getParents());
     // 		}
     $this->queuedImportanceSkills->enqueueAll($skill->getParents());
     $this->processImportanceQueue();
 }