Splitter Test written. Doesn't pass.
[order_line_extra.git] / hincludes / lib / IntHash.class.php
1 <?php
2
3 class IntHash implements IteratorAggregate{
4         public function __construct() {
5                 if(!php_Boot::$skip_constructor) {
6                 $this->h = array();
7         }}
8         public function getIterator() {
9                 return $this->iterator();
10         }
11         public function toString() {
12                 $s = "{";
13                 $it = $this->keys();
14                 $»it = $it;
15                 while($»it->hasNext()) {
16                         $i = $»it->next();
17                         $s .= _hx_string_rec($i, "");
18                         $s .= " => ";
19                         $s .= Std::string($this->get($i));
20                         if($it->hasNext()) {
21                                 $s .= ", ";
22                         }
23                 }
24                 return $s . "}";
25         }
26         public function iterator() {
27                 return new _hx_array_iterator(array_values($this->h));
28         }
29         public function keys() {
30                 return new _hx_array_iterator(array_keys($this->h));
31         }
32         public function remove($key) {
33                 if(array_key_exists($key, $this->h)) {
34                         unset($this->h[$key]);
35                         return true;
36                 } else {
37                         return false;
38                 }
39         }
40         public function exists($key) {
41                 return array_key_exists($key, $this->h);
42         }
43         public function get($key) {
44                 if(array_key_exists($key, $this->h)) {
45                         return $this->h[$key];
46                 } else {
47                         return null;
48                 }
49         }
50         public function set($key, $value) {
51                 $this->h[$key] = $value;
52         }
53         public $h;
54         public function __call($m, $a) {
55                 if(isset($this->$m) && is_callable($this->$m))
56                         return call_user_func_array($this->$m, $a);
57                 else if(isset($this->»dynamics[$m]) && is_callable($this->»dynamics[$m]))
58                         return call_user_func_array($this->»dynamics[$m], $a);
59                 else if('toString' == $m)
60                         return $this->__toString();
61                 else
62                         throw new HException('Unable to call «'.$m.'»');
63         }
64         function __toString() { return $this->toString(); }
65 }