This Golang library provides utilities to generate Lexorank codes, which are used for ordering items in a way that allows efficient insertion of new items between existing ones. The library offers two main functions:
Rank(prev string, next string) string
- Generates a single Lexorank code between two given ranks.RankN(prev string, next string, n int) []string
- Generates multiple Lexorank codes between two given ranks.
To install the library, use the following command:
go get github.com/danghh-1998/lexorank
Import the library in your Go code:
import "github.com/danghh-1998/lexorank"
Use the Rank
function to generate a Lexorank code between two existing ranks:
package main
import (
"fmt"
"github.com/danghh-1998/lexorank"
)
func main() {
prev := "a"
next := "b"
rank := lexorank.Rank(prev, next)
fmt.Println("Generated Lexorank:", rank)
}
Use the RankN
function to generate multiple Lexorank codes between two existing ranks:
package main
import (
"fmt"
"github.com/danghh-1998/lexorank"
)
func main() {
prev := "a"
next := "b"
n := 5
ranks := lexorank.RankN(prev, next, n)
fmt.Println("Generated Lexoranks:", ranks)
}
func Rank(prev string, next string) string
prev
: The previous Lexorank code.next
: The next Lexorank code.
Generates a single Lexorank code between prev
and next
.
func RankN(prev string, next string, n int) []string
prev
: The previous Lexorank code.next
: The next Lexorank code.n
: The number of Lexorank codes to generate.
Generates n
Lexorank codes between prev
and next
.
Contributions are welcome! Please open an issue or submit a pull request on GitHub. See the CONTRIBUTING file for more details.
This library is licensed under the MIT License. See the LICENSE file for more details.