本文整理汇总了PHP中Map::apply方法的典型用法代码示例。如果您正苦于以下问题:PHP Map::apply方法的具体用法?PHP Map::apply怎么用?PHP Map::apply使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Map
的用法示例。
在下文中一共展示了Map::apply方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* Initialization
*
* @param array parameters
* @return object HashObject
*/
public function __construct($setup = null, $hashes = null)
{
/**
* Default parameters
*/
$params = array('strtolower' => true);
/**
* Applying income user parameters
*/
$params = Map::apply($this->map, $params, $setup);
$this->params = $params;
/**
* Creating unique seed
*/
$seeds = array();
if ($hashes) {
foreach ($hashes as $hash) {
$seeds = array_merge((array) $seeds, (array) $hash->seed);
}
}
do {
$hash = substr(str_shuffle("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), 0, 6);
} while (in_array($hash, $seeds));
$this->seed[] = $hash;
}
示例2: __construct
/**
* Hash constructor.
*
* @param null $setup
* @param null $hashes
*/
public function __construct($setup = null, $hashes = null)
{
/*
* Default parameters
*/
$params = array('strtolower' => true);
/*
* Applying income user parameters
*/
$params = Map::apply($this->map, $params, $setup);
$this->params = $params;
/*
* Creating unique seed
*/
$seeds = array();
if ($hashes) {
foreach ($hashes as $hash) {
$seeds = array_merge((array) $seeds, (array) $hash->seed);
}
}
do {
$hash = substr(str_shuffle(BloomFilter::alphabet), 0, 6);
} while (in_array($hash, $seeds));
$this->seed[] = $hash;
}
示例3: __construct
/**
* Class initiation
*
* @param array
* @return BloomObject
*/
public function __construct($setup = [])
{
/**
* Default parameters
*/
$params = array('entries_max' => 100, 'error_chance' => 0.001, 'counter' => false, 'hash' => array('strtolower' => true));
/**
* Applying income user parameters
*/
$params = Map::apply($this->map, $params, $setup);
/**
* Setting every parameters as properties
*/
foreach ($params as $key => $value) {
$this->{$key} = $value;
}
/**
* Calculating size of set using maximum number of entries and error chance
*/
if (!$this->set_size) {
$this->set_size = -round($this->entries_max * log($this->error_chance) / pow(log(2), 2));
}
/**
* Calculating number of hashes using maximum number of entries and set size
*/
if (!$this->hash_count) {
$this->hash_count = round($this->set_size * log(2) / $this->entries_max);
}
/**
* Setting up HashObjects to hashes property
*/
for ($i = 0; $i < $this->hash_count; $i++) {
$this->hashes[] = new Hash($params['hash'], $this->hashes);
}
/**
* Initiation set
*/
$this->set = str_repeat('0', $this->set_size);
return $this;
}