本文整理汇总了PHP中SplFixedArray::__construct方法的典型用法代码示例。如果您正苦于以下问题:PHP SplFixedArray::__construct方法的具体用法?PHP SplFixedArray::__construct怎么用?PHP SplFixedArray::__construct使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SplFixedArray
的用法示例。
在下文中一共展示了SplFixedArray::__construct方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
public function __construct(array $prototype, array $data = [])
{
parent::__construct(count($prototype));
$this->prototype = $prototype;
foreach ($data as $offset => $value) {
$this->offsetSet($offset, $value);
}
}
示例2: __construct
/**
* Constructor
*
* @param integer $size bloom-filter size (in bits)
* @param array $hashes hash algorithms to use
*/
public function __construct($size, array $hashes)
{
if ($size <= 0) {
throw new \UnexpectedValueException("Size cannot be negative or null");
}
if (empty($hashes)) {
throw new \UnexpectedValueException("You must provide at least one hash algorithm");
}
$hashAlgos = hash_algos();
foreach ($hashes as $hash) {
if (!in_array($hash, $hashAlgos)) {
throw new \UnexpectedValueException("Hash algorithm {$hash} is not supported");
}
}
$this->hashes = $hashes;
$this->size = $size;
$this->count = 0;
parent::__construct($size);
}
示例3: __construct
public function __construct($size, $convert = false)
{
parent::__construct($size);
$this->convert = (bool) $convert;
}
示例4: SplFixedArray
/* negative init value */
try {
$b = new SplFixedArray(-10);
} catch (Exception $e) {
var_dump($e->getMessage());
}
/* resize and negative value */
$b = new SplFixedArray();
try {
$b->setSize(-5);
} catch (Exception $e) {
var_dump($e->getMessage());
}
/* calling __construct() twice */
$c = new SplFixedArray(0);
var_dump($c->__construct());
/* fromArray() from empty array */
$d = new SplFixedArray();
$d->fromArray(array());
var_dump(count($a));
var_dump($a->count());
var_dump($a);
/* foreach by ref */
$e = new SplFixedArray(10);
$e[0] = 1;
$e[1] = 5;
$e[2] = 10;
try {
foreach ($e as $k => &$v) {
var_dump($v);
}