1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
|
package byteutil
import "sort"
// Alphabet returns the alphabet of a byte slice
func Alphabet(s []byte) []byte {
count := CountOfByte(s)
letters := make([]byte, len(count))
i := 0
for b := range count {
letters[i] = b
i++
}
sort.Sort(ByteSlice(letters))
return letters
}
// AlphabetFromCountOfByte returns the alphabet of a byte slice from count
func AlphabetFromCountOfByte(count map[byte]int) []byte {
letters := make([]byte, len(count))
i := 0
for b := range count {
letters[i] = b
i++
}
sort.Sort(ByteSlice(letters))
return letters
}
|