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


PHP Stdlib\PriorityQueue類代碼示例

本文整理匯總了PHP中Zend\Stdlib\PriorityQueue的典型用法代碼示例。如果您正苦於以下問題:PHP PriorityQueue類的具體用法?PHP PriorityQueue怎麽用?PHP PriorityQueue使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了PriorityQueue類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: __clone

    /**
     * Make a deep clone of a fieldset
     *
     * @return void
     */
    public function __clone()
    {
        $items = $this->iterator->toArray(PriorityQueue::EXTR_BOTH);

        $this->byName    = array();
        $this->elements  = array();
        $this->fieldsets = array();
        $this->iterator  = new PriorityQueue();

        foreach ($items as $item) {
            $elementOrFieldset = clone $item['data'];
            $name = $elementOrFieldset->getName();

            $this->iterator->insert($elementOrFieldset, $item['priority']);
            $this->byName[$name] = $elementOrFieldset;

            if ($elementOrFieldset instanceof FieldsetInterface) {
                $this->fieldsets[$name] = $elementOrFieldset;
            } elseif ($elementOrFieldset instanceof ElementInterface) {
                $this->elements[$name] = $elementOrFieldset;
            }
        }

        // Also make a deep copy of the object in case it's used within a collection
        if (is_object($this->object)) {
            $this->object = clone $this->object;
        }
    }
開發者ID:Robert-Xie,項目名稱:php-framework-benchmark,代碼行數:33,代碼來源:Fieldset.php

示例2: addCollector

 /**
  * Adds a collector.
  *
  * @param  Collector\CollectorInterface $collector
  * @return self
  * @throws Exception\CollectorException
  */
 public function addCollector($collector)
 {
     if (!isset($this->collectors)) {
         $this->collectors = new PriorityQueue();
     }
     if ($collector instanceof Collector\CollectorInterface) {
         $this->collectors->insert($collector, $collector->getPriority());
     } else {
         $error = sprintf('%s must implement CollectorInterface.', get_class($collector));
         if ($this->strict === true) {
             throw new Exception\CollectorException($error);
         }
         $this->report->addError($error);
     }
     return $this;
 }
開發者ID:lafaiDev,項目名稱:suive_com,代碼行數:23,代碼來源:Profiler.php

示例3: __clone

 /**
  * Make a deep clone of a fieldset
  *
  * @return void
  */
 public function __clone()
 {
     $this->iterator = new PriorityQueue();
     foreach ($this->byName as $key => $value) {
         $value = clone $value;
         $this->byName[$key] = $value;
         $this->iterator->insert($value);
         if ($value instanceof FieldsetInterface) {
             $this->fieldsets[$key] = $value;
         } elseif ($value instanceof ElementInterface) {
             $this->elements[$key] = $value;
         }
     }
     // Also make a deep copy of the object in case it's used within a collection
     if (is_object($this->object)) {
         $this->object = clone $this->object;
     }
 }
開發者ID:navassouza,項目名稱:zf2,代碼行數:23,代碼來源:Fieldset.php

示例4: getValidators

 /**
  * Get all the validators
  *
  * @return array
  */
 public function getValidators()
 {
     return $this->validators->toArray(PriorityQueue::EXTR_DATA);
 }
開發者ID:MadCat34,項目名稱:zend-validator,代碼行數:9,代碼來源:ValidatorChain.php

示例5: createPriorityQueue

 /**
  * Create the priority queue
  * 
  * @return void
  */
 protected function createPriorityQueue()
 {
     $queue = new PriorityQueue();
     foreach ($this->prioritizedValues as $data) {
         // Do not include priority 0 in list
         if ($data['priority'] == 0) {
             continue;
         }
         // Hack to ensure priorities are correct; was not treating
         // fractional values correctly
         $queue->insert($data['media_type'], (double) $data['priority'] * 10);
     }
     $this->priorityQueue = $queue;
 }
開發者ID:ranxin1022,項目名稱:zf2,代碼行數:19,代碼來源:Accept.php

示例6: renderEvent

    protected function renderEvent($name, EventManagerInterface $eventManager, $profile)
    {
        $listeners = new PriorityQueue();
        foreach ($eventManager->getListeners($name) as $listener) {
            $info = $this->getListenerInfo($listener);
            $listeners->insert($info, $info['priority']);
        }
        $sharedEvents = $eventManager->getSharedManager();
        foreach ($eventManager->getIdentifiers() as $identifier) {
            $sharedListeners = $sharedEvents->getListeners($identifier, $name);
            if ($sharedListeners) {
                foreach ($sharedListeners as $sharedListener) {
                    $info = $this->getListenerInfo($sharedListener, $identifier);
                    $listeners->insert($info, $info['priority']);
                }
            }
        }
        $html = '';
        foreach ($listeners as $listener) {
            $html .= $this->renderListener($listener, $eventManager, $profile);
        }
        $html = <<<HDOC
<li><span class="name">{$this->escape($name)}</span>
    <ol class="listeners">{$html}</ol></li>
HDOC;
        return $html;
    }
開發者ID:sporkcode,項目名稱:sporktools,代碼行數:27,代碼來源:Events.php

示例7: handle

 /**
  * {@inheritdoc}
  */
 public function handle($code)
 {
     if ($this->handlers->isEmpty()) {
         throw new HandleException(self::class, 'There are no handlers defined.');
     }
     foreach ($this->handlers as $handler) {
         $handler->handle($code);
     }
 }
開發者ID:ReissClothing,項目名稱:Sylius,代碼行數:12,代碼來源:CompositeLocaleChangeHandler.php

示例8: addPath

 /**
  * {@inheritDoc}
  */
 public function addPath($path)
 {
     if (is_string($path)) {
         $this->paths->insert($this->normalizePath($path), 1);
         return;
     }
     if (!is_array($path) && !$path instanceof ArrayAccess) {
         throw new Exception\InvalidArgumentException(sprintf('Provided path must be an array or an instance of ArrayAccess, %s given', is_object($path) ? get_class($path) : gettype($path)));
     }
     if (isset($path['priority']) && isset($path['path'])) {
         $this->paths->insert($this->normalizePath($path['path']), $path['priority']);
         return;
     }
     throw new Exception\InvalidArgumentException('Provided array must contain both keys "priority" and "path"');
 }
開發者ID:sokac,項目名稱:AssetManager,代碼行數:18,代碼來源:PrioritizedPathsResolver.php

示例9: attach

 /**
  * Attach a filter to the chain
  *
  * @param  callable|FilterInterface $callback A Filter implementation or valid PHP callback
  * @param  int $priority Priority at which to enqueue filter; defaults to 1000 (higher executes earlier)
  * @throws Exception\InvalidArgumentException
  * @return FilterChain
  */
 public function attach($callback, $priority = self::DEFAULT_PRIORITY)
 {
     if (!is_callable($callback)) {
         if (!$callback instanceof FilterInterface) {
             throw new Exception\InvalidArgumentException(sprintf('Expected a valid PHP callback; received "%s"', is_object($callback) ? get_class($callback) : gettype($callback)));
         }
         $callback = array($callback, 'filter');
     }
     $this->filters->insert($callback, $priority);
     return $this;
 }
開發者ID:royaltyclubvp,項目名稱:BuzzyGals,代碼行數:19,代碼來源:FilterChain.php

示例10: addJS

 /**
  * Add a JS
  * @param string $path
  * @param int (optional) $priority
  * @return self
  */
 public function addJS($path, $priority = self::DEFAULT_ASSET_PRIORITY, $attributes = null)
 {
     $path = $this->calculateUrl($path, $this->jsPath);
     $tagAttributes = array();
     $tagAttributes['src'] = $path . '?v=' . $this->jsVersion;
     $tagAttributes['type'] = 'text/javascript';
     if (isset($attributes) && is_array($attributes)) {
         $tagAttributes = array_merge($tagAttributes, $attributes);
     }
     $tag = new Tag('script', $tagAttributes);
     $this->jsQueue->insert($tag, $priority);
     return $this;
 }
開發者ID:mrubiosan,項目名稱:asset,代碼行數:19,代碼來源:AssetManager.php

示例11: getThemeConfig

 /**
  * Get a theme configuration file
  * @param string $theme
  * @return array | null
  */
 public function getThemeConfig($theme)
 {
     $theme = $this->cleanThemeName($theme);
     $path_iterator = $this->themePaths->getIterator();
     $config = null;
     $n = $path_iterator->count();
     while (!$config && $n-- > 0) {
         $path = $path_iterator->extract();
         if (file_exists($path . $theme . '/config.php')) {
             $config = (include $path . $theme . '/config.php');
         }
     }
     return $config;
 }
開發者ID:ranjithinnergys,項目名稱:ZeTheme,代碼行數:19,代碼來源:Manager.php

示例12: getThemeConfig

 /**
  * Get a theme configuration file
  * @param string $theme
  * @return array | null
  */
 public function getThemeConfig($theme)
 {
     $theme = $this->cleanThemeName($theme);
     $path_iterator = $this->themePaths->getIterator();
     $config = null;
     $n = $path_iterator->count();
     while (!$config && $n-- > 0) {
         $path = $path_iterator->extract();
         $appConfig = $this->serviceManager->get('Configuration');
         if ($appConfig['ze_theme']['custom_theme_path'] === true) {
             $configFile = str_replace('{theme}', $theme, $path) . '/config.php';
         } else {
             $configFile = $path . $theme . '/config.php';
         }
         if (file_exists($configFile)) {
             $config = (include $configFile);
         }
     }
     return $config;
 }
開發者ID:bb-drummer,項目名稱:ZeTheme,代碼行數:25,代碼來源:Manager.php

示例13: addContext

 /**
  * @param CartContextInterface $cartContext
  * @param int $priority
  */
 public function addContext(CartContextInterface $cartContext, $priority = 0)
 {
     $this->cartContexts->insert($cartContext, $priority);
 }
開發者ID:ReissClothing,項目名稱:Sylius,代碼行數:8,代碼來源:CompositeCartContext.php

示例14: count

 /**
  * @return int
  */
 public function count()
 {
     return $this->iterator->count();
 }
開發者ID:slkxmail,項目名稱:App,代碼行數:7,代碼來源:Fieldset.php

示例15: attach

 /**
  * Attach a resolver
  *
  * @param  ResolverInterface $resolver
  * @param  int               $priority
  * @return self
  */
 public function attach(ResolverInterface $resolver, $priority = 1)
 {
     $this->queue->insert($resolver, $priority);
 }
開發者ID:CPDS,項目名稱:Sistema-de-controle-cpds,代碼行數:11,代碼來源:AggregateResolver.php


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