File: struct.go

package info (click to toggle)
golang-github-shenwei356-util 0.0~git20201231.861956c-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 192 kB
  • sloc: makefile: 2
file content (23 lines) | stat: -rw-r--r-- 591 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
package byteutil

import "bytes"

// SliceOfByteSlice is [][]byte
type SliceOfByteSlice [][]byte

func (s SliceOfByteSlice) Len() int { return len(s) }
func (s SliceOfByteSlice) Less(i, j int) bool {
	c := bytes.Compare(s[i], s[j])
	if c == -1 {
		return true
	}
	return false
}
func (s SliceOfByteSlice) Swap(i, j int) { s[i], s[j] = s[j], s[i] }

// ByteSlice is []byte
type ByteSlice []byte

func (bs ByteSlice) Len() int           { return len(bs) }
func (bs ByteSlice) Less(i, j int) bool { return bs[i] < bs[j] }
func (bs ByteSlice) Swap(i, j int)      { bs[i], bs[j] = bs[j], bs[i] }