mirror of
https://github.com/bcicen/ctop.git
synced 2024-08-30 18:23:19 +00:00
move container sort to struct method
This commit is contained in:
parent
aff6943d07
commit
a48a9031cc
@ -3,7 +3,6 @@ package connector
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"sort"
|
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
@ -161,7 +160,7 @@ func (cm *Docker) All() (containers container.Containers) {
|
|||||||
for _, c := range cm.containers {
|
for _, c := range cm.containers {
|
||||||
containers = append(containers, c)
|
containers = append(containers, c)
|
||||||
}
|
}
|
||||||
sort.Sort(containers)
|
containers.Sort()
|
||||||
containers.Filter()
|
containers.Filter()
|
||||||
cm.lock.Unlock()
|
cm.lock.Unlock()
|
||||||
return containers
|
return containers
|
||||||
|
@ -4,7 +4,6 @@ package connector
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"math/rand"
|
"math/rand"
|
||||||
"sort"
|
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -72,7 +71,7 @@ func (cs *Mock) Get(id string) (*container.Container, bool) {
|
|||||||
|
|
||||||
// Return array of all containers, sorted by field
|
// Return array of all containers, sorted by field
|
||||||
func (cs *Mock) All() container.Containers {
|
func (cs *Mock) All() container.Containers {
|
||||||
sort.Sort(cs.containers)
|
cs.containers.Sort()
|
||||||
cs.containers.Filter()
|
cs.containers.Filter()
|
||||||
return cs.containers
|
return cs.containers
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,6 @@ import (
|
|||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"sort"
|
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -217,7 +216,7 @@ func (cm *Runc) All() (containers container.Containers) {
|
|||||||
for _, c := range cm.containers {
|
for _, c := range cm.containers {
|
||||||
containers = append(containers, c)
|
containers = append(containers, c)
|
||||||
}
|
}
|
||||||
sort.Sort(containers)
|
containers.Sort()
|
||||||
containers.Filter()
|
containers.Filter()
|
||||||
cm.lock.Unlock()
|
cm.lock.Unlock()
|
||||||
return containers
|
return containers
|
||||||
|
@ -3,6 +3,7 @@ package container
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"regexp"
|
"regexp"
|
||||||
|
"sort"
|
||||||
|
|
||||||
"github.com/bcicen/ctop/config"
|
"github.com/bcicen/ctop/config"
|
||||||
)
|
)
|
||||||
@ -89,6 +90,7 @@ func SortFields() (fields []string) {
|
|||||||
|
|
||||||
type Containers []*Container
|
type Containers []*Container
|
||||||
|
|
||||||
|
func (a Containers) Sort() { sort.Sort(a) }
|
||||||
func (a Containers) Len() int { return len(a) }
|
func (a Containers) Len() int { return len(a) }
|
||||||
func (a Containers) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
|
func (a Containers) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
|
||||||
func (a Containers) Less(i, j int) bool {
|
func (a Containers) Less(i, j int) bool {
|
||||||
|
Loading…
Reference in New Issue
Block a user