| 1 |
<?php if (! defined('ABSPATH')) exit; // Exit if accessed directly |
| 2 |
class HC3_Lib_PackedArray implements ArrayAccess |
| 3 |
{ |
| 4 |
private $container = ''; |
| 5 |
|
| 6 |
public function __construct( $size, $fill = 0 ) |
| 7 |
{ |
| 8 |
$this->container = str_repeat( chr($fill), $size ); |
| 9 |
} |
| 10 |
|
| 11 |
public function offsetSet( $i, $v ) |
| 12 |
{ |
| 13 |
$this->container[$i] = chr( $v & 0xff ); // store value $v into $x[$i] |
| 14 |
} |
| 15 |
|
| 16 |
public function offsetExists( $i ) |
| 17 |
{ |
| 18 |
return TRUE; |
| 19 |
// return isset($this->container[$offset]); |
| 20 |
} |
| 21 |
|
| 22 |
public function offsetUnset( $i ) |
| 23 |
{ |
| 24 |
// unset($this->container[$offset]); |
| 25 |
} |
| 26 |
|
| 27 |
public function offsetGet( $i ) |
| 28 |
{ |
| 29 |
$return = ord( $this->container[$i] ); // get value $v from $x[$i] |
| 30 |
return $return; |
| 31 |
} |
| 32 |
} |