strs

package
v0.0.0-...-7aac46a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 10, 2023 License: MIT Imports: 1 Imported by: 0

README

strs

This package contains string utilities and algorithms. New MatchSplit(non-recursive) function is about 2x faster than recursive version.

Mike@/tmp:$ go test -bench=. t_test.go -cpuprofile=c.out
BenchmarkMatch-2         1000000              1144 ns/op
BenchmarkMatchNew-2      2000000             **607 ns/op**
PASS
ok      command-line-arguments  3.052s
Mike@/tmp:$

Documentation

Overview

Strs contants string utils.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FindPrefix

func FindPrefix(a *string, b *string, pf *int)

FindPrefix finds longest common prefix between two strings and writes it to int pointer `pf`.

func LCPWithSeparator

func LCPWithSeparator(a string, b string, spl byte) int

LCPWithSeparator is similar to `FindPrefix` but returns longest common prefix with evaluating wildcard positions.

func Match

func Match(a string, b string, spl string, wildcard string) bool

Match returns wether two strings seperated by delimiter `spl` are exactly a match. First string can contain a wildcard `wildcard` which forces the algrithm to count it as a match. For example: `test/*/a` and `test/a/a` are exact matches because `*` matches any string at its level.

func MatchSplits

func MatchSplits(a string, b string, spl string, wildcard string) bool

MatchSplits returns wether two strings seperated by delimiter `spl` are exactly a match. First string can contain a wildcard `wildcard` which forces the algrithm to count it as a match. For example: `/test/*/a` and `/test/a/a` are exact matches because `*` matches any string at its level. This function is not implemented recursively because of performance issues ( non recursive version is about 500ms faster than a recursive impl.).

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL