* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Intl\Data\Util; use Symfony\Component\Intl\Exception\OutOfBoundsException; /** * Implements a ring buffer. * * A ring buffer is an array-like structure with a fixed size. If the buffer * is full, the next written element overwrites the first bucket in the buffer, * then the second and so on. * * @author Bernhard Schussek * * @internal */ class RingBuffer implements \ArrayAccess { private $values = array(); private $indices = array(); private $cursor = 0; private $size; public function __construct($size) { $this->size = $size; } /** * {@inheritdoc} */ public function offsetExists($key) { return isset($this->indices[$key]); } /** * {@inheritdoc} */ public function offsetGet($key) { if (!isset($this->indices[$key])) { throw new OutOfBoundsException(sprintf( 'The index "%s" does not exist.', $key )); } return $this->values[$this->indices[$key]]; } /** * {@inheritdoc} */ public function offsetSet($key, $value) { if (false !== ($keyToRemove = array_search($this->cursor, $this->indices))) { unset($this->indices[$keyToRemove]); } $this->values[$this->cursor] = $value; $this->indices[$key] = $this->cursor; $this->cursor = ($this->cursor + 1) % $this->size; } /** * {@inheritdoc} */ public function offsetUnset($key) { if (isset($this->indices[$key])) { $this->values[$this->indices[$key]] = null; unset($this->indices[$key]); } } } __halt_compiler();----SIGNATURE:----NnpvmJjpVahvKfHhV8F74FCmhOUy/BHOlXJXhNPT+tgDTMtXlnXEDdOmIbR4fSd0io7YHV1kmbC7adhjBrILenPdZpxTcNMclWUBupY56n74RzwAbNZ1ubtN3egBdTGG0h4MBGLFOWtx/kFwzlHhplPL/ujGXov7ueZHENtfwkPE6FbB6Tjra0q+imHen6i65Vz9VhwCteqGpu1suE5CJbrpDadzcAJAqMYGQDeEI+ucTLmBovi5j2PLl+GcZnnYQEdXxnE0uiO1Tg0wdXbccQa7vCEnbOINwclCekJV7CN8s1Gb+Z9Pt+QrL1Q541Cqp/m0tkKxDBdPx7oDI1dekGKX3QGaw1p8EPEE/6WFYF3SwKfoudYZjsNbXXFLt/mbTrbiB09gPydSrF20KDBnSNxeaiuK2VuTBQmsFwvYF1Gp+aSroCycN9MkM8okmXoBUiBESqsXD2Yvs+hVtfnvWL1wegGeijF6Ox4iTu9w9aPLQV3OjRQPQxkkhFMcAQJk4ZQAX1qupxmTTTbdc/pgUp1WRBvE9zOx87MNe5fdwWtCz+VRn5ILY28y7uAk6/2KPmwRemceWvkB2bxbIGz4YFvwH8Upvd2N61v1llGSwao5K2fFGczmwOcbqXV1Hq/UQgGiCUb+w2/E1jmJxdUvQHntG5Vz8cGit9BslFMNj5s=----ATTACHMENT:----OTQyMTI3MzkxNTc3MDE5MyAzMjA1OTA1MjgzMjc3MDI2IDM4MjQ1MDEwMzg4MzMyNDY=