stubbed out
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
package pwgenerator
|
||||
|
||||
import (
|
||||
"sort"
|
||||
)
|
||||
|
||||
// sortDedupe sorts a slice of runes and deduplicates them.
|
||||
func sortDedupe(charset *CharSet) {
|
||||
|
||||
var vals map[Char]bool = make(map[Char]bool)
|
||||
var sorted CharSet
|
||||
var idx int
|
||||
|
||||
// This inherently dedupes.
|
||||
for _, i := range *charset {
|
||||
vals[i] = true
|
||||
}
|
||||
|
||||
// This handles sorting.
|
||||
sorted = make(CharSet, len(vals))
|
||||
// First we need a slice (again).
|
||||
for k := range vals {
|
||||
sorted[idx] = k
|
||||
idx++
|
||||
}
|
||||
// And now we can sort...
|
||||
sort.Sort(&sorted)
|
||||
|
||||
// And replace the original charset with the sorted, deduplicated one.
|
||||
*charset = sorted
|
||||
|
||||
return
|
||||
}
|
||||
Reference in New Issue
Block a user