mirror of
https://github.com/btcsuite/btcd.git
synced 2024-11-19 18:00:11 +01:00
6e402deb35
This commit relicenses all code in this repository to the btcsuite developers.
32 lines
855 B
Go
32 lines
855 B
Go
// Copyright (c) 2013-2014 The btcsuite developers
|
|
// Use of this source code is governed by an ISC
|
|
// license that can be found in the LICENSE file.
|
|
|
|
package blockchain
|
|
|
|
import (
|
|
"time"
|
|
)
|
|
|
|
// timeSorter implements sort.Interface to allow a slice of timestamps to
|
|
// be sorted.
|
|
type timeSorter []time.Time
|
|
|
|
// 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 {
|
|
return s[i].Before(s[j])
|
|
}
|