localheinz/data-structure

该软件包已被废弃,不再维护。没有建议的替代软件包。

提供数据结构实现。

dev-master 2019-12-07 08:15 UTC

This package is auto-updated.

Last update: 2019-12-07 08:16:41 UTC


README

CI Status codecov Latest Stable Version Total Downloads

此软件包提供数据结构的实现。

安装

运行

$ composer require localheinz/data-structure

数据结构

  • Localheinz\DataStructure\Queue
  • Localheinz\DataStructure\Stack

队列

use Localheinz\DataStructure\Queue;

$queue = new Queue();

$queue->isEmpty(); // true
$queue->isFull(); // false

$queue->enqueue('foo');
$queue->enqueue('bar');
$queue->isEmpty(); // false
$queue->isFull(); // false

$queue->dequeue(); // 'foo'
$queue->dequeue(); // 'bar'
$queue->isEmpty(); // true
$queue->isFull(); // false

$maxSize = 1;

$anotherQueue = new Queue($maxSize);

$anotherQueue->enqueue('foo');
$anotherQueue->isFull(); // true

use Localheinz\DataStructure\Stack;

$stack = new Stack();

$stack->isEmpty(); // true
$stack->isFull(); // false

$stack->push('foo');
$stack->push('bar');
$stack->isEmpty(); // false
$stack->isFull(); // false

$stack->peek(); // 'bar'

$stack->pop(); // 'bar'
$stack->pop(); // 'foo'
$stack->isEmpty(); // true
$stack->isFull(); // false

$maxSize = 1;

$anotherStack = new Stack($maxSize);

$anotherStack->push('foo');
$anotherStack->isFull(); // true

变更日志

请查看CHANGELOG.md

贡献

请查看CONTRIBUTING.md

行为准则

请查看CODE_OF_CONDUCT.md

许可证

本软件包使用MIT许可证授权。