Source for file List.class.php

Documentation is available at List.class.php

  1. <?php
  2. /**
  3.  * Gumbo Library Framework
  4.  *
  5.  * LICENSE
  6.  * This library is being released under the terms of the New BSD License.  A
  7.  * copy of the license is packaged with the software (LICENSE.txt).  If no
  8.  * copy is found, a copy of the license template can be found at:
  9.  * http://www.opensource.org/licenses/bsd-license.php
  10.  * 
  11.  * @category Gumbo
  12.  * @package List
  13.  * @copyright Copyright (c) 2007, iBayou, Michael Luster
  14.  * @license http://www.opensource.org/licenses/bsd-license.php New BSD License
  15.  * @author Michael Luster <mluster79@yahoo.com>
  16.  * @link http://sourceforge.net/projects/phpgumbo
  17.  * @version 0.0.1
  18.  */
  19.  
  20. /**
  21.  * List Interface
  22.  * 
  23.  * This is a typical set of common methods for accessing and manipulating a List
  24.  * of data.  This is the general Interface for accessing many types of Lists.
  25.  * Some classes will extend this implementation, or use the interface to define
  26.  * ways of accessing private information.
  27.  *
  28.  * @category Gumbo
  29.  * @package List
  30.  * @copyright Copyright (c) 2007, iBayou, Michael Luster
  31.  * @license http://www.opensource.org/licenses/bsd-license.php New BSD License
  32.  * @author Michael Luster <mluster79@yahoo.com>
  33.  * @link http://sourceforge.net/projects/phpgumbo
  34.  * @desc List Interface, responsible for holding a List of some data
  35.  * @version 0.0.1
  36.  */
  37.  
  38. interface Gumbo_Interface_List {
  39.     
  40.     /** OVERLOADED METHODS **/
  41.     /**
  42.      * Returns Data (wrapper to get())
  43.      * @param int|string$key for integers, use $list->{$num}
  44.      * @return mixed 
  45.      */
  46.     public function __get ($key);
  47.     
  48.     /**
  49.      * Sets Data (wrapper to add())
  50.      * @param int|string$key 
  51.      * @param mixed $data 
  52.      */
  53.     public function __set ($key$data);
  54.     
  55.     /**
  56.      * Returns if key is set (wrapper to exists())
  57.      * @param int|string$key 
  58.      * @return bool 
  59.      */
  60.     public function __isset ($key);
  61.     
  62.     /**
  63.      * Removes Data (wrapper to remove())
  64.      * @param int|string$key 
  65.      */
  66.     public function __unset ($key);
  67.     
  68.     
  69.     
  70.     /** ACTION METHODS **/
  71.     /**
  72.      * Adds a new Item to the List
  73.      * @param mixed $data 
  74.      * @param int|string$key 
  75.      */
  76.     public function add ($data$key=null);
  77.     
  78.     /**
  79.      * Removes an Item from the List
  80.      * @param int|string$key 
  81.      */
  82.     public function remove ($key);
  83.     
  84.     /**
  85.      * Removes a value from the List
  86.      * @param mixed $data 
  87.      */
  88.     public function removeValue ($data);
  89.     
  90.     /**
  91.      * Resets the List
  92.      * @postcondition !size()
  93.      */
  94.     public function reset ();
  95.     
  96.     
  97.     
  98.     /** ACCESSOR METHODS **/
  99.     /**
  100.      * Returns a single Value
  101.      * @param int|string$key 
  102.      * @return mixed 
  103.      */
  104.     public function get ($key);
  105.     
  106.     /**
  107.      * Returns the entire List
  108.      * @return array 
  109.      */
  110.     public function getAll ();
  111.     
  112.     /**
  113.      * Returns an array of the List Keys
  114.      * @return array 
  115.      */
  116.     public function keys ();
  117.     
  118.     /**
  119.      * Returns the size of the list
  120.      * @return int 
  121.      */
  122.     public function size ();
  123.     
  124.     /**
  125.      * Returns if the Key exists, or if the List contains data
  126.      * @param int|string$key 
  127.      * @return bool 
  128.      */
  129.     public function exists ($key=null);
  130.     
  131. }
  132.  
  133. ?>