Ejemplo n.º 1
0
 /**
  * Constructs a StackAsLinkedList_Iterator for the given stack.
  *
  * @param object StackAsLinkedList $stack A stack.
  */
 public function __construct(StackAsLinkedList $stack)
 {
     parent::__construct();
     $this->stack = $stack;
     $this->position = $stack->getList()->getHead();
     $this->key = 0;
 }
Ejemplo n.º 2
0
 /**
  * Constructs a QueueAsArray_Iterator for the given queue.
  *
  * @param object QueueAsArray $queue A queue.
  */
 public function __construct(QueueAsArray $queue)
 {
     parent::__construct();
     $this->queue = $queue;
     $this->position = $this->queue->getHeadPosition();
     $this->count = 0;
 }
Ejemplo n.º 3
0
 /**
  * Constructs a QueueAsLinkedList_Iterator for the given queue.
  *
  * @param object QueueAsLinkedList $queue A queue.
  */
 public function __construct(QueueAsLinkedList $queue)
 {
     parent::__construct();
     $this->queue = $queue;
     $this->position = $queue->getList()->getHead();
     $this->key = 0;
 }
Ejemplo n.º 4
0
 /**
  * Constructs a MultisetAsLinkedList_Iterator for the given set.
  *
  * @param object MultisetAsLinkedList $set A set.
  */
 public function __construct(MultisetAsLinkedList $set)
 {
     parent::__construct();
     $this->set = $set;
     $this->element = $this->set->getList()->getHead();
     $this->position = 0;
 }
Ejemplo n.º 5
0
 /**
  * Constructs a AbstractSet_Iterator for the given set.
  *
  * @param object ISet $set A set.
  */
 public function __construct(ISet $set)
 {
     parent::__construct();
     $this->set = $set;
     $this->item = 0;
     while ($this->item < $this->set->getUniverseSize() && !$this->set->containsItem($this->item)) {
         ++$this->item;
     }
 }
Ejemplo n.º 6
0
 /**
  * Constructs a AbstractTree_Iterator for the given stack.
  *
  * @param object AbstractTree $tree The tree to enumerated.
  */
 public function __construct(AbstractTree $tree)
 {
     parent::__construct();
     $this->tree = $tree;
     $this->stack = new StackAsLinkedList();
     if (!$this->tree->isEmpty()) {
         $this->stack->push($this->tree);
     }
     $this->key = 0;
 }
Ejemplo n.º 7
0
 /**
  * Constructs a ChainedScatterTable_Iterator for the given hash table.
  *
  * @param object ChainedScatterTable $hashTable A hash table.
  */
 public function __construct(ChainedScatterTable $hashTable)
 {
     parent::__construct();
     $this->hashTable = $hashTable;
     $array = $this->hashTable->getArray();
     for ($this->position = 0; $this->position < $array->getLength(); ++$this->position) {
         if ($array[$this->position]->object !== NULL) {
             break;
         }
     }
 }
Ejemplo n.º 8
0
 /**
  * Constructs a MultisetAsArray_Iterator for the given set.
  *
  * @param object MultisetAsArray $set A set.
  */
 public function __construct(MultisetAsArray $set)
 {
     parent::__construct();
     $this->set = $set;
     $this->item = 0;
     $array = $this->set->getArray();
     while ($this->item < $this->set->getUniverseSize() && $array[$this->item] == 0) {
         ++$this->item;
     }
     $this->count = 0;
     $this->position = 0;
 }
Ejemplo n.º 9
0
 /**
  * Constructs a DigraphAsMatrix_EdgeIterator for the given graph.
  *
  * @param object DigraphAsMatrix $graph The graph.
  */
 public function __construct(DigraphAsMatrix $graph)
 {
     parent::__construct();
     $this->graph = $graph;
     $matrix = $this->graph->getMatrix();
     for ($this->v = 0; $this->v < $this->graph->getNumberOfVertices(); ++$this->v) {
         for ($this->w = 0; $this->w < $this->graph->getNumberOfVertices(); ++$this->w) {
             if ($matrix[array($this->v, $this->w)] !== NULL) {
                 break 2;
             }
         }
     }
 }
Ejemplo n.º 10
0
 /**
  * Constructs a ChainedHashTable_Iterator for the given hash table.
  *
  * @param object ChainedHashTable $hashTable A hash table.
  */
 public function __construct(ChainedHashTable $hashTable)
 {
     parent::__construct();
     $this->hashTable = $hashTable;
     $this->element = NULL;
     $this->key = 0;
     $array = $this->hashTable->getArray();
     for ($this->offset = 0; $this->offset < $array->getLength(); ++$this->offset) {
         $this->element = $array[$this->offset]->getHead();
         if ($this->element !== NULL) {
             break;
         }
     }
 }
Ejemplo n.º 11
0
 /**
  * Constructs an AbstractGraph_VertexIterator for the given graph.
  *
  * @param object AbstractGraph $graph This graph.
  */
 public function __construct(AbstractGraph $graph)
 {
     parent::__construct();
     $this->graph = $graph;
     $this->v = 0;
 }
Ejemplo n.º 12
0
 /**
  * Constructs a GraphAsLists_EmanatingEdgeIterator
  * for the given graph and vertex.
  *
  * @param object GraphAsLists $graph The graph.
  * @param integer $v The vertex.
  */
 public function __construct(GraphAsLists $graph, $v)
 {
     parent::__construct();
     $this->graph = $graph;
     $this->v = $v;
     $list = $this->graph->getAdjacencyList();
     $this->ptr = $list[$this->v]->getHead();
     $this->pos = 0;
 }
Ejemplo n.º 13
0
 /**
  * Constructs a ZeroOneKnapsackProblem_Node_SuccessorIterator
  * for the given node.
  *
  * @param object ZeroOneKnapsackProblem_Node $node The node.
  */
 public function __construct(ZeroOneKnapsackProblem_Node $node)
 {
     parent::__construct();
     $this->node = $node;
     $this->value = 0;
 }
Ejemplo n.º 14
0
 /**
  * Constructs a Vertex_Iterator from the given set of edges.
  *
  * @param object Vertex $vertex This vertex.
  * @param object Iterator $edgeIterator An edge iterator.
  */
 public function __construct(Vertex $vertex, Iterator $edgeIterator)
 {
     parent::__construct();
     $this->vertex = $vertex;
     $this->edgeIterator = $edgeIterator;
 }
Ejemplo n.º 15
0
 /**
  * Constructs a BinaryHeap_Iterator for the given queue.
  *
  * @param object BinaryHeap $heap A heap.
  */
 public function __construct(BinaryHeap $heap)
 {
     parent::__construct();
     $this->heap = $heap;
     $this->position = 1;
 }
Ejemplo n.º 16
0
 /**
  * Constructs a Deap_Iterator for the given queue.
  *
  * @param object Deap $heap A heap.
  */
 public function __construct(Deap $heap)
 {
     parent::__construct();
     $this->heap = $heap;
     $this->position = 0;
 }
Ejemplo n.º 17
0
 /**
  * Constructs a ScalesBalancingProblem_Node_SuccessorIterator
  * for the given node.
  *
  * @param object ScalesBalancingProblem_Node $node The node.
  */
 public function __construct(ScalesBalancingProblem_Node $node)
 {
     parent::__construct();
     $this->node = $node;
     $this->pan = 0;
 }
Ejemplo n.º 18
0
 /**
  * Constructs a StackAsArray_Iterator for the given stack.
  *
  * @param object StackAsArray $stack A stack.
  */
 public function __construct(StackAsArray $stack)
 {
     parent::__construct();
     $this->stack = $stack;
     $this->position = 0;
 }