data_structures
[ class tree: data_structures ] [ index: data_structures ] [ all elements ]

Source for file Vector.class.php

Documentation is available at Vector.class.php

  1. <?php
  2. /**
  3.  * For including this file you have to define the constant "CLASSPATH".
  4.  * Because every include in the framework depends on the CLASSPATH definition.
  5.  * The CLASSPATH means the relative path to the folder that contains the
  6.  * framework GilliGan.
  7.  *
  8.  * @package data_structures
  9.  */
  10. if!defined"CLASSPATH" ) )
  11. {
  12.   echo "<h3>You have to define the constant CLASSPATH!</h3>\r\n";
  13.   echo "Example: define( 'CLASSPATH', '../path/to/classes/' );\r\n";
  14.   exit();
  15. }
  16.  
  17. /**
  18.  *
  19.  */
  20. require_onceCLASSPATH."core/Arrays.class.php" );
  21.  
  22. /**
  23.  * @package data_structures
  24.  *
  25.  * @version   0.1.53
  26.  * @author    Daniel Plücken <daniel@debakel.net>
  27.  * @license   http://www.gnu.org/copyleft/lesser.html
  28.  *             GNU Lesser General Public License
  29.  * @copyright Copyright (C) 2004 Daniel Plücken <daniel@debakel.net>
  30.  *
  31.  *  This library is free software; you can redistribute it and/or
  32.  *  modify it under the terms of the GNU Lesser General Public
  33.  *  License as published by the Free Software Foundation; either
  34.  *  version 2.1 of the License.
  35.  *
  36.  *  This library is distributed in the hope that it will be useful,
  37.  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  38.  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  39.  *  GNU Lesser General Public License for more details.
  40.  *
  41.  *  You should have received a copy of the GNU Lesser General
  42.  *  Public License along with this library; if not, write to the
  43.  *  Free Software Foundation, Inc., 59 Temple Place, Suite 330,
  44.  *  Boston, MA 02111-1307 USA
  45.  */
  46. class Vector extends Arrays
  47. {
  48.    /**
  49.     * @var    array   $mixed 
  50.     * @access private
  51.     */
  52.    var $mixed;
  53.  
  54.  
  55.  
  56.    /**
  57.     * Constructor
  58.     *
  59.     * @version 1.0
  60.     * @since   0.1.0
  61.     * @author  Daniel Plücken <daniel@debakel.net>
  62.     * @access  public
  63.     * @param   array  $array* The array to manage.
  64.     * @return  void 
  65.     */
  66.    function Vector$arr array() )
  67.    {
  68.       ifis_array$arr ) )
  69.         $this->mixed = $arr;
  70.       else
  71.         die"Vector: The given value has to be an array." );
  72.    }
  73.  
  74.  
  75.  
  76.    /**
  77.     * Push one element onto the end of the intern array.
  78.     * 
  79.     * @version 1.0
  80.     * @since   0.1.53
  81.     * @author  Daniel Plücken <daniel@debakel.net>
  82.     * @access  public
  83.     * @return  void 
  84.     */
  85.    function add&$item )
  86.    $this->mixed[=$item}
  87.  
  88.  
  89.  
  90.    /**
  91.     * Sets the pointer to the value zero.
  92.     *
  93.     * @version 1.0
  94.     * @since   0.1.2
  95.     * @author  Daniel Plücken <daniel@debakel.net>
  96.     * @access  public
  97.     * @return  void 
  98.     */
  99.    function resetPointer()
  100.    reset$this->mixed )}
  101.  
  102.  
  103.  
  104.    /**
  105.     * Sets the pointer to the given value.
  106.     *
  107.     * @version 1.0
  108.     * @since   0.1.4
  109.     * @author  Daniel Plücken <daniel@debakel.net>
  110.     * @access  public
  111.     * @param   integer $int 
  112.     * @return  boolean 
  113.     */
  114.    function select$int )
  115.    {
  116.       if count$this->mixed <= )
  117.          return false;
  118.       
  119.       $int $int count$this->mixed );
  120.       reset$this->mixed );
  121.       for $i 0$i $int$i++ )
  122.           next$this->mixed );
  123.       
  124.       return true;
  125.    }
  126.  
  127.  
  128.  
  129.    /**
  130.     * Returns the previous entry of this one who is associated with the pointer
  131.     * and arises the pointer by one.
  132.     *
  133.     * @version 1.0
  134.     * @since   0.1.2
  135.     * @author  Daniel Plücken <daniel@debakel.net>
  136.     * @access  public
  137.     * @param   integer $int    Index of record to remove.
  138.     */
  139.    function next()
  140.    return next$this->mixed )}
  141.  
  142.  
  143.  
  144.    /**
  145.     * Returns the previous entry of this one who is associated with the pointer
  146.     * and abates the pointer by one.
  147.     *
  148.     * @version 1.0
  149.     * @since   0.1.2
  150.     * @author  Daniel Plücken <daniel@debakel.net>
  151.     * @access  public
  152.     * @return  mixed 
  153.     */
  154.    function previous()
  155.    return prev$this->mixed )}
  156.  
  157.  
  158.  
  159.    /**
  160.     * Returns the previous entry of this one who is associated with the pointer
  161.     * and abates the pointer by one.
  162.     * This method is an alias of the method previous.
  163.     *
  164.     * @version 1.0
  165.     * @since   0.1.2
  166.     * @author  Daniel Plücken <daniel@debakel.net>
  167.     * @access  public
  168.     * @return  mixed 
  169.     */
  170.    function prev()
  171.    return prev$this->mixed )}
  172.  
  173.  
  174.  
  175.    /**
  176.     * Removes the record at $int-index. All entrys behind the deleted record
  177.     * moving up by one position.
  178.     *
  179.     * @version 1.0
  180.     * @since   0.1.1
  181.     * @author  Daniel Plücken <daniel@debakel.net>
  182.     * @access  public
  183.     * @param   integer $int    Index of record to remove.
  184.     * @return  void 
  185.     */
  186.    function deleteRecordAt&$int )
  187.    array_splice$this->mixed$int)}
  188.  
  189.  
  190.  
  191.    /**
  192.     * Searches the first record of $value. If it is found it will be delete. All
  193.     * entrys behind the deleted record moving up by one position.
  194.     *
  195.     * @version 1.1
  196.     * @since   0.1.1
  197.     * @author  Daniel Plücken <daniel@debakel.net>
  198.     * @access  public
  199.     * @param   mixed $value  The value that should be searched.
  200.     * @return  void 
  201.     */
  202.    function deleteRecordValue&$value )
  203.    $this->mixed = parent::deleteRecordValue$value$this->mixed )}
  204.  
  205.  
  206.  
  207.    /**
  208.     * Returns the value of the current pointer position.
  209.     *
  210.     * @version 1.0
  211.     * @since   0.1.5
  212.     * @author  Daniel Pl&uuml;cken <daniel@debakel.net>
  213.     * @access  public
  214.     * @return  mixed 
  215.     */
  216.    function getCurrent()
  217.    return current$this->mixed )}
  218.  
  219.  
  220.  
  221.    /**
  222.     * Returns the position of the first record that matches the value
  223.     * of $mixedVal.
  224.     *
  225.     * @version 1.1
  226.     * @since   0.1.1
  227.     * @author  Daniel Plücken <daniel@debakel.net>
  228.     * @access  public
  229.     * @param   mixed  $mixedVal  The value that should be searched.
  230.     * @return  integer|false
  231.     */
  232.     function getFirstIndexOf&$mixedVal )
  233.     return parent::getFirstIndexOf$mixedVal$this->mixed )}
  234.  
  235.  
  236.  
  237.    /**
  238.     * Returns a random record of this vector.
  239.     *
  240.     * @version 1.0
  241.     * @since   0.1.1
  242.     * @author  Daniel Plücken <daniel@debakel.net>
  243.     * @access  public
  244.     * @return  array 
  245.     */
  246.    function getRandomRecord()
  247.    return parent::getRandomRecord$this->mixed )}
  248.  
  249.  
  250.  
  251.    /**
  252.     * Returns true if $this->mixed (the internal array that is managed by the
  253.     * class Vector) contains $record else it will return false.
  254.     * 
  255.     * @version 1.1
  256.     * @since   0.1.1
  257.     * @author  Daniel Plücken <daniel@debakel.net>
  258.     * @access  public
  259.     * @param   mixed $record  The value which should be compared with
  260.     *                          the records of the array.
  261.     * @return boolean 
  262.     */
  263.    function contains&$record )
  264.    return parent::contains$record )}
  265.  
  266.  
  267.  
  268.    /**
  269.     * Fills $record in $this->mixed only if $this->mixed does not already
  270.     * contains it.
  271.     *
  272.     * @version 1.0
  273.     * @since   0.1.1
  274.     * @author  Daniel Plücken <daniel@debakel.net>
  275.     * @access  public
  276.     * @param   mixed $record  The value which should be filled in the array.
  277.     * @return  void 
  278.     */
  279.    function uniqueInsert&$record )
  280.    parent::uniqueInsert$this->mixed$record )}
  281.  
  282.  
  283.  
  284.    /**
  285.     * Removes doubly occuring records in $this->mixed.
  286.     *
  287.     * @version 1.0
  288.     * @since   0.1.0
  289.     * @author  Daniel Plücken <daniel@debakel.net>
  290.     * @access  public
  291.     * @return  void 
  292.     */
  293.    function uniqueRecords()
  294.    $this->mixed = parent::uniqueRecords$this->mixed )}
  295. // End of class Vector
  296. ?>

Documentation generated on Thu, 05 Jun 2008 19:15:37 +0200 by phpDocumentor 1.4.1