package sortutil
import "k8s.io/kubernetes/Godeps/_workspace/src/github.com/cznic/sortutil"
Package sortutil provides utilities supplementing the standard 'sort' package.
Index ¶
- func Dedupe(data sort.Interface) (n int)
- func SearchBytes(a []byte, x byte) int
- func SearchFloat32s(a []float32, x float32) int
- func SearchInt16s(a []int16, x int16) int
- func SearchInt32s(a []int32, x int32) int
- func SearchInt64s(a []int64, x int64) int
- func SearchInt8s(a []int8, x int8) int
- func SearchRunes(a []rune, x rune) int
- func SearchUint16s(a []uint16, x uint16) int
- func SearchUint32s(a []uint32, x uint32) int
- func SearchUint64s(a []uint64, x uint64) int
- func SearchUints(a []uint, x uint) int
- type ByteSlice
- func (s ByteSlice) Len() int
- func (s ByteSlice) Less(i, j int) bool
- func (s ByteSlice) Sort()
- func (s ByteSlice) Swap(i, j int)
- type Float32Slice
- func (s Float32Slice) Len() int
- func (s Float32Slice) Less(i, j int) bool
- func (s Float32Slice) Sort()
- func (s Float32Slice) Swap(i, j int)
- type Int16Slice
- func (s Int16Slice) Len() int
- func (s Int16Slice) Less(i, j int) bool
- func (s Int16Slice) Sort()
- func (s Int16Slice) Swap(i, j int)
- type Int32Slice
- func (s Int32Slice) Len() int
- func (s Int32Slice) Less(i, j int) bool
- func (s Int32Slice) Sort()
- func (s Int32Slice) Swap(i, j int)
- type Int64Slice
- func (s Int64Slice) Len() int
- func (s Int64Slice) Less(i, j int) bool
- func (s Int64Slice) Sort()
- func (s Int64Slice) Swap(i, j int)
- type Int8Slice
- func (s Int8Slice) Len() int
- func (s Int8Slice) Less(i, j int) bool
- func (s Int8Slice) Sort()
- func (s Int8Slice) Swap(i, j int)
- type RuneSlice
- func (s RuneSlice) Len() int
- func (s RuneSlice) Less(i, j int) bool
- func (s RuneSlice) Sort()
- func (s RuneSlice) Swap(i, j int)
- type Uint16Slice
- func (s Uint16Slice) Len() int
- func (s Uint16Slice) Less(i, j int) bool
- func (s Uint16Slice) Sort()
- func (s Uint16Slice) Swap(i, j int)
- type Uint32Slice
- func (s Uint32Slice) Len() int
- func (s Uint32Slice) Less(i, j int) bool
- func (s Uint32Slice) Sort()
- func (s Uint32Slice) Swap(i, j int)
- type Uint64Slice
- func (s Uint64Slice) Len() int
- func (s Uint64Slice) Less(i, j int) bool
- func (s Uint64Slice) Sort()
- func (s Uint64Slice) Swap(i, j int)
- type UintSlice
Examples ¶
Functions ¶
func Dedupe ¶
Dedupe returns n, the number of distinct elements in data. The resulting
elements are sorted in elements [0, n) or data[:n] for a slice.
Code:
Output:Example¶
{
a := []int{4, 1, 2, 1, 3, 4, 2}
fmt.Println(a[:Dedupe(sort.IntSlice(a))])
b := []string{"foo", "bar", "baz", "bar", "foo", "qux", "qux"}
fmt.Println(b[:Dedupe(sort.StringSlice(b))])
// Output:
// [1 2 3 4]
// [bar baz foo qux]
}
[1 2 3 4]
[bar baz foo qux]
func SearchBytes ¶
SearchBytes searches for x in a sorted slice of bytes and returns the index as specified by sort.Search. The slice must be sorted in ascending order.
func SearchFloat32s ¶
SearchFloat32s searches for x in a sorted slice of float32 and returns the index as specified by sort.Search. The slice must be sorted in ascending order.
func SearchInt16s ¶
SearchInt16s searches for x in a sorted slice of int16 and returns the index as specified by sort.Search. The slice must be sorted in ascending order.
func SearchInt32s ¶
SearchInt32s searches for x in a sorted slice of int32 and returns the index as specified by sort.Search. The slice must be sorted in ascending order.
func SearchInt64s ¶
SearchInt64s searches for x in a sorted slice of int64 and returns the index as specified by sort.Search. The slice must be sorted in ascending order.
func SearchInt8s ¶
SearchInt8s searches for x in a sorted slice of int8 and returns the index as specified by sort.Search. The slice must be sorted in ascending order.
func SearchRunes ¶
SearchRunes searches for x in a sorted slice of uint64 and returns the index as specified by sort.Search. The slice must be sorted in ascending order.
func SearchUint16s ¶
SearchUint16s searches for x in a sorted slice of uint16 and returns the index as specified by sort.Search. The slice must be sorted in ascending order.
func SearchUint32s ¶
SearchUint32s searches for x in a sorted slice of uint32 and returns the index as specified by sort.Search. The slice must be sorted in ascending order.
func SearchUint64s ¶
SearchUint64s searches for x in a sorted slice of uint64 and returns the index as specified by sort.Search. The slice must be sorted in ascending order.
func SearchUints ¶
SearchUints searches for x in a sorted slice of uints and returns the index as specified by sort.Search. The slice must be sorted in ascending order.
Types ¶
type ByteSlice ¶
type ByteSlice []byte
ByteSlice attaches the methods of sort.Interface to []byte, sorting in increasing order.
func (ByteSlice) Len ¶
func (ByteSlice) Less ¶
func (ByteSlice) Sort ¶
func (s ByteSlice) Sort()
Sort is a convenience method.
func (ByteSlice) Swap ¶
type Float32Slice ¶
type Float32Slice []float32
Float32Slice attaches the methods of sort.Interface to []float32, sorting in increasing order.
func (Float32Slice) Len ¶
func (s Float32Slice) Len() int
func (Float32Slice) Less ¶
func (s Float32Slice) Less(i, j int) bool
func (Float32Slice) Sort ¶
func (s Float32Slice) Sort()
Sort is a convenience method.
func (Float32Slice) Swap ¶
func (s Float32Slice) Swap(i, j int)
type Int16Slice ¶
type Int16Slice []int16
Int16Slice attaches the methods of sort.Interface to []int16, sorting in increasing order.
func (Int16Slice) Len ¶
func (s Int16Slice) Len() int
func (Int16Slice) Less ¶
func (s Int16Slice) Less(i, j int) bool
func (Int16Slice) Sort ¶
func (s Int16Slice) Sort()
Sort is a convenience method.
func (Int16Slice) Swap ¶
func (s Int16Slice) Swap(i, j int)
type Int32Slice ¶
type Int32Slice []int32
Int32Slice attaches the methods of sort.Interface to []int32, sorting in increasing order.
func (Int32Slice) Len ¶
func (s Int32Slice) Len() int
func (Int32Slice) Less ¶
func (s Int32Slice) Less(i, j int) bool
func (Int32Slice) Sort ¶
func (s Int32Slice) Sort()
Sort is a convenience method.
func (Int32Slice) Swap ¶
func (s Int32Slice) Swap(i, j int)
type Int64Slice ¶
type Int64Slice []int64
Int64Slice attaches the methods of sort.Interface to []int64, sorting in increasing order.
func (Int64Slice) Len ¶
func (s Int64Slice) Len() int
func (Int64Slice) Less ¶
func (s Int64Slice) Less(i, j int) bool
func (Int64Slice) Sort ¶
func (s Int64Slice) Sort()
Sort is a convenience method.
func (Int64Slice) Swap ¶
func (s Int64Slice) Swap(i, j int)
type Int8Slice ¶
type Int8Slice []int8
Int8Slice attaches the methods of sort.Interface to []int8, sorting in increasing order.
func (Int8Slice) Len ¶
func (Int8Slice) Less ¶
func (Int8Slice) Sort ¶
func (s Int8Slice) Sort()
Sort is a convenience method.
func (Int8Slice) Swap ¶
type RuneSlice ¶
type RuneSlice []rune
RuneSlice attaches the methods of sort.Interface to []rune, sorting in increasing order.
func (RuneSlice) Len ¶
func (RuneSlice) Less ¶
func (RuneSlice) Sort ¶
func (s RuneSlice) Sort()
Sort is a convenience method.
func (RuneSlice) Swap ¶
type Uint16Slice ¶
type Uint16Slice []uint16
Uint16Slice attaches the methods of sort.Interface to []uint16, sorting in increasing order.
func (Uint16Slice) Len ¶
func (s Uint16Slice) Len() int
func (Uint16Slice) Less ¶
func (s Uint16Slice) Less(i, j int) bool
func (Uint16Slice) Sort ¶
func (s Uint16Slice) Sort()
Sort is a convenience method.
func (Uint16Slice) Swap ¶
func (s Uint16Slice) Swap(i, j int)
type Uint32Slice ¶
type Uint32Slice []uint32
Uint32Slice attaches the methods of sort.Interface to []uint32, sorting in increasing order.
func (Uint32Slice) Len ¶
func (s Uint32Slice) Len() int
func (Uint32Slice) Less ¶
func (s Uint32Slice) Less(i, j int) bool
func (Uint32Slice) Sort ¶
func (s Uint32Slice) Sort()
Sort is a convenience method.
func (Uint32Slice) Swap ¶
func (s Uint32Slice) Swap(i, j int)
type Uint64Slice ¶
type Uint64Slice []uint64
Uint64Slice attaches the methods of sort.Interface to []uint64, sorting in increasing order.
func (Uint64Slice) Len ¶
func (s Uint64Slice) Len() int
func (Uint64Slice) Less ¶
func (s Uint64Slice) Less(i, j int) bool
func (Uint64Slice) Sort ¶
func (s Uint64Slice) Sort()
Sort is a convenience method.
func (Uint64Slice) Swap ¶
func (s Uint64Slice) Swap(i, j int)
type UintSlice ¶
type UintSlice []uint
UintSlice attaches the methods of sort.Interface to []uint, sorting in increasing order.
func (UintSlice) Len ¶
func (UintSlice) Less ¶
func (UintSlice) Sort ¶
func (s UintSlice) Sort()
Sort is a convenience method.
func (UintSlice) Swap ¶
Source Files ¶
sortutil.go
- Version
- v0.16.1
- Published
- May 1, 2015
- Platform
- linux/amd64
- Imports
- 1 packages
- Last checked
- 5 hours ago –
Tools for package owners.