Source for file List.class.php
Documentation is available at List.class.php
* Gumbo Library Framework
* This library is being released under the terms of the New BSD License. A
* copy of the license is packaged with the software (LICENSE.txt). If no
* copy is found, a copy of the license template can be found at:
* http://www.opensource.org/licenses/bsd-license.php
* @copyright Copyright (c) 2007, iBayou, Michael Luster
* @license http://www.opensource.org/licenses/bsd-license.php New BSD License
* @author Michael Luster <mluster79@yahoo.com>
* @link http://sourceforge.net/projects/phpgumbo
* @copyright Copyright (c) 2007, iBayou, Michael Luster
* @license http://www.opensource.org/licenses/bsd-license.php New BSD License
* @author Michael Luster <mluster79@yahoo.com>
* @link http://sourceforge.net/projects/phpgumbo
gumbo_load ("Interface_List");
class Gumbo_List implements Gumbo_Interface_List, IteratorAggregate {
/** OVERLOADED METHODS **/
* Returns Data (wrapper to get())
* @param int|string$key for integers, use $list->{$num}
public function __get ($key) {
return $this->get ($key);
* Sets Data (wrapper to add())
public function __set ($key, $data) {
$this->add ($data, $key);
* Returns if key is set (wrapper to exists())
* Removes Data (wrapper to remove())
* Adds a new Item to the List
* @throws Gumbo_Exception
public function add ($data, $key=
null) {
$this->_list [$key] =
$data;
$e->setFunction (__METHOD__
);
* Removes an Item from the List
* @precondition exists($key)
* @throws Gumbo_Exception
public function remove ($key) {
unset
($this->_list [$key]);
$e->setFunction (__METHOD__
);
* Removes a value from the List
* @throws Gumbo_Exception
foreach ($this->getAll () as $key=>
$val) {
unset
($this->_list [$key]);
$e->setFunction (__METHOD__
);
public function reset () {
* @precondition exists($key)
* @throws Gumbo_Exception
public function get ($key) {
return $this->_list [$key];
$e->setFunction (__METHOD__
);
* Returns the entire List
* Returns the size of the list
public function size () {
* Returns if the Key exists, or if the List contains data
public function exists ($key=
null) {
if ($this->size () >
0) {
return isset
($this->_list [$key]);
$e->setFunction (__METHOD__
);