承接 thomaslarsson/priorityqueue 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

thomaslarsson/priorityqueue

Composer 安装命令:

composer require thomaslarsson/priorityqueue

包简介

Ascending/descending PriorityQueues. Order maintained for nodes with equal priority on dequeue

README 文档

README

Ascending/descending PriorityQueues. Order maintained for nodes with equal priority on dequeue.

Install

You can install the package using Composer.

  1. Install composer.
  2. Add the following dependency to a composer.json and:
{
    "require": {
        "thomaslarsson/priorityqueue": "1.0.*"
    }
}

The package is now installed in your vendor directory.

Usage

// Require composer's autoload
require 'vendor/autoload.php';

// Optional: Alias/import the package's namespace
use ThomasLarsson\PriorityQueue\MinPriorityQueue as MinPriorityQueue,
    ThomasLarsson\PriorityQueue\MaxPriorityQueue as MaxPriorityQueue;

// Create a ascending queue (Use the package's namespace unless you aliased it)
$ascendingQueue = new MinPriorityQueue();

// ... OR a descending queue.
$descendingQueue = new MaxPriorityQueue(); // A decending queue

// Create some data sorted descending (Just to illustrate that it's working)
$ascendingQueue->insert(4, 0);
$ascendingQueue->insert(3, 0);
$ascendingQueue->insert(2, 0);
$ascendingQueue->insert(1, 0);
$ascendingQueue->insert(0, 0);

// Display the sorted result
foreach ( $ascendingQueue as $value )
{
    echo $value . "\n";
}

Fixes equal priority sorting bug

ThomasLarsson/PriorityQueue is built on top of SplPriorityQueue. This implementation fixes problems when two or more nodes share a similar priority. The standard SPL-implementation will dequeue equal priority nodes in no particular (random) order, as noted in the manual.

SPLPriorityQueue::compare()

Note: Multiple elements with the same priority will get dequeued in no particular order.

统计信息

  • 总下载量: 426
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2013-09-30

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固