diff options
author | Ben Morrison <ben@gbmor.dev> | 2019-05-14 01:40:47 -0400 |
---|---|---|
committer | Ben Morrison <ben@gbmor.dev> | 2019-05-14 01:40:47 -0400 |
commit | 76ab864fd8372d947d3de97315e4f9996a39ff49 (patch) | |
tree | bc43746bd33100e660dbb2214f40ce366397a9de /cache/types.go | |
parent | fae46db2e7716a273a02a5bf52f8a0b78bcb23c8 (diff) | |
download | getwtxt-76ab864fd8372d947d3de97315e4f9996a39ff49.tar.gz |
tentatively finished QueryUser function
Diffstat (limited to 'cache/types.go')
-rw-r--r-- | cache/types.go | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/cache/types.go b/cache/types.go index ed270c3..939114e 100644 --- a/cache/types.go +++ b/cache/types.go @@ -22,5 +22,26 @@ type Data struct { status []string } -// Mutex to control access to the User Index +// Mutex to control access to the User Index. var imutex = sync.RWMutex{} + +// TimeSlice is used for sorting by timestamp. +type TimeSlice []time.Time + +// Len returns the length of the slice to be sorted. +// This helps satisfy sort.Interface with respect to TimeSlice. +func (t TimeSlice) Len() int { + return len(t) +} + +// Less returns true if the timestamp at index i is before the timestamp at index j in TimeSlice. +// This helps satisfy sort.Interface with respect to TimeSlice. +func (t TimeSlice) Less(i, j int) bool { + return t[i].Before(t[j]) +} + +// Swap transposes the timestampss at the two given indices. +// This helps satisfy sort.Interface with respect to TimeSlice. +func (t TimeSlice) Swap(i, j int) { + t[i], t[j] = t[j], t[i] +} |