sort-slice.generated.go 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  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 float64Rv struct {
  67. v float64
  68. r reflect.Value
  69. }
  70. type float64RvSlice []float64Rv
  71. func (p float64RvSlice) Len() int { return len(p) }
  72. func (p float64RvSlice) Swap(i, j int) { p[uint(i)], p[uint(j)] = p[uint(j)], p[uint(i)] }
  73. func (p float64RvSlice) Less(i, j int) bool {
  74. return p[uint(i)].v < p[uint(j)].v || isNaN64(p[uint(i)].v) && !isNaN64(p[uint(j)].v)
  75. }
  76. type uint64Rv struct {
  77. v uint64
  78. r reflect.Value
  79. }
  80. type uint64RvSlice []uint64Rv
  81. func (p uint64RvSlice) Len() int { return len(p) }
  82. func (p uint64RvSlice) Swap(i, j int) { p[uint(i)], p[uint(j)] = p[uint(j)], p[uint(i)] }
  83. func (p uint64RvSlice) Less(i, j int) bool {
  84. return p[uint(i)].v < p[uint(j)].v
  85. }
  86. type uintptrRv struct {
  87. v uintptr
  88. r reflect.Value
  89. }
  90. type uintptrRvSlice []uintptrRv
  91. func (p uintptrRvSlice) Len() int { return len(p) }
  92. func (p uintptrRvSlice) Swap(i, j int) { p[uint(i)], p[uint(j)] = p[uint(j)], p[uint(i)] }
  93. func (p uintptrRvSlice) Less(i, j int) bool {
  94. return p[uint(i)].v < p[uint(j)].v
  95. }
  96. type int64Rv struct {
  97. v int64
  98. r reflect.Value
  99. }
  100. type int64RvSlice []int64Rv
  101. func (p int64RvSlice) Len() int { return len(p) }
  102. func (p int64RvSlice) Swap(i, j int) { p[uint(i)], p[uint(j)] = p[uint(j)], p[uint(i)] }
  103. func (p int64RvSlice) Less(i, j int) bool {
  104. return p[uint(i)].v < p[uint(j)].v
  105. }
  106. type boolRv struct {
  107. v bool
  108. r reflect.Value
  109. }
  110. type boolRvSlice []boolRv
  111. func (p boolRvSlice) Len() int { return len(p) }
  112. func (p boolRvSlice) Swap(i, j int) { p[uint(i)], p[uint(j)] = p[uint(j)], p[uint(i)] }
  113. func (p boolRvSlice) Less(i, j int) bool {
  114. return !p[uint(i)].v && p[uint(j)].v
  115. }
  116. type timeRv struct {
  117. v time.Time
  118. r reflect.Value
  119. }
  120. type timeRvSlice []timeRv
  121. func (p timeRvSlice) Len() int { return len(p) }
  122. func (p timeRvSlice) Swap(i, j int) { p[uint(i)], p[uint(j)] = p[uint(j)], p[uint(i)] }
  123. func (p timeRvSlice) Less(i, j int) bool {
  124. return p[uint(i)].v.Before(p[uint(j)].v)
  125. }
  126. type bytesRv struct {
  127. v []byte
  128. r reflect.Value
  129. }
  130. type bytesRvSlice []bytesRv
  131. func (p bytesRvSlice) Len() int { return len(p) }
  132. func (p bytesRvSlice) Swap(i, j int) { p[uint(i)], p[uint(j)] = p[uint(j)], p[uint(i)] }
  133. func (p bytesRvSlice) Less(i, j int) bool {
  134. return bytes.Compare(p[uint(i)].v, p[uint(j)].v) == -1
  135. }
  136. type bytesIntf struct {
  137. v []byte
  138. i interface{}
  139. }
  140. type bytesIntfSlice []bytesIntf
  141. func (p bytesIntfSlice) Len() int { return len(p) }
  142. func (p bytesIntfSlice) Swap(i, j int) { p[uint(i)], p[uint(j)] = p[uint(j)], p[uint(i)] }
  143. func (p bytesIntfSlice) Less(i, j int) bool {
  144. return bytes.Compare(p[uint(i)].v, p[uint(j)].v) == -1
  145. }