Ejemplo n.º 1
0
 /**
  * Accepts the specified visitor and makes it visit all the objects
  * in this deap.
  *
  * @param object IVisitor $visitor The visitor to accept.
  */
 public function accept(IVisitor $visitor)
 {
     for ($i = 2; $i < $this->count + 2; ++$i) {
         if ($visitor->isDone()) {
             return;
         }
         $visitor->visit($this->array[$i]);
     }
 }
Ejemplo n.º 2
0
 /**
  * Causes a visitor to visit the vertices of this graph
  * in topological order.
  * This method takes a visitor and,
  * as long as the IsDone method of that visitor returns false,
  * this method invokes the Visit method of the visitor
  * for each vertex in the graph.
  * The order in which the vertices are visited
  * is given by a topological sort of the vertices.
  *
  * @param object IVisitor $visitor The visitor to accept.
  */
 public function topologicalOrderTraversal(IVisitor $visitor)
 {
     $inDegree = new BasicArray($this->numberOfVertices);
     for ($v = 0; $v < $this->numberOfVertices; ++$v) {
         $inDegree[$v] = 0;
     }
     foreach ($this->getEdges() as $edge) {
         $to = $edge->getV1();
         $inDegree[$to->getNumber()] += 1;
     }
     $queue = new QueueAsLinkedList();
     for ($v = 0; $v < $this->numberOfVertices; ++$v) {
         if ($inDegree[$v] == 0) {
             $queue->enqueue($this->vertex[$v]);
         }
     }
     while (!$queue->isEmpty() && !$visitor->isDone()) {
         $v = $queue->dequeue();
         $visitor->visit($v);
         foreach ($v->getSuccessors() as $to) {
             $inDegree[$to->getNumber()] -= 1;
             if ($inDegree[$to->getNumber()] == 0) {
                 $queue->enqueue($to);
             }
         }
     }
 }
Ejemplo n.º 3
0
 /**
  *
  *
  * @param IVisitor $visitor
  * @param mixed $arg
  * @param boolean $bool
  * @return mixed
  */
 public function accept(IVisitor $visitor, $arg, $bool)
 {
     return $visitor->hyperTextMarkup($this, $arg, $bool);
 }
Ejemplo n.º 4
0
 public function accept(IVisitor $visitor, stdClass $obj)
 {
     return $visitor->visit($this, $obj);
 }
Ejemplo n.º 5
0
 public function accept(IVisitor $visitor)
 {
     $visitor->visit($this);
 }
Ejemplo n.º 6
0
 /**
  *
  *
  * @param IVisitor $visitor
  * @param mixed $arg
  * @param boolean $bool
  * @return mixed
  */
 public function accept(IVisitor $visitor, $arg, $bool)
 {
     return $visitor->markdown($this, $arg, $bool);
 }
Ejemplo n.º 7
0
 /**
  * Calls the visit method of the given visitor
  * for each object in this container.
  *
  * @param object IVisitor $visitor A visitor.
  */
 public function accept(IVisitor $visitor)
 {
     foreach ($this as $obj) {
         if ($visitor->isDone()) {
             break;
         }
         $visitor->visit($obj);
     }
 }
Ejemplo n.º 8
0
 /**
  *
  *
  * @param IVisitor $visitor
  * @param $arg
  * @return mixed
  */
 public function accept(IVisitor $visitor, $arg)
 {
     $index = !isset($this->config['reverse']) || $this->config['reverse'] ? 1 : 0;
     return $visitor->carousel($this, $index);
 }
Ejemplo n.º 9
0
 /**
  *
  *
  * @param IVisitor $visitor
  * @param $arg
  * @return mixed
  */
 public function accept(IVisitor $visitor, $arg)
 {
     return $visitor->composite($this, $arg);
 }
 /**
  *
  *
  * @param IVisitor $visitor
  * @param $arg
  * @return mixed
  */
 public function accept(IVisitor $visitor, $arg)
 {
     return $visitor->hypertextPreprocessor($this, $arg);
 }
Ejemplo n.º 11
0
 /**
  *
  *
  * @param IVisitor $visitor
  * @param $arg
  * @return mixed
  */
 public function accept(IVisitor $visitor, $arg)
 {
     return $visitor->link($this, $arg);
 }
Ejemplo n.º 12
0
 /**
  *
  *
  * @param IVisitor $visitor
  * @param mixed $arg
  * @param boolean $bool
  * @return mixed
  */
 public function accept(IVisitor $visitor, $arg, $bool)
 {
     $index = !isset($this->config['reverse']) || $this->config['reverse'] ? 1 : 0;
     return $visitor->photoSwipe($this, $index, $bool);
 }
Ejemplo n.º 13
0
 /**
  *
  *
  * @param IVisitor $visitor
  * @param $arg
  * @return mixed
  */
 public function accept(IVisitor $visitor, $arg)
 {
     return $visitor->container($this, $arg);
 }
Ejemplo n.º 14
0
 /**
  * Accepts a visitor and makes it visit the elements of this partition.
  *
  * @param object IVisitor $visitor The visitor to accept.
  */
 public function accept(IVisitor $visitor)
 {
     for ($item = 0; $item < $this->universeSize; ++$item) {
         if ($visitor->isDone()) {
             return;
         }
         $visitor->visit($this->array[$i]);
     }
 }
Ejemplo n.º 15
0
 /**
  * Causes a visitor to visit the nodes of this tree
  * in breadth-first traversal order starting from this node.
  * This method invokes the <code>visit</code> method of the visitor
  * for each node in this tree.
  * Uses a queue to keep track of the nodes to be visited.
  * The traversal continues as long as the <code>isDone</code>
  * method of the visitor returns false.
  *
  * @param object IVisitor $visitor The visitor to accept.
  */
 public function breadthFirstTraversal(IVisitor $visitor)
 {
     $queue = new QueueAsLinkedList();
     if (!$this->isEmpty()) {
         $queue->enqueue($this);
     }
     while (!$queue->isEmpty()) {
         $head = $queue->dequeue();
         for ($i = 1; $i <= $head->getDegree() - 1; ++$i) {
             $visitor->visit($head->getKeyN($i));
         }
         for ($i = 0; $i <= $head->getDegree() - 1; ++$i) {
             $child = $head->getSubtree($i);
             if (!$child->isEmpty()) {
                 $queue->enqueue($child);
             }
         }
     }
 }
Ejemplo n.º 16
0
 /**
  *
  *
  * @param IVisitor $visitor
  * @param $arg
  * @return mixed
  */
 public function accept(IVisitor $visitor, $arg)
 {
     return $visitor->collection($this, $arg);
 }
Ejemplo n.º 17
0
 /**
  *
  *
  * @param IVisitor $visitor
  * @param mixed $arg
  * @param boolean $bool
  * @return mixed
  */
 public function accept(IVisitor $visitor, $arg, $bool)
 {
     return $visitor->remote($this, $arg, $bool);
 }
Ejemplo n.º 18
0
 /**
  *
  *
  * @param IVisitor $visitor
  * @param mixed $arg
  * @param boolean $bool
  * @return mixed
  */
 public function accept(IVisitor $visitor, $arg, $bool)
 {
     return $visitor->typedContainer($this, $arg, $bool);
 }