mirror of
https://github.com/coaidev/coai.git
synced 2025-05-19 21:10:18 +09:00
30 lines
468 B
Go
30 lines
468 B
Go
package channel
|
|
|
|
import "sort"
|
|
|
|
func (s *Sequence) Len() int {
|
|
return len(*s)
|
|
}
|
|
|
|
func (s *Sequence) Less(i, j int) bool {
|
|
return (*s)[i].GetPriority() < (*s)[j].GetPriority()
|
|
}
|
|
|
|
func (s *Sequence) Swap(i, j int) {
|
|
(*s)[i], (*s)[j] = (*s)[j], (*s)[i]
|
|
}
|
|
|
|
func (s *Sequence) GetChannelById(id int) *Channel {
|
|
for _, channel := range *s {
|
|
if channel.Id == id {
|
|
return channel
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (s *Sequence) Sort() {
|
|
// sort by priority
|
|
sort.Sort(s)
|
|
}
|