mirror of https://github.com/ethereum/go-ethereum
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
513 B
26 lines
513 B
10 years ago
|
package whisper
|
||
|
|
||
|
import "sort"
|
||
|
|
||
|
type sortedKeys struct {
|
||
|
k []int32
|
||
|
}
|
||
|
|
||
|
func (self *sortedKeys) Len() int { return len(self.k) }
|
||
|
func (self *sortedKeys) Less(i, j int) bool { return self.k[i] < self.k[j] }
|
||
|
func (self *sortedKeys) Swap(i, j int) { self.k[i], self.k[j] = self.k[j], self.k[i] }
|
||
|
|
||
|
func sortKeys(m map[int32]Hash) []int32 {
|
||
|
sorted := new(sortedKeys)
|
||
|
sorted.k = make([]int32, len(m))
|
||
|
i := 0
|
||
|
for key, _ := range m {
|
||
|
sorted.k[i] = key
|
||
|
i++
|
||
|
}
|
||
|
|
||
|
sort.Sort(sorted)
|
||
|
|
||
|
return sorted.k
|
||
|
}
|