예제 #1
0
 /**
  * Main program.
  *
  * @param array $args Command-line arguments.
  * @return integer Zero on succes; non-zero on failure.
  */
 public static function main($args)
 {
     printf("Demonstration program number 6.\n");
     $status = 0;
     BinaryHeap::main($args);
     LeftistHeap::main($args);
     BinomialQueue::main($args);
     Deap::main($args);
     return $status;
 }
예제 #2
0
 /**
  * Dequeues and returns the "smallest" object in this binomial queue.
  * The smallest object in this binomial queue is the object
  * that is less than or equal to all other objects in this
  * binomial queue.
  *
  * @return object IComparable The "smallest" object in this binomial queue.
  */
 public function dequeueMin()
 {
     if ($this->count == 0) {
         throw new ContainerEmptyException();
     }
     $minTree = $this->findMinTree();
     $this->removeTree($minTree);
     $queue = new BinomialQueue();
     while ($minTree->getDegree() > 0) {
         $child = $minTree->getSubtree(0);
         $minTree->detachSubtree($child);
         $queue->addTree($child);
     }
     $this->merge($queue);
     return $minTree->getKey();
 }