feat(aa): rule interface: replace less & equal by the compare method.
- set a new alphabet order to sort AARE based string. - unify compare function for all rules - handle some special sort order, eg: base include
This commit is contained in:
parent
747292e954
commit
4cbacc186c
22 changed files with 250 additions and 399 deletions
|
|
@ -117,6 +117,12 @@ var (
|
|||
}
|
||||
fileWeights = generateWeights(fileAlphabet)
|
||||
|
||||
// The order AARE should be sorted
|
||||
stringAlphabet = []byte(
|
||||
"!\"#$%&'(){}[]*+,-./:;<=>?@\\^_`|~0123456789abcdefghijklmnopqrstuvwxyz",
|
||||
)
|
||||
stringWeights = generateWeights(stringAlphabet)
|
||||
|
||||
// The order the rule values (access, type, domains, etc) should be sorted
|
||||
requirements = map[Kind]requirement{}
|
||||
requirementsWeights map[Kind]map[string]map[string]int
|
||||
|
|
@ -155,7 +161,7 @@ func renderTemplate(name Kind, data any) string {
|
|||
return res.String()
|
||||
}
|
||||
|
||||
func generateWeights[T Kind | string](alphabet []T) map[T]int {
|
||||
func generateWeights[T comparable](alphabet []T) map[T]int {
|
||||
res := make(map[T]int, len(alphabet))
|
||||
for i, r := range alphabet {
|
||||
res[r] = i
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue