xcytek/linked_lists 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

xcytek/linked_lists

Composer 安装命令:

composer require xcytek/linked_lists

包简介

Linked Lists pattern

README 文档

README

=======

Linked Lists

Linked Lists implementation in PHP

Examples How To Use all the methods available:

Push nodes at the bottom

// Import the usage of the main classes
use Xcytek\LinkedList\LinkedList;
use Xcytek\LinkedList\Node;

// Push nodes at the end
$linkedList = new LinkedList();
foreach (range(1, 5) as $node) {
    $linkedList->push(new Node('Node #' . $node));
}
$linkedList->printList();
// Output
Linked list
"Node #1" -> "Node #2" -> "Node #3" -> "Node #4" -> "Node #5" -> null

Push nodes after specific position

// Push nodes after a certain position no matter if the node has other nodes pointed too.
$addAfterPosition = 2;
$nodeNinja1 = new Node('Node ninja 1');
$nodeNinja2 = new Node('Node ninja 2');
$nodeNinja3 = new Node('Node ninja 3');
$nodeNinja2->next = $nodeNinja3;
$nodeNinja1->next = $nodeNinja2;
$linkedList->pushAfterPosition($addAfterPosition, $nodeNinja1);
$linkedList->printList();
// Output
Linked list
"Node #1" -> "Node #2" -> "Node ninja 1" -> "Node ninja 2" -> "Node ninja 3" -> "Node #3" -> "Node #4" -> "Node #5" -> null

Push single node after a position

// Push single nodes after any position
$addAfterPosition = 4;
$linkedList->pushAfterPosition($addAfterPosition, new Node('New node ninja'));
$linkedList->printList();
// Output
Linked list
"Node #1" -> "Node #2" -> "Node ninja 1" -> "Node ninja 2" -> "New node ninja" -> "Node ninja 3" -> "Node #3" -> "Node #4" -> "Node #5" -> null

Push a node at the top of the list

// Push a node at the top of the list
$linkedList->pushAtTop(new Node('First ninja node'));
$linkedList->printList();
// Output
Linked list
"First ninja node" -> "Node #1" -> "Node #2" -> "Node ninja 1" -> "Node ninja 2" -> "New node ninja" -> "Node ninja 3" -> "Node #3" -> "Node #4" -> "Node #5" -> null

Delete a node given a position

// Remove single node given a position
$linkedList->deleteAtPosition(3);
$linkedList->printList();
// Output
Linked list
"First ninja node" -> "Node #1" -> "Node ninja 1" -> "Node ninja 2" -> "New node ninja" -> "Node ninja 3" -> "Node #3" -> "Node #4" -> "Node #5" -> null

Clear the entire list

// Clear the whole list
$linkedList->clear();
$linkedList->printList();
// Output
 [List Empty]

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-08-10

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固