collections

package
v0.6.9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 11, 2022 License: BSD-3-Clause Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HeapSort

func HeapSort(data sort.Interface)

堆排序

func InsertionSort

func InsertionSort(data sort.Interface)

插入排序

Types

type Comparable

type Comparable interface {

	// a.CompareTo(b) < 0 表明a < b
	// a.CompareTo(b) > 0 表明a > b
	// a.CompareTo(b) == 0 表明a == b
	CompareTo(Comparable) int
}

丐版java.lang.Comparable

内部实现要符合结合律: (a.CompareTo(b) > 0 && b.CompareTo(c) > 0) implies a.CompareTo(c) > 0

type Float32Slice added in v0.1.21

type Float32Slice []float32

func (Float32Slice) Len added in v0.1.21

func (x Float32Slice) Len() int

func (Float32Slice) Less added in v0.1.21

func (x Float32Slice) Less(i, j int) bool

func (Float32Slice) Swap added in v0.1.21

func (x Float32Slice) Swap(i, j int)

type Float64Slice added in v0.1.21

type Float64Slice []float64

func (Float64Slice) Len added in v0.1.21

func (x Float64Slice) Len() int

func (Float64Slice) Less added in v0.1.21

func (x Float64Slice) Less(i, j int) bool

func (Float64Slice) Swap added in v0.1.21

func (x Float64Slice) Swap(i, j int)

type IDSet

type IDSet []int32

无序整数集合,用于存储少量数据且插入/删除多于查询的场合

func (IDSet) Delete

func (s IDSet) Delete(id int32) IDSet

删除

func (IDSet) Find

func (s IDSet) Find(id int32) int

func (IDSet) Has

func (s IDSet) Has(id int32) bool

func (IDSet) Insert

func (s IDSet) Insert(id int32) IDSet

插入,需要提前判断是否已经存在

func (IDSet) PutIfAbsent

func (s IDSet) PutIfAbsent(id int32) IDSet

type Int16Slice added in v0.1.21

type Int16Slice []uint16

func (Int16Slice) Len added in v0.1.21

func (x Int16Slice) Len() int

func (Int16Slice) Less added in v0.1.21

func (x Int16Slice) Less(i, j int) bool

func (Int16Slice) Swap added in v0.1.21

func (x Int16Slice) Swap(i, j int)

type Int32Slice added in v0.1.21

type Int32Slice []int32

func (Int32Slice) Len added in v0.1.21

func (x Int32Slice) Len() int

func (Int32Slice) Less added in v0.1.21

func (x Int32Slice) Less(i, j int) bool

func (Int32Slice) Swap added in v0.1.21

func (x Int32Slice) Swap(i, j int)

type Int64Slice added in v0.1.21

type Int64Slice []int64

func (Int64Slice) Len added in v0.1.21

func (x Int64Slice) Len() int

func (Int64Slice) Less added in v0.1.21

func (x Int64Slice) Less(i, j int) bool

func (Int64Slice) Swap added in v0.1.21

func (x Int64Slice) Swap(i, j int)

type Int8Slice added in v0.1.21

type Int8Slice []int8

func (Int8Slice) Len added in v0.1.21

func (x Int8Slice) Len() int

func (Int8Slice) Less added in v0.1.21

func (x Int8Slice) Less(i, j int) bool

func (Int8Slice) Swap added in v0.1.21

func (x Int8Slice) Swap(i, j int)

type IntSlice added in v0.1.21

type IntSlice []int

func (IntSlice) Len added in v0.1.21

func (x IntSlice) Len() int

func (IntSlice) Less added in v0.1.21

func (x IntSlice) Less(i, j int) bool

func (IntSlice) Swap added in v0.1.21

func (x IntSlice) Swap(i, j int)

type OrderedIDSet

type OrderedIDSet []int32

用数组实现的有序数字集合,仅用于存储少量数据且查询多过插入/删除的场合

func (OrderedIDSet) Delete

func (s OrderedIDSet) Delete(id int32) OrderedIDSet

删除

func (OrderedIDSet) Find

func (s OrderedIDSet) Find(id int32) int

查询使用二分查找

func (OrderedIDSet) Has

func (s OrderedIDSet) Has(id int32) bool

func (OrderedIDSet) Insert

func (s OrderedIDSet) Insert(id int32) OrderedIDSet

插入后保持有序

type StringSlice added in v0.1.21

type StringSlice []string

func (StringSlice) Len added in v0.1.21

func (x StringSlice) Len() int

func (StringSlice) Less added in v0.1.21

func (x StringSlice) Less(i, j int) bool

func (StringSlice) Swap added in v0.1.21

func (x StringSlice) Swap(i, j int)

type Uint16Slice added in v0.1.21

type Uint16Slice []uint16

func (Uint16Slice) Len added in v0.1.21

func (x Uint16Slice) Len() int

func (Uint16Slice) Less added in v0.1.21

func (x Uint16Slice) Less(i, j int) bool

func (Uint16Slice) Swap added in v0.1.21

func (x Uint16Slice) Swap(i, j int)

type Uint32Slice added in v0.1.21

type Uint32Slice []uint32

func (Uint32Slice) Len added in v0.1.21

func (x Uint32Slice) Len() int

func (Uint32Slice) Less added in v0.1.21

func (x Uint32Slice) Less(i, j int) bool

func (Uint32Slice) Swap added in v0.1.21

func (x Uint32Slice) Swap(i, j int)

type Uint64Slice added in v0.1.21

type Uint64Slice []uint64

func (Uint64Slice) Len added in v0.1.21

func (x Uint64Slice) Len() int

func (Uint64Slice) Less added in v0.1.21

func (x Uint64Slice) Less(i, j int) bool

func (Uint64Slice) Swap added in v0.1.21

func (x Uint64Slice) Swap(i, j int)

type Uint8Slice added in v0.1.21

type Uint8Slice []uint8

func (Uint8Slice) Len added in v0.1.21

func (x Uint8Slice) Len() int

func (Uint8Slice) Less added in v0.1.21

func (x Uint8Slice) Less(i, j int) bool

func (Uint8Slice) Swap added in v0.1.21

func (x Uint8Slice) Swap(i, j int)

type UintSlice added in v0.1.21

type UintSlice []uint

func (UintSlice) Len added in v0.1.21

func (x UintSlice) Len() int

func (UintSlice) Less added in v0.1.21

func (x UintSlice) Less(i, j int) bool

func (UintSlice) Swap added in v0.1.21

func (x UintSlice) Swap(i, j int)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL