pccomponentes/lexicographic-ranking

字典序计算器,用于持久化有序列表。

v0.0.5 2021-01-28 09:33 UTC

This package is auto-updated.

Last update: 2024-08-29 05:43:34 UTC


README

字典序计算器,用于持久化有序列表。

安装

通过 composer 安装

composer require pccomponentes/lexicographic-ranking

使用方法

$calculator = new RankingCalculator(
    new Alpha36TokenSet(),
    new DynamicMidPosition()
);

echo $calculator->between('A', 'B');   // AU
echo $calculator->between('F6', 'Z');  // P
echo $calculator->between('FB', 'FW'); // FL
echo $calculator->between(null, '7');  // 3
echo $calculator->between(null, null); // U

配置选项

令牌集

创建排名的字符池。以下为可用选项

NumericTokenSet (0-9)
Alpha36TokenSet (0-9 and A-Z)
Alpha62TokenSet (0-9 and A-z)

要创建自定义的,请从 TokenSet 扩展。

位置

排名之间留出的空间。以下模式可用

FixedStartPosition  // Leaves a fixed amount of spaces after the first input
FixedEndPosition    // Leaves a fixed amount of spaces before the second input
DynamicMidPosition  // Leaves the same space before and after the result

要创建自定义的,请实现 Position。