github.com/nguyentm83/docker@v1.5.0/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 tmp := containers[i] 23 containers[i] = containers[j] 24 containers[j] = tmp 25 } 26 27 func (history *History) Add(container *Container) { 28 *history = append(*history, container) 29 } 30 31 func (history *History) Sort() { 32 sort.Sort(history) 33 }