uint64slice.go raw

   1  package gcs
   2  
   3  // uint64slice is a package-local utility class that allows us to use Go's txsort package to txsort a []uint64 by
   4  // implementing sort.Interface.
   5  type uint64Slice []uint64
   6  
   7  // Len returns the length of the slice.
   8  func (p uint64Slice) Len() int {
   9  	return len(p)
  10  }
  11  
  12  // Less returns true when the ith element is smaller than the jth element of the slice, and returns false otherwise.
  13  func (p uint64Slice) Less(i, j int) bool {
  14  	return p[i] < p[j]
  15  }
  16  
  17  // Swap swaps two slice elements.
  18  func (p uint64Slice) Swap(i, j int) {
  19  	p[i], p[j] = p[j], p[i]
  20  }
  21