定制 gedex/container 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

gedex/container

Composer 安装命令:

composer require gedex/container

包简介

Library for various data structure and its operations

README 文档

README

Build Status Coverage Status

Library for various data structure and its operations.

Examples

Doubly Linked List

use Gedex\Container;

$ll = new Container\DoublyLinkedList();
$e1 = $ll->pushFront(1);
$e2 = $ll->pushFront(2);
$e3 = $ll->pushBack('e3');

$e4 = $ll->insertBefore('el before e3', $e3);
$e5 = $ll->insertAfter('el after e3', $e3);
printList($ll); // --> (2) --> (1) --> (el before e3) --> (e3) --> (el after e4)

printf("Remove element (%s)\n", $e3->getValue());
$ll->remove($e3);

printList($ll); // --> (2) --> (1) --> (el before e3) --> (el after e4)

function printList($ll) {
    $el = $ll->getFront();
    while (!is_null($el)) {
        printf('--> (%s) ', $el->getValue());
        $el = $el->getNext();
    }
    printf("\n");
}

Circular List

use Gedex\Container;

$cl = new Container\CircularList(5);
for ($i = 1; $i <= $cl->len(); $i++) {
    $el = $cl->cursor()->setValue($i);
    $cl->next();
}

$sum = 0;
$cl->walk(function($value) use(&$sum) {
    printf('--> (%s) ', $value);
    $sum += $value;
});
printf("\n");
printf("%d\n", $sum); // 15

License

MIT License - See LICENSE file.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-08-03