sort-slice.generated.go 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338
  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 float32Slice []float32
  15. func (p float32Slice) Len() int { return len(p) }
  16. func (p float32Slice) Swap(i, j int) { p[uint(i)], p[uint(j)] = p[uint(j)], p[uint(i)] }
  17. func (p float32Slice) Less(i, j int) bool {
  18. return p[uint(i)] < p[uint(j)] || isNaN32(p[uint(i)]) && !isNaN32(p[uint(j)])
  19. }
  20. type float64Slice []float64
  21. func (p float64Slice) Len() int { return len(p) }
  22. func (p float64Slice) Swap(i, j int) { p[uint(i)], p[uint(j)] = p[uint(j)], p[uint(i)] }
  23. func (p float64Slice) Less(i, j int) bool {
  24. return p[uint(i)] < p[uint(j)] || isNaN64(p[uint(i)]) && !isNaN64(p[uint(j)])
  25. }
  26. type uintSlice []uint
  27. func (p uintSlice) Len() int { return len(p) }
  28. func (p uintSlice) Swap(i, j int) { p[uint(i)], p[uint(j)] = p[uint(j)], p[uint(i)] }
  29. func (p uintSlice) Less(i, j int) bool {
  30. return p[uint(i)] < p[uint(j)]
  31. }
  32. type uint8Slice []uint8
  33. func (p uint8Slice) Len() int { return len(p) }
  34. func (p uint8Slice) Swap(i, j int) { p[uint(i)], p[uint(j)] = p[uint(j)], p[uint(i)] }
  35. func (p uint8Slice) Less(i, j int) bool {
  36. return p[uint(i)] < p[uint(j)]
  37. }
  38. type uint16Slice []uint16
  39. func (p uint16Slice) Len() int { return len(p) }
  40. func (p uint16Slice) Swap(i, j int) { p[uint(i)], p[uint(j)] = p[uint(j)], p[uint(i)] }
  41. func (p uint16Slice) Less(i, j int) bool {
  42. return p[uint(i)] < p[uint(j)]
  43. }
  44. type uint32Slice []uint32
  45. func (p uint32Slice) Len() int { return len(p) }
  46. func (p uint32Slice) Swap(i, j int) { p[uint(i)], p[uint(j)] = p[uint(j)], p[uint(i)] }
  47. func (p uint32Slice) Less(i, j int) bool {
  48. return p[uint(i)] < p[uint(j)]
  49. }
  50. type uint64Slice []uint64
  51. func (p uint64Slice) Len() int { return len(p) }
  52. func (p uint64Slice) Swap(i, j int) { p[uint(i)], p[uint(j)] = p[uint(j)], p[uint(i)] }
  53. func (p uint64Slice) Less(i, j int) bool {
  54. return p[uint(i)] < p[uint(j)]
  55. }
  56. type uintptrSlice []uintptr
  57. func (p uintptrSlice) Len() int { return len(p) }
  58. func (p uintptrSlice) Swap(i, j int) { p[uint(i)], p[uint(j)] = p[uint(j)], p[uint(i)] }
  59. func (p uintptrSlice) Less(i, j int) bool {
  60. return p[uint(i)] < p[uint(j)]
  61. }
  62. type intSlice []int
  63. func (p intSlice) Len() int { return len(p) }
  64. func (p intSlice) Swap(i, j int) { p[uint(i)], p[uint(j)] = p[uint(j)], p[uint(i)] }
  65. func (p intSlice) Less(i, j int) bool {
  66. return p[uint(i)] < p[uint(j)]
  67. }
  68. type int8Slice []int8
  69. func (p int8Slice) Len() int { return len(p) }
  70. func (p int8Slice) Swap(i, j int) { p[uint(i)], p[uint(j)] = p[uint(j)], p[uint(i)] }
  71. func (p int8Slice) Less(i, j int) bool {
  72. return p[uint(i)] < p[uint(j)]
  73. }
  74. type int16Slice []int16
  75. func (p int16Slice) Len() int { return len(p) }
  76. func (p int16Slice) Swap(i, j int) { p[uint(i)], p[uint(j)] = p[uint(j)], p[uint(i)] }
  77. func (p int16Slice) Less(i, j int) bool {
  78. return p[uint(i)] < p[uint(j)]
  79. }
  80. type int32Slice []int32
  81. func (p int32Slice) Len() int { return len(p) }
  82. func (p int32Slice) Swap(i, j int) { p[uint(i)], p[uint(j)] = p[uint(j)], p[uint(i)] }
  83. func (p int32Slice) Less(i, j int) bool {
  84. return p[uint(i)] < p[uint(j)]
  85. }
  86. type int64Slice []int64
  87. func (p int64Slice) Len() int { return len(p) }
  88. func (p int64Slice) Swap(i, j int) { p[uint(i)], p[uint(j)] = p[uint(j)], p[uint(i)] }
  89. func (p int64Slice) Less(i, j int) bool {
  90. return p[uint(i)] < p[uint(j)]
  91. }
  92. type boolSlice []bool
  93. func (p boolSlice) Len() int { return len(p) }
  94. func (p boolSlice) Swap(i, j int) { p[uint(i)], p[uint(j)] = p[uint(j)], p[uint(i)] }
  95. func (p boolSlice) Less(i, j int) bool {
  96. return !p[uint(i)] && p[uint(j)]
  97. }
  98. type timeSlice []time.Time
  99. func (p timeSlice) Len() int { return len(p) }
  100. func (p timeSlice) Swap(i, j int) { p[uint(i)], p[uint(j)] = p[uint(j)], p[uint(i)] }
  101. func (p timeSlice) Less(i, j int) bool {
  102. return p[uint(i)].Before(p[uint(j)])
  103. }
  104. type bytesSlice [][]byte
  105. func (p bytesSlice) Len() int { return len(p) }
  106. func (p bytesSlice) Swap(i, j int) { p[uint(i)], p[uint(j)] = p[uint(j)], p[uint(i)] }
  107. func (p bytesSlice) Less(i, j int) bool {
  108. return bytes.Compare(p[uint(i)], p[uint(j)]) == -1
  109. }
  110. type stringRv struct {
  111. v string
  112. r reflect.Value
  113. }
  114. type stringRvSlice []stringRv
  115. func (p stringRvSlice) Len() int { return len(p) }
  116. func (p stringRvSlice) Swap(i, j int) { p[uint(i)], p[uint(j)] = p[uint(j)], p[uint(i)] }
  117. func (p stringRvSlice) Less(i, j int) bool {
  118. return p[uint(i)].v < p[uint(j)].v
  119. }
  120. type stringIntf struct {
  121. v string
  122. i interface{}
  123. }
  124. type stringIntfSlice []stringIntf
  125. func (p stringIntfSlice) Len() int { return len(p) }
  126. func (p stringIntfSlice) Swap(i, j int) { p[uint(i)], p[uint(j)] = p[uint(j)], p[uint(i)] }
  127. func (p stringIntfSlice) Less(i, j int) bool {
  128. return p[uint(i)].v < p[uint(j)].v
  129. }
  130. type float64Rv struct {
  131. v float64
  132. r reflect.Value
  133. }
  134. type float64RvSlice []float64Rv
  135. func (p float64RvSlice) Len() int { return len(p) }
  136. func (p float64RvSlice) Swap(i, j int) { p[uint(i)], p[uint(j)] = p[uint(j)], p[uint(i)] }
  137. func (p float64RvSlice) Less(i, j int) bool {
  138. return p[uint(i)].v < p[uint(j)].v || isNaN64(p[uint(i)].v) && !isNaN64(p[uint(j)].v)
  139. }
  140. type float64Intf struct {
  141. v float64
  142. i interface{}
  143. }
  144. type float64IntfSlice []float64Intf
  145. func (p float64IntfSlice) Len() int { return len(p) }
  146. func (p float64IntfSlice) Swap(i, j int) { p[uint(i)], p[uint(j)] = p[uint(j)], p[uint(i)] }
  147. func (p float64IntfSlice) Less(i, j int) bool {
  148. return p[uint(i)].v < p[uint(j)].v || isNaN64(p[uint(i)].v) && !isNaN64(p[uint(j)].v)
  149. }
  150. type uint64Rv struct {
  151. v uint64
  152. r reflect.Value
  153. }
  154. type uint64RvSlice []uint64Rv
  155. func (p uint64RvSlice) Len() int { return len(p) }
  156. func (p uint64RvSlice) Swap(i, j int) { p[uint(i)], p[uint(j)] = p[uint(j)], p[uint(i)] }
  157. func (p uint64RvSlice) Less(i, j int) bool {
  158. return p[uint(i)].v < p[uint(j)].v
  159. }
  160. type uint64Intf struct {
  161. v uint64
  162. i interface{}
  163. }
  164. type uint64IntfSlice []uint64Intf
  165. func (p uint64IntfSlice) Len() int { return len(p) }
  166. func (p uint64IntfSlice) Swap(i, j int) { p[uint(i)], p[uint(j)] = p[uint(j)], p[uint(i)] }
  167. func (p uint64IntfSlice) Less(i, j int) bool {
  168. return p[uint(i)].v < p[uint(j)].v
  169. }
  170. type uintptrRv struct {
  171. v uintptr
  172. r reflect.Value
  173. }
  174. type uintptrRvSlice []uintptrRv
  175. func (p uintptrRvSlice) Len() int { return len(p) }
  176. func (p uintptrRvSlice) Swap(i, j int) { p[uint(i)], p[uint(j)] = p[uint(j)], p[uint(i)] }
  177. func (p uintptrRvSlice) Less(i, j int) bool {
  178. return p[uint(i)].v < p[uint(j)].v
  179. }
  180. type uintptrIntf struct {
  181. v uintptr
  182. i interface{}
  183. }
  184. type uintptrIntfSlice []uintptrIntf
  185. func (p uintptrIntfSlice) Len() int { return len(p) }
  186. func (p uintptrIntfSlice) Swap(i, j int) { p[uint(i)], p[uint(j)] = p[uint(j)], p[uint(i)] }
  187. func (p uintptrIntfSlice) Less(i, j int) bool {
  188. return p[uint(i)].v < p[uint(j)].v
  189. }
  190. type int64Rv struct {
  191. v int64
  192. r reflect.Value
  193. }
  194. type int64RvSlice []int64Rv
  195. func (p int64RvSlice) Len() int { return len(p) }
  196. func (p int64RvSlice) Swap(i, j int) { p[uint(i)], p[uint(j)] = p[uint(j)], p[uint(i)] }
  197. func (p int64RvSlice) Less(i, j int) bool {
  198. return p[uint(i)].v < p[uint(j)].v
  199. }
  200. type int64Intf struct {
  201. v int64
  202. i interface{}
  203. }
  204. type int64IntfSlice []int64Intf
  205. func (p int64IntfSlice) Len() int { return len(p) }
  206. func (p int64IntfSlice) Swap(i, j int) { p[uint(i)], p[uint(j)] = p[uint(j)], p[uint(i)] }
  207. func (p int64IntfSlice) Less(i, j int) bool {
  208. return p[uint(i)].v < p[uint(j)].v
  209. }
  210. type boolRv struct {
  211. v bool
  212. r reflect.Value
  213. }
  214. type boolRvSlice []boolRv
  215. func (p boolRvSlice) Len() int { return len(p) }
  216. func (p boolRvSlice) Swap(i, j int) { p[uint(i)], p[uint(j)] = p[uint(j)], p[uint(i)] }
  217. func (p boolRvSlice) Less(i, j int) bool {
  218. return !p[uint(i)].v && p[uint(j)].v
  219. }
  220. type boolIntf struct {
  221. v bool
  222. i interface{}
  223. }
  224. type boolIntfSlice []boolIntf
  225. func (p boolIntfSlice) Len() int { return len(p) }
  226. func (p boolIntfSlice) Swap(i, j int) { p[uint(i)], p[uint(j)] = p[uint(j)], p[uint(i)] }
  227. func (p boolIntfSlice) Less(i, j int) bool {
  228. return !p[uint(i)].v && p[uint(j)].v
  229. }
  230. type timeRv struct {
  231. v time.Time
  232. r reflect.Value
  233. }
  234. type timeRvSlice []timeRv
  235. func (p timeRvSlice) Len() int { return len(p) }
  236. func (p timeRvSlice) Swap(i, j int) { p[uint(i)], p[uint(j)] = p[uint(j)], p[uint(i)] }
  237. func (p timeRvSlice) Less(i, j int) bool {
  238. return p[uint(i)].v.Before(p[uint(j)].v)
  239. }
  240. type timeIntf struct {
  241. v time.Time
  242. i interface{}
  243. }
  244. type timeIntfSlice []timeIntf
  245. func (p timeIntfSlice) Len() int { return len(p) }
  246. func (p timeIntfSlice) Swap(i, j int) { p[uint(i)], p[uint(j)] = p[uint(j)], p[uint(i)] }
  247. func (p timeIntfSlice) Less(i, j int) bool {
  248. return p[uint(i)].v.Before(p[uint(j)].v)
  249. }
  250. type bytesRv struct {
  251. v []byte
  252. r reflect.Value
  253. }
  254. type bytesRvSlice []bytesRv
  255. func (p bytesRvSlice) Len() int { return len(p) }
  256. func (p bytesRvSlice) Swap(i, j int) { p[uint(i)], p[uint(j)] = p[uint(j)], p[uint(i)] }
  257. func (p bytesRvSlice) Less(i, j int) bool {
  258. return bytes.Compare(p[uint(i)].v, p[uint(j)].v) == -1
  259. }
  260. type bytesIntf struct {
  261. v []byte
  262. i interface{}
  263. }
  264. type bytesIntfSlice []bytesIntf
  265. func (p bytesIntfSlice) Len() int { return len(p) }
  266. func (p bytesIntfSlice) Swap(i, j int) { p[uint(i)], p[uint(j)] = p[uint(j)], p[uint(i)] }
  267. func (p bytesIntfSlice) Less(i, j int) bool {
  268. return bytes.Compare(p[uint(i)].v, p[uint(j)].v) == -1
  269. }