Advertisement
fruffl

Untitled

Apr 25th, 2012
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 6.18 KB | None | 0 0
  1. <?PHP
  2.     class StringArray Extends ArrayList implements System\iDataTypeString{ use System\tDataTypeStringDelegate; }
  3.     class DecimalArray Extends ArrayList implements System\iDataTypeDecimal{ use System\tDataTypeDecimalDelegate; }
  4.     $array = (new StringArray())->push('The')->push('quick')->push('brown')->push('fox')->toUpper();
  5.     var_dump($array);
  6. ?>
  7. object(localhost\illiFW\dev\StringArray)#2 (1) {
  8.   ["__value":protected]=>
  9.   object(ILLI\System\DataTypeStringArray)#4 (8) {
  10.     ["__offsets":"ILLI\System\DataTypeArray":private]=>
  11.     array(4) {
  12.       [0]=>
  13.       int(0)
  14.       [1]=>
  15.       int(1)
  16.       [2]=>
  17.       int(2)
  18.       [3]=>
  19.       int(3)
  20.     }
  21.     ["__indexes":"ILLI\System\DataTypeArray":private]=>
  22.     array(4) {
  23.       [0]=>
  24.       int(0)
  25.       [1]=>
  26.       int(1)
  27.       [2]=>
  28.       int(2)
  29.       [3]=>
  30.       int(3)
  31.     }
  32.     ["__itIndex":"ILLI\System\DataTypeArray":private]=>
  33.     int(4)
  34.     ["__lastOffsetUpdate":"ILLI\System\DataTypeArray":private]=>
  35.     NULL
  36.     ["__lastOffsetInsert":"ILLI\System\DataTypeArray":private]=>
  37.     NULL
  38.     ["__BITS":"ILLI\System\DataTypeArray":private]=>
  39.     object(ILLI\System\Bits)#3 (1) {
  40.       ["__bits":"ILLI\System\Bits":private]=>
  41.       int(0)
  42.     }
  43.     ["__value":protected]=>
  44.     array(4) {
  45.       [0]=>
  46.       object(ILLI\System\DataTypeString)#6 (5) {
  47.         ["__isMultibyte":"ILLI\System\DataTypeString":private]=>
  48.         bool(false)
  49.         ["__width":"ILLI\System\DataTypeString":private]=>
  50.         NULL
  51.         ["__length":"ILLI\System\DataTypeString":private]=>
  52.         NULL
  53.         ["__value":protected]=>
  54.         string(3) "THE"
  55.         ["__initialValue":"ILLI\System\DataType":private]=>
  56.         string(3) "The"
  57.       }
  58.       [1]=>
  59.       object(ILLI\System\DataTypeString)#7 (5) {
  60.         ["__isMultibyte":"ILLI\System\DataTypeString":private]=>
  61.         bool(false)
  62.         ["__width":"ILLI\System\DataTypeString":private]=>
  63.         NULL
  64.         ["__length":"ILLI\System\DataTypeString":private]=>
  65.         NULL
  66.         ["__value":protected]=>
  67.         string(5) "QUICK"
  68.         ["__initialValue":"ILLI\System\DataType":private]=>
  69.         string(5) "quick"
  70.       }
  71.       [2]=>
  72.       object(ILLI\System\DataTypeString)#8 (5) {
  73.         ["__isMultibyte":"ILLI\System\DataTypeString":private]=>
  74.         bool(false)
  75.         ["__width":"ILLI\System\DataTypeString":private]=>
  76.         NULL
  77.         ["__length":"ILLI\System\DataTypeString":private]=>
  78.         NULL
  79.         ["__value":protected]=>
  80.         string(5) "BROWN"
  81.         ["__initialValue":"ILLI\System\DataType":private]=>
  82.         string(5) "brown"
  83.       }
  84.       [3]=>
  85.       object(ILLI\System\DataTypeString)#9 (5) {
  86.         ["__isMultibyte":"ILLI\System\DataTypeString":private]=>
  87.         bool(false)
  88.         ["__width":"ILLI\System\DataTypeString":private]=>
  89.         NULL
  90.         ["__length":"ILLI\System\DataTypeString":private]=>
  91.         NULL
  92.         ["__value":protected]=>
  93.         string(3) "FOX"
  94.         ["__initialValue":"ILLI\System\DataType":private]=>
  95.         string(3) "fox"
  96.       }
  97.     }
  98.     ["__initialValue":"ILLI\System\DataType":private]=>
  99.     array(0) {
  100.     }
  101.   }
  102. }
  103.  
  104. <?PHP
  105.     /**
  106.      * ILLI
  107.      *
  108.      * @category   ILLI_System_Collection
  109.      * @package    ILLI
  110.      * @subpackage SystemCollection
  111.      * @link       http://illi.be
  112.      * @license    http://l.illi.be
  113.      * @copyright  ILLI Conference
  114.      */
  115.     NAMESPACE ILLI\System\Collection;
  116.     USE ILLI\System as System;
  117.  
  118.     /**
  119.      * ILLI System Collection ArrayList
  120.      *
  121.      * @category   ILLI_System_Collection
  122.      * @package    ILLI
  123.      * @subpackage SystemCollection
  124.      * @namespace  ILLI\System\Collection
  125.      * @link       http://illi.be
  126.      * @license    http://l.illi.be
  127.      * @copyright  ILLI Conference
  128.      * @since      2.0.0-1
  129.      * @version    2.0.0-1
  130.      * @abstract
  131.      */
  132.     CLASS ArrayList IMPLEMENTS System\iSerializable, System\iIterator
  133.     {
  134.         USE System\tSerializable;
  135.        
  136.         /**
  137.          * DataTypeArray prototype
  138.          */
  139.         protected $__value      = NULL;
  140.        
  141.         private static $__serializable  =
  142.                         [
  143.                             '__value'
  144.                         ];
  145.        
  146.         public function __construct($array = [], System\Bits $BITS = NULL)
  147.         {              
  148.             switch(TRUE):
  149.                 case ($this instanceOf System\iDataTypeChar):
  150.                     $this->__value = new System\DataTypeCharArray($array, $BITS);
  151.                     break;
  152.                 case ($this instanceOf System\iDataTypeDecimal):
  153.                     $this->__value = new System\DataTypeDecimalArray($array, $BITS);
  154.                     break;
  155.                 case ($this instanceOf System\iDataTypeString):
  156.                     $this->__value = new System\DataTypeStringArray($array, $BITS);
  157.                     break;
  158.                 default:
  159.                     $this->__value = new System\DataTypeArray($array, $BITS);
  160.             endswitch;
  161.             self::$__tSerializableProperties = self::$__serializable;
  162.         }
  163.        
  164.         public function clear()
  165.         {
  166.             $this->__value->clear();
  167.             return $this;
  168.         }
  169.        
  170.         public function pop()
  171.         {
  172.             return $this->__value->pop();
  173.         }
  174.        
  175.         public function push($value)
  176.         {
  177.             $this->__value->push($value);
  178.             return $this;
  179.         }
  180.        
  181.         public function current()
  182.         {
  183.             return $this->__value->current();
  184.         }
  185.        
  186.         public function next()
  187.         {
  188.             $this->__value->next();
  189.             return $this;
  190.         }
  191.        
  192.         public function key()
  193.         {
  194.             return $this->__value->key();
  195.         }
  196.        
  197.         public function valid()
  198.         {
  199.             return $this->__value->valid();
  200.         }
  201.        
  202.         public function rewind()
  203.         {
  204.             $this->__value->rewind();
  205.             return $this;
  206.         }
  207.        
  208.         public function peek()
  209.         {
  210.             return $this->__value->peekValueByOffset($this->__value->lastOffset());
  211.         }
  212.     }
  213.  
  214.     CLASS Queue EXTENDS ArrayList
  215.     {  
  216.         public function __construct($array = [])
  217.         {
  218.             parent::__construct($array, new System\Bits(System\DataTypeArray::IT_MODE_FIFO));
  219.         }
  220.        
  221.         public function peek()
  222.         {
  223.             return $this->__value->peekValueByOffset($this->__value->firstOffset());
  224.         }
  225.        
  226.        
  227.         public function pop()
  228.         {
  229.             return $this->__value->shift();
  230.         }
  231.     }
  232.  
  233.     CLASS Stack EXTENDS ArrayList
  234.     {  
  235.         public function __construct($array = [])
  236.         {
  237.             parent::__construct($array, new System\Bits(System\DataTypeArray::IT_MODE_LIFO));
  238.         }
  239.        
  240.         public function rewind()
  241.         {
  242.             $this->__value->setIteratorIndex($this->__value->lastIndex());
  243.             return $this;
  244.         }
  245.        
  246.         public function next()
  247.         {
  248.             $this->__value->prev();
  249.             return $this;
  250.         }
  251.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement