@@ -46,8 +46,8 @@ discard block |
||
| 46 | 46 | if ($this->captureTopItems) { |
| 47 | 47 | if ($this->topCount < $this->captureTopItems || $this->topLast === null || $this->topLast < $value) { |
| 48 | 48 | ++$this->sampleId; |
| 49 | - $this->topMetas [$this->sampleId]= $meta; |
|
| 50 | - $this->topValues [$this->sampleId]= $value; |
|
| 49 | + $this->topMetas [$this->sampleId] = $meta; |
|
| 50 | + $this->topValues [$this->sampleId] = $value; |
|
| 51 | 51 | ++$this->topCount; |
| 52 | 52 | |
| 53 | 53 | if ($this->topCount > $this->captureTopItems) { |
@@ -65,8 +65,8 @@ discard block |
||
| 65 | 65 | if ($this->captureBottomItems) { |
| 66 | 66 | if ($this->bottomCount < $this->captureBottomItems || $this->bottomLast === null || $this->bottomLast > $value) { |
| 67 | 67 | ++$this->sampleId; |
| 68 | - $this->bottomMetas [$this->sampleId]= $meta; |
|
| 69 | - $this->bottomValues [$this->sampleId]= $value; |
|
| 68 | + $this->bottomMetas [$this->sampleId] = $meta; |
|
| 69 | + $this->bottomValues [$this->sampleId] = $value; |
|
| 70 | 70 | ++$this->bottomCount; |
| 71 | 71 | |
| 72 | 72 | if ($this->bottomCount > $this->captureBottomItems) { |
@@ -117,7 +117,7 @@ discard block |
||
| 117 | 117 | $left = 0; |
| 118 | 118 | $right = $this->totalBuckets - 1; |
| 119 | 119 | while ($right - $left > 0) { |
| 120 | - $position = (int)(($right + $left)/2); |
|
| 120 | + $position = (int)(($right + $left) / 2); |
|
| 121 | 121 | $item = $this->buckets[$position]; |
| 122 | 122 | if ($value < $item[0]) { |
| 123 | 123 | $right = $position - 1; |
@@ -222,7 +222,7 @@ discard block |
||
| 222 | 222 | public function getTopMetas() { |
| 223 | 223 | $result = array(); |
| 224 | 224 | foreach ($this->topValues as $sampleId => $tmp) { |
| 225 | - $result []= $this->topMetas[$sampleId]; |
|
| 225 | + $result [] = $this->topMetas[$sampleId]; |
|
| 226 | 226 | } |
| 227 | 227 | return $result; |
| 228 | 228 | } |
@@ -234,7 +234,7 @@ discard block |
||
| 234 | 234 | public function getBottomMetas() { |
| 235 | 235 | $result = array(); |
| 236 | 236 | foreach ($this->bottomValues as $sampleId => $tmp) { |
| 237 | - $result []= $this->bottomMetas[$sampleId]; |
|
| 237 | + $result [] = $this->bottomMetas[$sampleId]; |
|
| 238 | 238 | } |
| 239 | 239 | return $result; |
| 240 | 240 | } |
@@ -85,25 +85,20 @@ discard block |
||
| 85 | 85 | $this->buckets = array(array($value, $value, 1, $meta)); |
| 86 | 86 | $this->min = $this->max = $value; |
| 87 | 87 | $this->totalBuckets = 1; |
| 88 | - } |
|
| 89 | - else { |
|
| 88 | + } else { |
|
| 90 | 89 | if ($value < $this->min) { |
| 91 | 90 | $this->min = $value; |
| 92 | 91 | array_unshift($this->buckets, array($value, $value, 1, $meta)); |
| 93 | 92 | $this->totalBuckets++; |
| 94 | - } |
|
| 95 | - elseif ($value > $this->max) { |
|
| 93 | + } elseif ($value > $this->max) { |
|
| 96 | 94 | $this->max = $value; |
| 97 | 95 | array_push($this->buckets, array($value, $value, 1, $meta)); |
| 98 | 96 | $this->totalBuckets++; |
| 99 | - } |
|
| 100 | - elseif ($value === $this->min) { |
|
| 97 | + } elseif ($value === $this->min) { |
|
| 101 | 98 | ++$this->buckets[0][2]; |
| 102 | - } |
|
| 103 | - elseif ($value === $this->max) { |
|
| 99 | + } elseif ($value === $this->max) { |
|
| 104 | 100 | ++$this->buckets[$this->totalBuckets - 1][2]; |
| 105 | - } |
|
| 106 | - else { |
|
| 101 | + } else { |
|
| 107 | 102 | $this->insert($value, $meta); |
| 108 | 103 | } |
| 109 | 104 | } |
@@ -121,11 +116,9 @@ discard block |
||
| 121 | 116 | $item = $this->buckets[$position]; |
| 122 | 117 | if ($value < $item[0]) { |
| 123 | 118 | $right = $position - 1; |
| 124 | - } |
|
| 125 | - elseif ($value > $item[1]) { |
|
| 119 | + } elseif ($value > $item[1]) { |
|
| 126 | 120 | $left = $position + 1; |
| 127 | - } |
|
| 128 | - else { |
|
| 121 | + } else { |
|
| 129 | 122 | ++$this->buckets[$position][2]; |
| 130 | 123 | return; |
| 131 | 124 | } |
@@ -136,12 +129,10 @@ discard block |
||
| 136 | 129 | if ($value < $item[0]) { |
| 137 | 130 | array_splice($this->buckets, $position, 0, array(array($value, $value, 1, $meta))); |
| 138 | 131 | ++$this->totalBuckets; |
| 139 | - } |
|
| 140 | - elseif ($value > $item[1]) { |
|
| 132 | + } elseif ($value > $item[1]) { |
|
| 141 | 133 | array_splice($this->buckets, $position + 1, 0, array(array($value, $value, 1, $meta))); |
| 142 | 134 | ++$this->totalBuckets; |
| 143 | - } |
|
| 144 | - else { |
|
| 135 | + } else { |
|
| 145 | 136 | ++$this->buckets[$position][2]; |
| 146 | 137 | } |
| 147 | 138 | } |
@@ -157,8 +148,7 @@ discard block |
||
| 157 | 148 | $currentCount = $this->buckets[$position][2]; |
| 158 | 149 | if ($position === $this->totalBuckets - 1) { |
| 159 | 150 | $currentMergePosition = $position - 1; |
| 160 | - } |
|
| 161 | - else { |
|
| 151 | + } else { |
|
| 162 | 152 | $currentMergePosition = $this->buckets[$position + 1][2] < $this->buckets[$position - 1][2] |
| 163 | 153 | ? $position + 1 |
| 164 | 154 | : $position - 1; |
@@ -176,8 +166,7 @@ discard block |
||
| 176 | 166 | |
| 177 | 167 | if ($mergePosition > $minPosition) { |
| 178 | 168 | $this->buckets[$minPosition][1] = $this->buckets[$mergePosition][1]; |
| 179 | - } |
|
| 180 | - else { |
|
| 169 | + } else { |
|
| 181 | 170 | $this->buckets[$minPosition][0] = $this->buckets[$mergePosition][0]; |
| 182 | 171 | } |
| 183 | 172 | $this->buckets[$minPosition][2] += $this->buckets[$mergePosition][2]; |