1 | <?php |
||
13 | class FiniteGroup extends Combinatorics implements IteratorInterface |
||
14 | { |
||
15 | /** |
||
16 | * The group size. |
||
17 | * |
||
18 | * @var int |
||
19 | */ |
||
20 | protected $size; |
||
21 | |||
22 | /** |
||
23 | * The group. |
||
24 | * |
||
25 | * @var int[] |
||
26 | */ |
||
27 | protected $group; |
||
28 | |||
29 | /** |
||
30 | * The key. |
||
31 | * |
||
32 | * @var int |
||
33 | */ |
||
34 | protected $key; |
||
35 | |||
36 | /** |
||
37 | * Combinatorics constructor. |
||
38 | */ |
||
39 | 2 | public function __construct() |
|
43 | |||
44 | /** |
||
45 | * {@inheritdoc} |
||
46 | */ |
||
47 | 2 | public function current() |
|
51 | |||
52 | /** |
||
53 | * {@inheritdoc} |
||
54 | */ |
||
55 | 2 | public function next() |
|
60 | |||
61 | /** |
||
62 | * {@inheritdoc} |
||
63 | */ |
||
64 | 2 | public function valid() |
|
68 | |||
69 | /** |
||
70 | * {@inheritdoc} |
||
71 | */ |
||
72 | 2 | public function rewind() |
|
76 | |||
77 | /** |
||
78 | * Count elements of an object. |
||
79 | * |
||
80 | * @return int |
||
81 | * The number of element |
||
82 | */ |
||
83 | 2 | public function count() |
|
87 | |||
88 | /** |
||
89 | * Set the group size. |
||
90 | * |
||
91 | * @param int $size |
||
92 | * The size |
||
93 | */ |
||
94 | 2 | public function setSize($size) |
|
99 | |||
100 | /** |
||
101 | * Get the group size. |
||
102 | * |
||
103 | * @return int |
||
104 | * The size |
||
105 | */ |
||
106 | 2 | public function getSize() |
|
110 | |||
111 | /** |
||
112 | * Get the order. |
||
113 | * |
||
114 | * @param int $generator |
||
115 | * The generator |
||
116 | * |
||
117 | * @return int |
||
118 | * The order |
||
119 | */ |
||
120 | public function order($generator) |
||
131 | |||
132 | /** |
||
133 | * Clean out the group from unwanted values. |
||
134 | */ |
||
135 | 2 | private function computeGroup() |
|
145 | |||
146 | /** |
||
147 | * Get the greater common divisor between two numbers. |
||
148 | * |
||
149 | * @param int $a |
||
150 | * The first number |
||
151 | * @param int $b |
||
152 | * The second number |
||
153 | * |
||
154 | * @return int |
||
155 | * The greater common divisor between $a and $b |
||
156 | */ |
||
157 | 2 | private function gcd($a, $b) |
|
161 | } |
||
162 |