Verzeichnisstruktur phpBB-3.2.0


Veröffentlicht
06.01.2017

So funktioniert es


Auf das letzte Element klicken. Dies geht jeweils ein Schritt zurück

Auf das Icon klicken, dies öffnet das Verzeichnis. Nochmal klicken schließt das Verzeichnis.
Auf den Verzeichnisnamen klicken, dies zeigt nur das Verzeichnis mit Inhalt an

      (Beispiel Datei-Icons)

Auf das Icon klicken um den Quellcode anzuzeigen

SplPriorityQueue.php

Zuletzt modifiziert: 09.10.2024, 12:55 - Dateigröße: 2.09 KiB


 01  <?php
 02  /**
 03   * Zend Framework (http://framework.zend.com/)
 04   *
 05   * @link      http://github.com/zendframework/zf2 for the canonical source repository
 06   * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
 07   * @license   http://framework.zend.com/license/new-bsd New BSD License
 08   */
 09   
 10  namespace Zend\Stdlib;
 11   
 12  use Serializable;
 13   
 14  /**
 15   * Serializable version of SplPriorityQueue
 16   *
 17   * Also, provides predictable heap order for datums added with the same priority
 18   * (i.e., they will be emitted in the same order they are enqueued).
 19   */
 20  class SplPriorityQueue extends \SplPriorityQueue implements Serializable
 21  {
 22      /**
 23       * @var int Seed used to ensure queue order for items of the same priority
 24       */
 25      protected $serial = PHP_INT_MAX;
 26   
 27      /**
 28       * Insert a value with a given priority
 29       *
 30       * Utilizes {@var $serial} to ensure that values of equal priority are
 31       * emitted in the same order in which they are inserted.
 32       *
 33       * @param  mixed $datum
 34       * @param  mixed $priority
 35       * @return void
 36       */
 37      public function insert($datum, $priority)
 38      {
 39          if (!is_array($priority)) {
 40              $priority = array($priority, $this->serial--);
 41          }
 42          parent::insert($datum, $priority);
 43      }
 44   
 45      /**
 46       * Serialize to an array
 47       *
 48       * Array will be priority => data pairs
 49       *
 50       * @return array
 51       */
 52      public function toArray()
 53      {
 54          $array = array();
 55          foreach (clone $this as $item) {
 56              $array[] = $item;
 57          }
 58          return $array;
 59      }
 60   
 61      /**
 62       * Serialize
 63       *
 64       * @return string
 65       */
 66      public function serialize()
 67      {
 68          $clone = clone $this;
 69          $clone->setExtractFlags(self::EXTR_BOTH);
 70   
 71          $data = array();
 72          foreach ($clone as $item) {
 73              $data[] = $item;
 74          }
 75   
 76          return serialize($data);
 77      }
 78   
 79      /**
 80       * Deserialize
 81       *
 82       * @param  string $data
 83       * @return void
 84       */
 85      public function unserialize($data)
 86      {
 87          foreach (unserialize($data) as $item) {
 88              $this->insert($item['data'], $item['priority']);
 89          }
 90      }
 91  }
 92