printf("%s\n", str($list)); $position = $list->findPosition(box(3)); $position->insertAfter(box(5)); printf("%s\n", str($list)); $position->insertBefore(box(6)); printf("%s\n", str($list)); $position->withdraw(); printf("%s\n", str($list)); printf("Using foreach\n"); foreach ($list as $obj) { printf("%s\n", str($obj)); } printf("Using reduce\n"); $list->reduce(create_function('$sum,$obj', '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("AbstractOrderedList main program.\n"); $status = 0; return $status; } } if (realpath($argv[0]) == realpath(__FILE__)) { exit(AbstractOrderedList::main(array_slice($argv, 1))); }
/** * Main program. * * @param array $args Command-line arguments. * @return integer Zero on success; non-zero on failure. */ public static function main($args) { printf("OrderedListAsLinkedList main program.\n"); $status = 0; $list = new OrderedListAsLinkedList(5); AbstractOrderedList::test($list); return $status; }