本文整理匯總了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);
}