martingold/linked-list 问题修复 & 功能扩展

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

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

martingold/linked-list

Composer 安装命令:

composer require martingold/linked-list

包简介

Library providing sorted linked list

README 文档

README

Library providing a standard sorted linked list implementation. The strict variant is offered for ensuring types in the list, making it suitable for non-typechecked codebases.

Installation

You can install this library using Composer:

composer require martingold/linked-list

Usage

require 'vendor/autoload.php';

use MartinGold\LinkedList\SortedLinkedList;

$list = new SortedLinkedList();

$list->insert(1);
$list->insert(3);
$list->insert(7);

var_dump($list->pop());

Following list operations are supported: insert, get, contains, shift, pop

In case runtime checking is required in a non-typesafe codebase, consider using the StrictSortedLinkedList implementation, which performs type checking at runtime.

Implementing custom sorting

The default implementation of sorting is done using spaceship operator. You may use your own implementation of Comparator in case you need to sort values depending on your needs.

use MartinGold\LinkedList\Comparator\Comparator;
use MartinGold\LinkedList\SortedLinkedList;

class Product
{
    public function __construct(
        public readonly float $quantity, 
    ){
        //
    }
}

/**
 * @implements Comparator<Product>
 */
class ProductComparator implements Comparator
{
    /**
     * Returns 1 when $a value is greater than $b.
     * Returns 0 when $a value is same as $b value.
     * Returns -1 when $a value is lesser than $b.
     */
    public function compare(Product $a, Product $b): int
    {
        return $a->quantity <=> $b->quantity;
    }
}

$productList = new SortedLinkedList(new ProductComparator());
$productList->insert(new Product(20));
$productList->insert(new Product(31));
$productList->insert(new Product(12));

foreach ($productList as $product) {
    echo $product->quantity;
}

// 12
// 20
// 31

Requirements

php >= 8.2

No other dependency required.

Contributing

Modify the library as needed and then run

composer qa

Please ensure that this script passes successfully before submitting a pull request. The script performs checks for adherence to coding standards and performs static analysis checks.

If you encounter code-style errors, you can automatically fix them by running:

composer csf

License

This library is open-source and available under the MIT License.

martingold/linked-list 适用场景与选型建议

martingold/linked-list 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 3 次下载、GitHub Stars 达 0, 最近一次更新时间为 2023 年 11 月 03 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 martingold/linked-list 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 martingold/linked-list 我们能提供哪些服务?
定制开发 / 二次开发

基于 martingold/linked-list 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-11-03