Richard Lynch wrote:
 > It still boggles my mind that you'd want to even *do* all this when 
you have
 > a built-in array type that can do everything you've done about a zillion
 > times faster...

1)I'm programing with php-oop for a few months. I need to know how to 
PHP work with references, class, ... .

2) I need data stucture like this:
method add($object): append object (anywhere, position is not important)
method remove($object): remove object
method item($index): get object at $index

with array??? There is a identical problem: deep recursion.
Object1 have references to object2 across Object3 which have ...  and 
vice versa.

Function uniqid() (or microtime()) is quite good, but is not a clear 
solution.

For example:

class Storage {
  $container = array();

  function add(&$object) {
   $objectID = microtime();
   $object->__uniqueObjectID__ = $objectID;
   $this->container[$objectID] = $object;
  }

  function remove(&$object) {
    unset($this->container[$object->__uniqueObjectID__];
  }

  function item($index) {
   $keys = array_keys($this->container);
   return $this->container[$keys[$index]]
  }
}

Grrr... to many problems:

1) adding variable to the third-party object
2) in remove() method: remove __uniqueObjectID__ varible from object or 
not???
3) if exists __uniqueObjectID__ variable replace with new value or keep 
current value???
4) Zend Engine 2.0 __clone() method:
   $obj = new MyObject();
   Storage->add($obj);
   $obj2 = $obj.__clone();
   Storage->remove($obj2); // Error: I want remove Obj2 not Obj1

and more...

-- 
Ondrej Ivanic
([EMAIL PROTECTED])


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to