mirror of
https://github.com/moby/moby.git
synced 2026-01-11 18:51:37 +00:00
These comments were added to enforce using the correct import path for
our packages ("github.com/docker/docker", not "github.com/moby/moby").
However, when working in go module mode (not GOPATH / vendor), they have
no effect, so their impact is limited.
Remove these imports in preparation of migrating our code to become an
actual go module.
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
31 lines
841 B
Go
31 lines
841 B
Go
package container
|
|
|
|
import "sort"
|
|
|
|
// History is a convenience type for storing a list of containers,
|
|
// sorted by creation date in descendant order.
|
|
type History []*Container
|
|
|
|
// Len returns the number of containers in the history.
|
|
func (history *History) Len() int {
|
|
return len(*history)
|
|
}
|
|
|
|
// Less compares two containers and returns true if the second one
|
|
// was created before the first one.
|
|
func (history *History) Less(i, j int) bool {
|
|
containers := *history
|
|
return containers[j].Created.Before(containers[i].Created)
|
|
}
|
|
|
|
// Swap switches containers i and j positions in the history.
|
|
func (history *History) Swap(i, j int) {
|
|
containers := *history
|
|
containers[i], containers[j] = containers[j], containers[i]
|
|
}
|
|
|
|
// sort orders the history by creation date in descendant order.
|
|
func (history *History) sort() {
|
|
sort.Sort(history)
|
|
}
|