1 | <?php |
||
12 | class Cluster extends Point implements IteratorAggregate, Countable |
||
13 | { |
||
14 | /** |
||
15 | * @var Space |
||
16 | */ |
||
17 | protected $space; |
||
18 | |||
19 | /** |
||
20 | * @var SplObjectStorage|Point[] |
||
21 | */ |
||
22 | protected $points; |
||
23 | |||
24 | /** |
||
25 | * @param Space $space |
||
26 | * @param array $coordinates |
||
27 | */ |
||
28 | public function __construct(Space $space, array $coordinates) |
||
34 | |||
35 | /** |
||
36 | * @return array |
||
37 | */ |
||
38 | public function getPoints() |
||
47 | |||
48 | /** |
||
49 | * @return array |
||
50 | */ |
||
51 | public function toArray() |
||
58 | |||
59 | /** |
||
60 | * @param Point $point |
||
61 | * |
||
62 | * @return Point |
||
63 | * |
||
64 | * @throws \LogicException |
||
65 | */ |
||
66 | public function attach(Point $point) |
||
76 | |||
77 | /** |
||
78 | * @param Point $point |
||
79 | * |
||
80 | * @return Point |
||
81 | */ |
||
82 | public function detach(Point $point) |
||
88 | |||
89 | /** |
||
90 | * @param SplObjectStorage $points |
||
91 | */ |
||
92 | public function attachAll(SplObjectStorage $points) |
||
96 | |||
97 | /** |
||
98 | * @param SplObjectStorage $points |
||
99 | */ |
||
100 | public function detachAll(SplObjectStorage $points) |
||
104 | |||
105 | public function updateCentroid() |
||
123 | |||
124 | /** |
||
125 | * @return Point[]|SplObjectStorage |
||
126 | */ |
||
127 | public function getIterator() |
||
131 | |||
132 | /** |
||
133 | * @return mixed |
||
134 | */ |
||
135 | public function count() |
||
139 | |||
140 | /** |
||
141 | * @param array $newCoordinates |
||
142 | */ |
||
143 | public function setCoordinates(array $newCoordinates) |
||
147 | } |
||
148 |