2017-01-31 01:32:50 +01:00
|
|
|
// Copyright (c) 2013-2017 The btcsuite developers
|
2013-07-18 16:49:28 +02:00
|
|
|
// Use of this source code is governed by an ISC
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
2015-01-30 21:54:30 +01:00
|
|
|
package blockchain
|
2013-07-18 16:49:28 +02:00
|
|
|
|
|
|
|
// timeSorter implements sort.Interface to allow a slice of timestamps to
|
|
|
|
// be sorted.
|
2017-01-31 01:32:50 +01:00
|
|
|
type timeSorter []int64
|
2013-07-18 16:49:28 +02:00
|
|
|
|
|
|
|
// Len returns the number of timestamps in the slice. It is part of the
|
|
|
|
// sort.Interface implementation.
|
|
|
|
func (s timeSorter) Len() int {
|
|
|
|
return len(s)
|
|
|
|
}
|
|
|
|
|
|
|
|
// Swap swaps the timestamps at the passed indices. It is part of the
|
|
|
|
// sort.Interface implementation.
|
|
|
|
func (s timeSorter) Swap(i, j int) {
|
|
|
|
s[i], s[j] = s[j], s[i]
|
|
|
|
}
|
|
|
|
|
|
|
|
// Less returns whether the timstamp with index i should sort before the
|
|
|
|
// timestamp with index j. It is part of the sort.Interface implementation.
|
|
|
|
func (s timeSorter) Less(i, j int) bool {
|
2017-01-31 01:32:50 +01:00
|
|
|
return s[i] < s[j]
|
2013-07-18 16:49:28 +02:00
|
|
|
}
|