/**
  * DoubledEndedPriorityQueue test method.
  *
  * @param object IPriorityQueue $pqueue The queue to test.
  */
 public static function test(IPriorityQueue $pqueue)
 {
     printf("AbstractDoubledEndedPriorityQueue test program.\n");
     AbstractPriorityQueue::test($pqueue);
     printf("%s\n", str($pqueue));
     $pqueue->enqueue(box(3));
     $pqueue->enqueue(box(1));
     $pqueue->enqueue(box(4));
     $pqueue->enqueue(box(1));
     $pqueue->enqueue(box(5));
     $pqueue->enqueue(box(9));
     $pqueue->enqueue(box(2));
     $pqueue->enqueue(box(6));
     $pqueue->enqueue(box(5));
     $pqueue->enqueue(box(4));
     printf("%s\n", str($pqueue));
     while (!$pqueue->isEmpty()) {
         $obj = $pqueue->dequeueMax();
         printf("%s\n", str($obj));
     }
 }
Example #2
0
 /**
  * Main program.
  *
  * @param array $args Command-line arguments.
  * @return integer Zero on success; non-zero on failure.
  */
 public static function main($args)
 {
     printf("BinomialQueue main program.\n");
     $status = 0;
     $pqueue = new BinomialQueue(5);
     AbstractPriorityQueue::test($pqueue);
     return $status;
 }
Example #3
0
 /**
  * Main program.
  *
  * @param array $args Command-line arguments.
  * @return integer Zero on success; non-zero on failure.
  */
 public static function main($args)
 {
     printf("LeftistHeap main program.\n");
     $status = 0;
     $bst = new LeftistHeap();
     AbstractPriorityQueue::test($bst);
     return $status;
 }
Example #4
0
 /**
  * Main program.
  *
  * @param array $args Command-line arguments.
  * @return integer Zero on success; non-zero on failure.
  */
 public static function main($args)
 {
     printf("BinaryHeap main program.\n");
     $status = 0;
     $queue = new BinaryHeap(57);
     AbstractPriorityQueue::test($queue);
     return $status;
 }
        $pqueue->enqueue(box(5));
        $pqueue->enqueue(box(4));
        printf("%s\n", str($pqueue));
        printf("Using reduce\n");
        $pqueue->reduce(create_function('$sum,$obj', 'printf("%s\\n", str($obj));'), '');
        printf("Using foreach\n");
        foreach ($pqueue as $obj) {
            printf("%s\n", str($obj));
        }
        printf("Dequeueing\n");
        while (!$pqueue->isEmpty()) {
            $obj = $pqueue->dequeueMin();
            printf("%s\n", str($obj));
        }
    }
    /**
     * Main program.
     *
     * @param array $args Command-line arguments.
     * @return integer Zero on success; non-zero on failure.
     */
    public static function main($args)
    {
        printf("AbstractPriorityQueue main program.\n");
        $status = 0;
        return $status;
    }
}
if (realpath($argv[0]) == realpath(__FILE__)) {
    exit(AbstractPriorityQueue::main(array_slice($argv, 1)));
}
 /**
  * Destructor.
  */
 public function __destruct()
 {
     parent::__destruct();
 }