sort-slice.generated.go 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  1. // Copyright (c) 2012-2018 Ugorji Nwoke. All rights reserved.
  2. // Use of this source code is governed by a MIT license found in the LICENSE file.
  3. // Code generated from sort-slice.go.tmpl - DO NOT EDIT.
  4. package codec
  5. import "time"
  6. import "reflect"
  7. import "bytes"
  8. type stringSlice []string
  9. func (p stringSlice) Len() int { return len(p) }
  10. func (p stringSlice) Swap(i, j int) { p[uint(i)], p[uint(j)] = p[uint(j)], p[uint(i)] }
  11. func (p stringSlice) Less(i, j int) bool {
  12. return p[uint(i)] < p[uint(j)]
  13. }
  14. type float64Slice []float64
  15. func (p float64Slice) Len() int { return len(p) }
  16. func (p float64Slice) Swap(i, j int) { p[uint(i)], p[uint(j)] = p[uint(j)], p[uint(i)] }
  17. func (p float64Slice) Less(i, j int) bool {
  18. return p[uint(i)] < p[uint(j)] || isNaN64(p[uint(i)]) && !isNaN64(p[uint(j)])
  19. }
  20. type uint64Slice []uint64
  21. func (p uint64Slice) Len() int { return len(p) }
  22. func (p uint64Slice) Swap(i, j int) { p[uint(i)], p[uint(j)] = p[uint(j)], p[uint(i)] }
  23. func (p uint64Slice) Less(i, j int) bool {
  24. return p[uint(i)] < p[uint(j)]
  25. }
  26. type uintptrSlice []uintptr
  27. func (p uintptrSlice) Len() int { return len(p) }
  28. func (p uintptrSlice) Swap(i, j int) { p[uint(i)], p[uint(j)] = p[uint(j)], p[uint(i)] }
  29. func (p uintptrSlice) Less(i, j int) bool {
  30. return p[uint(i)] < p[uint(j)]
  31. }
  32. type int64Slice []int64
  33. func (p int64Slice) Len() int { return len(p) }
  34. func (p int64Slice) Swap(i, j int) { p[uint(i)], p[uint(j)] = p[uint(j)], p[uint(i)] }
  35. func (p int64Slice) Less(i, j int) bool {
  36. return p[uint(i)] < p[uint(j)]
  37. }
  38. type boolSlice []bool
  39. func (p boolSlice) Len() int { return len(p) }
  40. func (p boolSlice) Swap(i, j int) { p[uint(i)], p[uint(j)] = p[uint(j)], p[uint(i)] }
  41. func (p boolSlice) Less(i, j int) bool {
  42. return !p[uint(i)] && p[uint(j)]
  43. }
  44. type timeSlice []time.Time
  45. func (p timeSlice) Len() int { return len(p) }
  46. func (p timeSlice) Swap(i, j int) { p[uint(i)], p[uint(j)] = p[uint(j)], p[uint(i)] }
  47. func (p timeSlice) Less(i, j int) bool {
  48. return p[uint(i)].Before(p[uint(j)])
  49. }
  50. type bytesSlice [][]byte
  51. func (p bytesSlice) Len() int { return len(p) }
  52. func (p bytesSlice) Swap(i, j int) { p[uint(i)], p[uint(j)] = p[uint(j)], p[uint(i)] }
  53. func (p bytesSlice) Less(i, j int) bool {
  54. return bytes.Compare(p[uint(i)], p[uint(j)]) == -1
  55. }
  56. type stringRv struct {
  57. v string
  58. r reflect.Value
  59. }
  60. type stringRvSlice []stringRv
  61. func (p stringRvSlice) Len() int { return len(p) }
  62. func (p stringRvSlice) Swap(i, j int) { p[uint(i)], p[uint(j)] = p[uint(j)], p[uint(i)] }
  63. func (p stringRvSlice) Less(i, j int) bool {
  64. return p[uint(i)].v < p[uint(j)].v
  65. }
  66. type stringIntf struct {
  67. v string
  68. i interface{}
  69. }
  70. type stringIntfSlice []stringIntf
  71. func (p stringIntfSlice) Len() int { return len(p) }
  72. func (p stringIntfSlice) Swap(i, j int) { p[uint(i)], p[uint(j)] = p[uint(j)], p[uint(i)] }
  73. func (p stringIntfSlice) Less(i, j int) bool {
  74. return p[uint(i)].v < p[uint(j)].v
  75. }
  76. type float64Rv struct {
  77. v float64
  78. r reflect.Value
  79. }
  80. type float64RvSlice []float64Rv
  81. func (p float64RvSlice) Len() int { return len(p) }
  82. func (p float64RvSlice) Swap(i, j int) { p[uint(i)], p[uint(j)] = p[uint(j)], p[uint(i)] }
  83. func (p float64RvSlice) Less(i, j int) bool {
  84. return p[uint(i)].v < p[uint(j)].v || isNaN64(p[uint(i)].v) && !isNaN64(p[uint(j)].v)
  85. }
  86. type float64Intf struct {
  87. v float64
  88. i interface{}
  89. }
  90. type float64IntfSlice []float64Intf
  91. func (p float64IntfSlice) Len() int { return len(p) }
  92. func (p float64IntfSlice) Swap(i, j int) { p[uint(i)], p[uint(j)] = p[uint(j)], p[uint(i)] }
  93. func (p float64IntfSlice) Less(i, j int) bool {
  94. return p[uint(i)].v < p[uint(j)].v || isNaN64(p[uint(i)].v) && !isNaN64(p[uint(j)].v)
  95. }
  96. type uint64Rv struct {
  97. v uint64
  98. r reflect.Value
  99. }
  100. type uint64RvSlice []uint64Rv
  101. func (p uint64RvSlice) Len() int { return len(p) }
  102. func (p uint64RvSlice) Swap(i, j int) { p[uint(i)], p[uint(j)] = p[uint(j)], p[uint(i)] }
  103. func (p uint64RvSlice) Less(i, j int) bool {
  104. return p[uint(i)].v < p[uint(j)].v
  105. }
  106. type uint64Intf struct {
  107. v uint64
  108. i interface{}
  109. }
  110. type uint64IntfSlice []uint64Intf
  111. func (p uint64IntfSlice) Len() int { return len(p) }
  112. func (p uint64IntfSlice) Swap(i, j int) { p[uint(i)], p[uint(j)] = p[uint(j)], p[uint(i)] }
  113. func (p uint64IntfSlice) Less(i, j int) bool {
  114. return p[uint(i)].v < p[uint(j)].v
  115. }
  116. type uintptrRv struct {
  117. v uintptr
  118. r reflect.Value
  119. }
  120. type uintptrRvSlice []uintptrRv
  121. func (p uintptrRvSlice) Len() int { return len(p) }
  122. func (p uintptrRvSlice) Swap(i, j int) { p[uint(i)], p[uint(j)] = p[uint(j)], p[uint(i)] }
  123. func (p uintptrRvSlice) Less(i, j int) bool {
  124. return p[uint(i)].v < p[uint(j)].v
  125. }
  126. type uintptrIntf struct {
  127. v uintptr
  128. i interface{}
  129. }
  130. type uintptrIntfSlice []uintptrIntf
  131. func (p uintptrIntfSlice) Len() int { return len(p) }
  132. func (p uintptrIntfSlice) Swap(i, j int) { p[uint(i)], p[uint(j)] = p[uint(j)], p[uint(i)] }
  133. func (p uintptrIntfSlice) Less(i, j int) bool {
  134. return p[uint(i)].v < p[uint(j)].v
  135. }
  136. type int64Rv struct {
  137. v int64
  138. r reflect.Value
  139. }
  140. type int64RvSlice []int64Rv
  141. func (p int64RvSlice) Len() int { return len(p) }
  142. func (p int64RvSlice) Swap(i, j int) { p[uint(i)], p[uint(j)] = p[uint(j)], p[uint(i)] }
  143. func (p int64RvSlice) Less(i, j int) bool {
  144. return p[uint(i)].v < p[uint(j)].v
  145. }
  146. type int64Intf struct {
  147. v int64
  148. i interface{}
  149. }
  150. type int64IntfSlice []int64Intf
  151. func (p int64IntfSlice) Len() int { return len(p) }
  152. func (p int64IntfSlice) Swap(i, j int) { p[uint(i)], p[uint(j)] = p[uint(j)], p[uint(i)] }
  153. func (p int64IntfSlice) Less(i, j int) bool {
  154. return p[uint(i)].v < p[uint(j)].v
  155. }
  156. type boolRv struct {
  157. v bool
  158. r reflect.Value
  159. }
  160. type boolRvSlice []boolRv
  161. func (p boolRvSlice) Len() int { return len(p) }
  162. func (p boolRvSlice) Swap(i, j int) { p[uint(i)], p[uint(j)] = p[uint(j)], p[uint(i)] }
  163. func (p boolRvSlice) Less(i, j int) bool {
  164. return !p[uint(i)].v && p[uint(j)].v
  165. }
  166. type boolIntf struct {
  167. v bool
  168. i interface{}
  169. }
  170. type boolIntfSlice []boolIntf
  171. func (p boolIntfSlice) Len() int { return len(p) }
  172. func (p boolIntfSlice) Swap(i, j int) { p[uint(i)], p[uint(j)] = p[uint(j)], p[uint(i)] }
  173. func (p boolIntfSlice) Less(i, j int) bool {
  174. return !p[uint(i)].v && p[uint(j)].v
  175. }
  176. type timeRv struct {
  177. v time.Time
  178. r reflect.Value
  179. }
  180. type timeRvSlice []timeRv
  181. func (p timeRvSlice) Len() int { return len(p) }
  182. func (p timeRvSlice) Swap(i, j int) { p[uint(i)], p[uint(j)] = p[uint(j)], p[uint(i)] }
  183. func (p timeRvSlice) Less(i, j int) bool {
  184. return p[uint(i)].v.Before(p[uint(j)].v)
  185. }
  186. type timeIntf struct {
  187. v time.Time
  188. i interface{}
  189. }
  190. type timeIntfSlice []timeIntf
  191. func (p timeIntfSlice) Len() int { return len(p) }
  192. func (p timeIntfSlice) Swap(i, j int) { p[uint(i)], p[uint(j)] = p[uint(j)], p[uint(i)] }
  193. func (p timeIntfSlice) Less(i, j int) bool {
  194. return p[uint(i)].v.Before(p[uint(j)].v)
  195. }
  196. type bytesRv struct {
  197. v []byte
  198. r reflect.Value
  199. }
  200. type bytesRvSlice []bytesRv
  201. func (p bytesRvSlice) Len() int { return len(p) }
  202. func (p bytesRvSlice) Swap(i, j int) { p[uint(i)], p[uint(j)] = p[uint(j)], p[uint(i)] }
  203. func (p bytesRvSlice) Less(i, j int) bool {
  204. return bytes.Compare(p[uint(i)].v, p[uint(j)].v) == -1
  205. }
  206. type bytesIntf struct {
  207. v []byte
  208. i interface{}
  209. }
  210. type bytesIntfSlice []bytesIntf
  211. func (p bytesIntfSlice) Len() int { return len(p) }
  212. func (p bytesIntfSlice) Swap(i, j int) { p[uint(i)], p[uint(j)] = p[uint(j)], p[uint(i)] }
  213. func (p bytesIntfSlice) Less(i, j int) bool {
  214. return bytes.Compare(p[uint(i)].v, p[uint(j)].v) == -1
  215. }