@@ 81-93 (lines=13) @@ | ||
78 | return $new; |
|
79 | } |
|
80 | ||
81 | public function put($key, $value) |
|
82 | { |
|
83 | if ($this->keys->has($key)) { |
|
84 | throw new OverflowException('Value with such key already exists'); |
|
85 | } |
|
86 | ||
87 | if ($this->values->has($value)) { |
|
88 | throw new OverflowException('Key with such value already exists'); |
|
89 | } |
|
90 | ||
91 | $this->keys->put($key, $value); |
|
92 | $this->values->put($value, $key); |
|
93 | } |
|
94 | ||
95 | public function get($key) |
|
96 | { |
|
@@ 105-121 (lines=17) @@ | ||
102 | return $this->keys->has($key); |
|
103 | } |
|
104 | ||
105 | public function remove($key) |
|
106 | { |
|
107 | if ($this->keys->has($key)) { |
|
108 | throw new OutOfBoundsException('Value with such key not found'); |
|
109 | } |
|
110 | ||
111 | $value = $this->keys->remove($key); |
|
112 | ||
113 | if ($this->values->has($value)) { |
|
114 | // UNEXPECTED |
|
115 | throw new OutOfBoundsException('Key with such value not found'); |
|
116 | } |
|
117 | ||
118 | $this->values->remove($value); |
|
119 | ||
120 | return $value; |
|
121 | } |
|
122 | ||
123 | public function clear() |
|
124 | { |