github.com/tsuna/docker@v1.7.0-rc3/daemon/history.go (about) 1 package daemon 2 3 import ( 4 "sort" 5 ) 6 7 // History is a convenience type for storing a list of containers, 8 // ordered by creation date. 9 type History []*Container 10 11 func (history *History) Len() int { 12 return len(*history) 13 } 14 15 func (history *History) Less(i, j int) bool { 16 containers := *history 17 return containers[j].Created.Before(containers[i].Created) 18 } 19 20 func (history *History) Swap(i, j int) { 21 containers := *history 22 containers[i], containers[j] = containers[j], containers[i] 23 } 24 25 func (history *History) Add(container *Container) { 26 *history = append(*history, container) 27 } 28 29 func (history *History) Sort() { 30 sort.Sort(history) 31 }