* * 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:----kWfeZWNbNbk08EvfCRMUdkbHTRYyKuNi+aDQ8UJVm569lmtnB7bvN8J2KpCuDfcnW5+s4BBRDtp6G2d22XJ6hB8eJjHqRI3ChrVE0HGyMGly0QN7piV573vZMI7bZuIyGtbYlPM4hXeXiQdPKWJikjuj2aDLXT88/Z56s0UL36khmA6WR1oIVXMrThaMaBPWSgccG1ScriInbF8naZ7gW6NN0ut0+HShxMI/hrYNpsJ1Sy9MrvSus3ssdjZX5fK8KvGA8HaLdk9boJCys1EQxHxupD5Wp3CmEr3xHHK7l90JSzM7V1O+dsEt1vG2ECPQ6zlpQPL9clr8uQ5Kv4dQXo6xA/pKjEHV71gW04nb7BeIOlxUyy5p4qClhVIdJT23CDMfQ431zkX2PmZoQw/2P7qaCirMef5h1MrnpxbW2x5trFtSzF57lR9HE9pv7yR1p5XiaSjFrYdRJ734ddgg6x2PWocaRtBGXqmJUsa4rtZmtz6yz1E9LrhBwAvEM2+/tkY5/HhCbnntOtS1aPxgviDU7+7dh5+Im3bQ5ZvBlBH1Om3f/9w4dId2MUyJ13PVx/GlhhNebbfdcfMvuC0hVd5WoM13nuweKkqB5pExXp7L9C8Zip6zsygWxSL6xvQnB0kYpkvNozPv2CQLo1DO0ZuMZJFoRZSlbJGJJ9s+vVg=----ATTACHMENT:----OTUyODY0MDAxMjkwMTA3MSA3MjM3ODgwNTEwMzMxNjIxIDE2ODYwODcxNTA2NjM5OTQ=