pccomponentes / lexicographic-ranking
字典序计算器,用于持久化有序列表。
v0.0.5
2021-01-28 09:33 UTC
Requires
- php: >=7.4
Requires (Dev)
- pccomponentes/coding-standard: ^1.2
- phpro/grumphp: ^1.1
- phpstan/phpstan: ^0.12.55
- phpunit/phpunit: ^8.5
- symfony/var-dumper: ^5.1
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。