Skip to content

Instantly share code, notes, and snippets.

@grahamc
Forked from tchrist/gist:1328966
Created October 31, 2011 21:10
Show Gist options
  • Save grahamc/1328968 to your computer and use it in GitHub Desktop.
Save grahamc/1328968 to your computer and use it in GitHub Desktop.
LL - iterator

Implement a linked list and supporting classes:

Class: LinkedList

Member Variables

  • Node $root

Methods

  • getElements() Returns an array of all elements in the linked list
  • insert($val) Insert a value at the current position in the linked list
  • delete() Delete the current value in the linked list

Class: Node

Member Variables

  • Node $next
  • Node $prev
  • mixed $val

Methods

  • next() Returns the next node in the list
  • prev() Returns the previous value in the list

All functions should be unit tested using PHPUnit and the code should be provided with a suite of executable tests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment