当前位置: 首页>>代码示例>>PHP>>正文


PHP Map::apply方法代码示例

本文整理汇总了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;
 }
开发者ID:razorpay,项目名称:php-bloom-filter,代码行数:31,代码来源:Hash.php

示例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;
 }
开发者ID:RomanGorbatko,项目名称:rg.bloom.filter,代码行数:31,代码来源:Hash.php

示例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;
 }
开发者ID:razorpay,项目名称:php-bloom-filter,代码行数:46,代码来源:Bloom.php


注:本文中的Map::apply方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。