當前位置: 首頁>>代碼示例>>PHP>>正文


PHP SplFixedArray::__construct方法代碼示例

本文整理匯總了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);
     }
 }
開發者ID:luijar,項目名稱:fp-php,代碼行數:8,代碼來源:Tuple.php

示例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);
 }
開發者ID:bdelespierre,項目名稱:bloom-filter.php,代碼行數:25,代碼來源:Filter.php

示例3: __construct

 public function __construct($size, $convert = false)
 {
     parent::__construct($size);
     $this->convert = (bool) $convert;
 }
開發者ID:ClearSkyTeam,項目名稱:ClearSky,代碼行數:5,代碼來源:SplFixedByteArray.php

示例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);
    }
開發者ID:badlamer,項目名稱:hhvm,代碼行數:31,代碼來源:fixedarray_021.php


注:本文中的SplFixedArray::__construct方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。