Class OrderedList

Description

A generic queue of objects. It provides iterator functions next() and hasNext().

  • version: $Id: OrderedList.class.php,v 1.4 2007/09/04 20:25:54 adamfranco Exp $
  • license: GNU General Public License (GPL)
  • copyright: Copyright © 2005, Middlebury College

Located in /harmoni/core/utilities/OrderedList.class.php (line 14)


	
			
Variable Summary
mixed $_list
Method Summary
OrderedList OrderedList ()
void add (object $object, [string $key = ""])
void clear ()
object A copy (string $key)
boolean delete (string $key)
boolean exists (string $key)
integer getSize ()
boolean hasNext ()
boolean moveDown (string $key)
boolean moveUp (string $key)
object The next ()
boolean putBefore (string $source, string $destination)
object The retrieve (string $key)
boolean swap (string $key1, string $key2)
Variables
mixed $_list (line 17)
Methods
Constructor OrderedList (line 23)

Constructor. Create a new ordered list.

  • access: public
OrderedList OrderedList ()
add (line 33)

Add a referenced object to the end of the list and reset the internal counter.

  • access: public
void add (object $object, [string $key = ""])
  • object $object: The object to add to the queue.
  • string $key: the key by which the object is referenced in the list. By default the key will be the integer position in the list.
clear (line 237)

Clear the list.

  • access: public
void clear ()
copy (line 61)

Create a new instance of the object in the list with a given reference.

  • return: copy of an object with a given key.
  • access: public
object A copy (string $key)
  • string $key: The primary key of the object to get a copy of.
delete (line 75)

Delete an element by reference.

  • return: True on success, false on failure (no such key exists).
  • access: public
boolean delete (string $key)
  • string $key: The primary key of the object to delete.
exists (line 90)

Tell whether an element with a given reference exists in the list.

  • return: True if the reference exists, false otherwise.
  • access: public
boolean exists (string $key)
  • string $key: The primary key of the object to check.
getSize (line 228)

Get the size of the list.

  • return: The size of the list.
  • access: public
integer getSize ()
hasNext (line 215)

Tell whether there exists an object in the queue at the current position.

  • return: Whether there exists an object in the queue at the current position.
  • access: public
boolean hasNext ()
moveDown (line 155)

Move an element down (towards the end) the list.

  • return: True on success, false on failure (either the element is already at the bottom or it doesn't exist in the list).
  • access: public
boolean moveDown (string $key)
  • string $key: The primary key of the object to move.
moveUp (line 132)

Move an element up (towards the beginning) the list.

  • return: True on success, false on failure (either the element is already at the top or it doesn't exist in the list).
  • access: public
boolean moveUp (string $key)
  • string $key: The primary key of the object to move.
next (line 204)

Get the current element and increase the position by one.

  • return: reference to the object at the current position in the queue.
  • access: public
object The next ()
putBefore (line 177)

Move an element to the position that preceeds that of another element or the end of the list.

  • return: True on sucess false on falure (either the source or the destination keys do not exist).
  • access: public
boolean putBefore (string $source, string $destination)
  • string $source: The primary key of object to move.
  • string $destination: The primary key of object in front of which the source object is to be put. If $destination==="list_end" the source will be put at the end of the list, in the hope that there is no element whose key is "list_end,"
retrieve (line 48)

Retrieve an element by reference.

  • return: reference to the object with a given key. False if no object with such key exists.
  • access: public
object The retrieve (string $key)
  • string $key: The primary key of the object to retrieve.
swap (line 105)

Swap two elements in the list.

  • return: True on sucess, false on failure (either of the keys is non-existent in the list).
  • access: public
boolean swap (string $key1, string $key2)
  • string $key1: The primary key of first object to swap the position of.
  • string $key2: The primary key of second object to swap the position of.

Documentation generated on Wed, 19 Sep 2007 10:25:22 -0400 by phpDocumentor 1.3.0RC3