_n = $n; $this->_k = $k; return; } /** * Get current γ. * * @return array */ public function current() { return $this->_current; } /** * Get current α. * * @return int */ public function key() { return $this->_key; } /** * Compute γ_{α + 1}. * * @return void */ public function next() { return; } /** * Rewind iterator. * * @return void */ public function rewind() { $this->_current = []; $this->_tmp = null; $this->_i = 0; $this->_o = 0 === $this->_n ? [0] : array_fill(0, $this->_n, 0); $this->_o[0] = $this->_k; $this->_last = false; return; } /** * Compute γ_α. * * @return bool */ public function valid() { if (true === $this->_last) { return false; } if (0 === $this->_n) { return false; } if ($this->_k == $this->_o[$this->_i = $this->_n - 1]) { $this->_last = true; $this->_current = $this->_o; ++$this->_key; return true; } $this->_current = $this->_o; ++$this->_key; $this->_tmp = $this->_o[$this->_i]; $this->_o[$this->_i] = 0; while ($this->_o[$this->_i] == 0) { --$this->_i; } --$this->_o[$this->_i]; $this->_o[$this->_i + 1] = $this->_tmp + 1; return true; } }