https://github.com/adnanmula/lexicographic-ranking
https://github.com/adnanmula/lexicographic-ranking
Last synced: 3 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/adnanmula/lexicographic-ranking
- Owner: adnanmula
- License: mit
- Created: 2025-03-12T09:16:35.000Z (3 months ago)
- Default Branch: master
- Last Pushed: 2025-03-12T09:25:28.000Z (3 months ago)
- Last Synced: 2025-03-12T10:30:50.689Z (3 months ago)
- Language: PHP
- Size: 16.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Lexicographic Ranking
Lexicographic order calculator, useful for persisting ordered lists.
## Installation
Install via [composer](https://getcomposer.org/)
```shell
composer require adnanmula/lexicographic-ranking
```## Usage
```php
$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
```## Config options
### Token setsThe char pool to create the rankings. The following are available:
```
NumericTokenSet (0-9)
Alpha36TokenSet (0-9 and A-Z)
Alpha62TokenSet (0-9 and A-z)
```
To create a custom one extend from TokenSet.### Position
The space to be left between ranks. The following modes are available:
```
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
```
To create a custom one implement Position.