コード例 #1
0
 public function testCloningAlsoClonesQueue()
 {
     $foo = new \stdClass();
     $foo->name = 'bar';
     $queue = new PriorityQueue();
     $queue->insert($foo, 1);
     $queue->insert($foo, 2);
     $queueClone = clone $queue;
     while (!$queue->isEmpty()) {
         $this->assertSame($foo, $queue->top());
         $queue->remove($queue->top());
     }
     $this->assertTrue($queue->isEmpty());
     $this->assertFalse($queueClone->isEmpty());
     $this->assertEquals(2, $queueClone->count());
     while (!$queueClone->isEmpty()) {
         $this->assertSame($foo, $queueClone->top());
         $queueClone->remove($queueClone->top());
     }
     $this->assertTrue($queueClone->isEmpty());
 }
コード例 #2
0
ファイル: Chain.php プロジェクト: totolouis/ZF2-Auth
 /**
  * If the chain is non-empty then the storage with the top priority is guaranteed to be
  * filled. Return its value.
  *
  * @see StorageInterface::read()
  */
 public function read()
 {
     return $this->storageChain->top()->read();
 }