PHP Classes

File: Documentation

Recommend this page to a friend!
  Classes of Matías montes  >  Sorted List  >  Documentation  >  Download  
File: Documentation
Role: Documentation
Content type: text/plain
Description: Documentation on how to use the list
Class: Sorted List
Sort objects of a double linked list
Author: By
Last change:
Date: 17 years ago
Size: 887 bytes


Class file image Download
 * This list extends from the LinkList and it's characteristic is that it is
 * always sorted. For that to work it requires a comparison function when it
 * is created with the following format.
 * function compare_objects($obj_1, $obj_2){
 * 	if ($obj_1->getValue() >  $obj_2->getValue()) $result = BIGGER;
 * 	if ($obj_1->getValue() == $obj_2->getValue()) $result = EQUAL;
 * 	if ($obj_1->getValue() <  $obj_2->getValue()) $result = SMALLER;
 *	return $result;
 * }
 * The instantiation should be like this:
 * $myList = new SortedList("compare_objects");
 * It should work similarly for any type of data, including objects and arrays.
 * The only order supported in this version is increasing. But as it is a Double
 * Linked List, you can iterate through it in reverse order to get the elements
 * in decreasing order.
For more information send a message to info at phpclasses dot org.