1 | <?php |
||
12 | class PrimeSieveOfEratosthenes extends Combinatorics implements \Iterator, \Countable { |
||
13 | |||
14 | /** |
||
15 | * The minimum limit. |
||
16 | * |
||
17 | * @var int |
||
18 | */ |
||
19 | protected $min; |
||
20 | |||
21 | /** |
||
22 | * The maximum limit. |
||
23 | * |
||
24 | * @var int |
||
25 | */ |
||
26 | protected $max; |
||
27 | |||
28 | /** |
||
29 | * The key. |
||
30 | * |
||
31 | * @var int |
||
32 | */ |
||
33 | protected $key; |
||
34 | |||
35 | /** |
||
36 | * The primes array. |
||
37 | * |
||
38 | * @var array |
||
39 | */ |
||
40 | private $primes; |
||
41 | |||
42 | /** |
||
43 | * @var int |
||
44 | */ |
||
45 | private $last; |
||
46 | |||
47 | /** |
||
48 | * PrimeSieveOfEratosthenes constructor. |
||
49 | */ |
||
50 | public function __construct() { |
||
55 | |||
56 | /** |
||
57 | * |
||
58 | */ |
||
59 | private function generateNextPrime() { |
||
78 | |||
79 | /** |
||
80 | * {@inheritdoc} |
||
81 | */ |
||
82 | public function rewind() { |
||
85 | |||
86 | /** |
||
87 | * {@inheritdoc} |
||
88 | */ |
||
89 | public function current() { |
||
98 | |||
99 | /** |
||
100 | * {@inheritdoc} |
||
101 | */ |
||
102 | public function valid() { |
||
105 | |||
106 | /** |
||
107 | * {@inheritdoc} |
||
108 | */ |
||
109 | public function key() { |
||
112 | |||
113 | /** |
||
114 | * {@inheritdoc} |
||
115 | */ |
||
116 | public function next() { |
||
119 | |||
120 | /** |
||
121 | * Count elements of an object. |
||
122 | * |
||
123 | * @return int |
||
124 | * The number of element. |
||
125 | */ |
||
126 | public function count() { |
||
129 | |||
130 | /** |
||
131 | * Convert the iterator into an array. |
||
132 | * |
||
133 | * @return array |
||
134 | * The elements. |
||
135 | */ |
||
136 | public function toArray() { |
||
145 | |||
146 | /** |
||
147 | * Set the maximum limit. |
||
148 | * |
||
149 | * @param int $max |
||
150 | * The limit. |
||
151 | */ |
||
152 | public function setMaxLimit($max) { |
||
155 | |||
156 | /** |
||
157 | * Get the maximum limit. |
||
158 | * |
||
159 | * @return int |
||
160 | * The limit. |
||
161 | */ |
||
162 | public function getMaxLimit() { |
||
165 | |||
166 | /** |
||
167 | * Set the minimum limit. |
||
168 | * |
||
169 | * @param int $min |
||
170 | * The limit. |
||
171 | */ |
||
172 | public function setMinLimit($min) { |
||
175 | |||
176 | /** |
||
177 | * Get the minimum limit. |
||
178 | * |
||
179 | * @return int |
||
180 | * The limit. |
||
181 | */ |
||
182 | public function getMinLimit() { |
||
185 | |||
186 | /** |
||
187 | * Get a rough estimation of how many prime numbers there are. |
||
188 | * |
||
189 | * @return float |
||
190 | * The number of primes. |
||
191 | */ |
||
192 | public function pi() { |
||
195 | |||
196 | } |
||
197 |