@@ 149-162 (lines=14) @@ | ||
146 | * |
|
147 | * @return Set |
|
148 | */ |
|
149 | final public function union(self $set) |
|
150 | { |
|
151 | $bit = $this->bit; |
|
152 | foreach (func_get_args() as $arg) { |
|
153 | self::validateType($arg); |
|
154 | ||
155 | $bit |= $arg->bit; |
|
156 | } |
|
157 | ||
158 | $clone = new static(); |
|
159 | $clone->bit = $bit; |
|
160 | ||
161 | return $clone; |
|
162 | } |
|
163 | ||
164 | /** |
|
165 | * Produce a new set with enum common to both this and other (this & other). |
|
@@ 171-184 (lines=14) @@ | ||
168 | * |
|
169 | * @return Set |
|
170 | */ |
|
171 | final public function intersect(self $set) |
|
172 | { |
|
173 | $bit = $this->bit; |
|
174 | foreach (func_get_args() as $arg) { |
|
175 | self::validateType($arg); |
|
176 | ||
177 | $bit &= $arg->bit; |
|
178 | } |
|
179 | ||
180 | $clone = new static(); |
|
181 | $clone->bit = $bit; |
|
182 | ||
183 | return $clone; |
|
184 | } |
|
185 | ||
186 | /** |
|
187 | * Produce a new set with enum in this but not in other (this - other). |
|
@@ 193-206 (lines=14) @@ | ||
190 | * |
|
191 | * @return Set |
|
192 | */ |
|
193 | final public function diff(self $set) |
|
194 | { |
|
195 | $bit = 0; |
|
196 | foreach (func_get_args() as $arg) { |
|
197 | self::validateType($arg); |
|
198 | ||
199 | $bit |= $arg->bit; |
|
200 | } |
|
201 | ||
202 | $clone = new static(); |
|
203 | $clone->bit = $this->bit & ~$bit; |
|
204 | ||
205 | return $clone; |
|
206 | } |
|
207 | ||
208 | /** |
|
209 | * Produce a new set with enum in either this and other but not in both (this ^ (other | other)). |
|
@@ 215-228 (lines=14) @@ | ||
212 | * |
|
213 | * @return Set |
|
214 | */ |
|
215 | final public function symDiff(self $set) |
|
216 | { |
|
217 | $bit = 0; |
|
218 | foreach (func_get_args() as $arg) { |
|
219 | self::validateType($arg); |
|
220 | ||
221 | $bit |= $arg->bit; |
|
222 | } |
|
223 | ||
224 | $clone = new static(); |
|
225 | $clone->bit = $this->bit ^ $bit; |
|
226 | ||
227 | return $clone; |
|
228 | } |
|
229 | ||
230 | /** |
|
231 | * Get choices for checkbox group. |