ds

package
v1.0.7 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2023 License: MIT Imports: 12 Imported by: 5

Documentation

Overview

Package ds Dlist copy from https://github.com/chen3feng/stl4go/blob/master/dlist.go

Package ds queue copy from https://github.com/eapache/queue/blob/master/queue.go

Package ds BuiltinSet copy from https://github.com/chen3feng/stl4go/blob/master/builtin_set.go

Package ds stack copy from https://github.com/chen3feng/stl4go/blob/master/stack.go

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MapEqualCounter added in v1.0.7

func MapEqualCounter[V comparable](c map[V]int, other map[V]int) bool

func MapKeyToSlice added in v1.0.1

func MapKeyToSlice[T comparable, V any](a map[T]V) []T

MapKeyToSlice 提取map的key

func MapValueToSlice added in v1.0.1

func MapValueToSlice[T comparable, V any](a map[T]V) []V

MapValueToSlice 提取map的值

func MapZipSliceToMap added in v1.0.1

func MapZipSliceToMap[T comparable, V any](a []T, b []V) (map[T]V, error)

MapZipSliceToMap 两个slice,一个key,一个value转换为map

func SetToSlice

func SetToSlice[K comparable](u BuiltinSet[K]) []K

SetToSlice convert from set to slice

func SliceAbsoluteEqual

func SliceAbsoluteEqual[T comparable](a []T, b []T) bool

SliceAbsoluteEqual 判断两个slice是否一样,严格按照顺序比较

func SliceBinarySearch added in v1.0.7

func SliceBinarySearch[T ttypes.Ordered](data []T, value T) int

SliceBinarySearch 二分搜索

func SliceConvertToInt added in v1.0.1

func SliceConvertToInt(data interface{}) ([]int, error)

SliceConvertToInt 切片集合统一转换为[]int

func SliceConvertToInt64 added in v1.0.1

func SliceConvertToInt64(data interface{}) ([]int64, error)

SliceConvertToInt64 切片集合统一转换为[]int64

func SliceConvertToString added in v1.0.1

func SliceConvertToString(data interface{}) ([]string, error)

SliceConvertToString 切片集合统一转换为[]string

func SliceCopy

func SliceCopy[T any](data []T, ns ...int) []T

SliceCopy 复制切片

func SliceExclude

func SliceExclude[T comparable](a []T, b T) bool

SliceExclude 判断元素是否不在slice中

func SliceFilter

func SliceFilter[T any](a []T, filter func(i int) bool) []T

SliceFilter 过滤slice

func SliceGroupByCounter added in v1.0.7

func SliceGroupByCounter[V comparable](data []V) map[V]int

SliceGroupByCounter 对元素按照Value进行进行计数

func SliceGroupByHandler added in v1.0.7

func SliceGroupByHandler[K comparable, V any](data []V, getKeyHandler func(int) K) map[K][]V

SliceGroupByHandler 对切片进行分类

func SliceGroupByValue added in v1.0.7

func SliceGroupByValue[V comparable](data []V) map[V][]V

SliceGroupByValue 对切片按照元素进行分类

func SliceGroupIntoSlice added in v1.0.7

func SliceGroupIntoSlice[V ttypes.Ordered](data []V) [][]V

SliceGroupIntoSlice 切片按照元素内容分成不同Slice

func SliceInclude

func SliceInclude[T comparable](a []T, b T) bool

SliceInclude 判断元素是否在slice中

func SliceIndex added in v1.0.1

func SliceIndex[T comparable](a []T, b T) int

SliceIndex 获取元素在切片中的下标,如果不存在返回-1

func SliceIndexOrder added in v1.0.3

func SliceIndexOrder[T ttypes.Ordered](a []T, b T) int

SliceIndexOrder 有序slice的元素搜索

func SliceInsert added in v1.0.3

func SliceInsert[T any](data *[]T, i int, x ...T)

SliceInsert 把元素插入到data的指定位置

func SliceLogicalEqual

func SliceLogicalEqual[T comparable](a []T, b []T) bool

SliceLogicalEqual 判断两个Slice是否逻辑一样,和顺序无关

func SliceMap

func SliceMap[T any](a []T, handler func(i int))

SliceMap 对slice中的元素执行操作

func SliceMax

func SliceMax[T ttypes.Ordered](data []T) T

SliceMax 求数组的最大值

func SliceMaxN added in v1.0.7

func SliceMaxN[T ttypes.Ordered](data []T, n int) []T

SliceMaxN 返回切片中最大N个元素

func SliceMaxNWithOrder added in v1.0.7

func SliceMaxNWithOrder[T ttypes.Ordered](data []T, n int) []T

SliceMaxNWithOrder 按序返回切片中最大的N个元素

func SliceMin

func SliceMin[T ttypes.Ordered](data []T) T

SliceMin 求数组的最小值

func SliceMinN added in v1.0.7

func SliceMinN[T ttypes.Ordered](data []T, n int) []T

SliceMinN 获取切片中最小的N个元素

func SliceMinNWithOrder added in v1.0.7

func SliceMinNWithOrder[T ttypes.Ordered](data []T, n int) []T

SliceMinNWithOrder 有序返回切片中最小的N个元素

func SlicePopBack added in v1.0.3

func SlicePopBack[T any](data *[]T) (T, bool)

SlicePopBack 弹出切片最后一个元素

func SliceRemove added in v1.0.1

func SliceRemove[T comparable](data *[]T, b T)

SliceRemove 原地删除元素

func SliceRemoveIndex added in v1.0.3

func SliceRemoveIndex[T any](data *[]T, i int)

SliceRemoveIndex 删除某个索引位置的切片

func SliceRemoveRange added in v1.0.3

func SliceRemoveRange[T any](data *[]T, i int, j int)

SliceRemoveRange 删除某个范围内的切片

func SliceReplace added in v1.0.1

func SliceReplace[T comparable](data []T, a T, b T)

SliceReplace 原地替换元素

func SliceReverse

func SliceReverse[T any](data []T)

SliceReverse 转置切片

func SliceReverseCopy added in v1.0.1

func SliceReverseCopy[T any](data []T) []T

SliceReverseCopy 转置切片并复制

func SliceShuffle added in v1.0.1

func SliceShuffle[T any](data []T)

SliceShuffle shuffle 切片

func SliceTail added in v1.0.3

func SliceTail[T any](data []T, d ...T) T

SliceTail 获取切片最后一个元素,如果没有则用默认值

func SliceTwoDiff added in v1.0.6

func SliceTwoDiff[T comparable](a []T, b []T) ([]T, []T)

SliceTwoDiff 显示两个切片的区别

func SliceUnique

func SliceUnique[T comparable](data []T) []T

SliceUnique 去重切片

func SliceUnpackInclude added in v1.0.7

func SliceUnpackInclude[T comparable](a T, others ...T) bool

SliceUnpackInclude 判断第一个元素是否在后续元素集合中

func SliceUnpackMax added in v1.0.7

func SliceUnpackMax[T ttypes.Ordered](data ...T) T

SliceUnpackMax 求最大值

func SliceUnpackMin added in v1.0.7

func SliceUnpackMin[T ttypes.Ordered](data ...T) T

SliceUnpackMin 求最小值

func StrHasPrefixInsensitive added in v1.0.7

func StrHasPrefixInsensitive(str string, subStr string) bool

StrHasPrefixInsensitive 判断str是以subStr开始, subStr不关注大小写

func StrHasSuffixInsensitive added in v1.0.7

func StrHasSuffixInsensitive(str string, subStr string) bool

StrHasSuffixInsensitive 判断str是以subStr结尾, subStr不关注大小写

func StrRemoveHead added in v1.0.7

func StrRemoveHead(s string, n int) string

StrRemoveHead 删除str起始n个元素

func StrRemoveTail added in v1.0.7

func StrRemoveTail(s string, n int) string

StrRemoveTail 删除str末尾n个元素

func StrSplitNth added in v1.0.7

func StrSplitNth(str string, sep string, total int, nth int) string

StrSplitNth 字符串分割按照sep分割,约定total个,返回第nth个元素 total == -1表示不关注total元素个数 nth == -1表示返回最后一个元素

Types

type BuiltinSet

type BuiltinSet[K comparable] map[K]struct{}

BuiltinSet is an associative container that contains an unordered set of unique objects of type K.

func NewSet

func NewSet[K comparable]() BuiltinSet[K]

func SetFromSlice

func SetFromSlice[K comparable](ks []K) BuiltinSet[K]

SetFromSlice create a new BuiltinSet object with the initial content from slice.

func SetOf

func SetOf[K comparable](ks ...K) BuiltinSet[K]

SetOf creates a new BuiltinSet object with the initial content from ks.

func (BuiltinSet[K]) Clear

func (s BuiltinSet[K]) Clear()

Clear implements the Container interface.

func (BuiltinSet[K]) Delete

func (s BuiltinSet[K]) Delete(k K)

Delete deletes an element from the set. It returns nothing, so it's faster than Remove.

func (BuiltinSet[K]) Difference

func (s BuiltinSet[K]) Difference(other BuiltinSet[K]) BuiltinSet[K]

Difference returns a new set with elements in the set that are not in other.

func (BuiltinSet[K]) ForEach

func (s BuiltinSet[K]) ForEach(cb func(k K))

ForEach implements the Set interface.

func (BuiltinSet[K]) ForEachIf

func (s BuiltinSet[K]) ForEachIf(cb func(k K) bool)

ForEachIf implements the Container interface.

func (BuiltinSet[K]) Has

func (s BuiltinSet[K]) Has(k K) bool

Has implements the Set interface.

func (BuiltinSet[K]) Insert

func (s BuiltinSet[K]) Insert(k K) bool

Insert implements the Set interface.

func (BuiltinSet[K]) InsertN

func (s BuiltinSet[K]) InsertN(ks ...K) int

InsertN implements the Set interface.

func (BuiltinSet[K]) Intersection

func (s BuiltinSet[K]) Intersection(other BuiltinSet[K]) BuiltinSet[K]

Intersection returns a new set with elements common to the set and other.

func (BuiltinSet[K]) IsDisjointOf

func (s BuiltinSet[K]) IsDisjointOf(other BuiltinSet[K]) bool

IsDisjointOf return True if the set has no elements in common with other. Sets are disjoint if and only if their intersection is the empty set.

func (BuiltinSet[K]) IsEmpty

func (s BuiltinSet[K]) IsEmpty() bool

IsEmpty implements the Container interface.

func (BuiltinSet[K]) IsSubsetOf

func (s BuiltinSet[K]) IsSubsetOf(other BuiltinSet[K]) bool

IsSubsetOf tests whether every element in the set is in other.

func (BuiltinSet[K]) IsSupersetOf

func (s BuiltinSet[K]) IsSupersetOf(other BuiltinSet[K]) bool

IsSupersetOf tests whether every element in other is in the set.

func (BuiltinSet[K]) Keys

func (s BuiltinSet[K]) Keys() []K

Keys return a copy of all keys as a slice.

func (BuiltinSet[K]) Len

func (s BuiltinSet[K]) Len() int

Len implements the Container interface.

func (BuiltinSet[K]) Remove

func (s BuiltinSet[K]) Remove(k K) bool

Remove implements the Set interface.

func (BuiltinSet[K]) RemoveN

func (s BuiltinSet[K]) RemoveN(ks ...K) int

RemoveN implements the Set interface.

func (BuiltinSet[K]) String

func (s BuiltinSet[K]) String() string

String implements the fmt.Stringer interface.

func (BuiltinSet[K]) Union

func (s BuiltinSet[K]) Union(other BuiltinSet[K]) BuiltinSet[K]

Union returns a new set with elements from the set and other.

func (BuiltinSet[K]) Update

func (s BuiltinSet[K]) Update(other BuiltinSet[K])

Update adds all elements from other to set. set |= other.

type Iterator added in v1.0.1

type Iterator[T any] interface {
	IsNotEnd() bool // Whether it is point to the end of the range.
	MoveToNext()    // Let it point to the next element.
	Value() T       // Return the value of current element.
}

Iterator is the interface for container's iterator.

type List added in v1.0.1

type List[T any] struct {
	// contains filtered or unexported fields
}

List is a doubly linked list.

func ListOf added in v1.0.1

func ListOf[T any](vs ...T) List[T]

ListOf make a new List from a serial of values.

func (*List[T]) Back added in v1.0.1

func (l *List[T]) Back() T

Back returns the last element in the container.

func (*List[T]) Clear added in v1.0.1

func (l *List[T]) Clear()

Clear cleanup the list.

func (*List[T]) ForEach added in v1.0.1

func (l *List[T]) ForEach(cb func(val T))

ForEach iterate the list, apply each element to the cb callback function.

func (*List[T]) ForEachIf added in v1.0.1

func (l *List[T]) ForEachIf(cb func(val T) bool)

ForEachIf iterate the list, apply each element to the cb callback function, stop if cb returns false.

func (*List[T]) ForEachMutable added in v1.0.1

func (l *List[T]) ForEachMutable(cb func(val *T))

ForEachMutable iterate the list, apply pointer of each element to the cb callback function.

func (*List[T]) ForEachMutableIf added in v1.0.1

func (l *List[T]) ForEachMutableIf(cb func(val *T) bool)

ForEachMutableIf iterate the list, apply pointer of each element to the cb callback function, stop if cb returns false.

func (*List[T]) Front added in v1.0.1

func (l *List[T]) Front() T

Front returns the first element in the container.

func (*List[T]) IsEmpty added in v1.0.1

func (l *List[T]) IsEmpty() bool

IsEmpty return whether the list is empty.

func (*List[T]) Iterate added in v1.0.1

func (l *List[T]) Iterate() MutableIterator[T]

Iterate returns an iterator to the first element in the list.

func (*List[T]) Len added in v1.0.1

func (l *List[T]) Len() int

Len return the length of the list.

func (*List[T]) PopBack added in v1.0.1

func (l *List[T]) PopBack() T

PopBack popups a element from the back of the list.

func (*List[T]) PopFront added in v1.0.1

func (l *List[T]) PopFront() T

PopFront popups a element from the front of the list.

func (*List[T]) PushBack added in v1.0.1

func (l *List[T]) PushBack(val T)

PushBack pushes an element at the back of the list.

func (*List[T]) PushFront added in v1.0.1

func (l *List[T]) PushFront(val T)

PushFront pushes an element at the front of the list.

func (*List[T]) TryPopBack added in v1.0.1

func (l *List[T]) TryPopBack() (T, bool)

TryPopBack tries to popup a element from the back of the list.

func (*List[T]) TryPopFront added in v1.0.1

func (l *List[T]) TryPopFront() (T, bool)

TryPopFront tries to popup a element from the front of the list.

type MapCompareResult added in v1.0.1

type MapCompareResult int
const (
	LeftKeyMiss MapCompareResult = iota + 1
	RightKeyMiss
	AllKeyMiss
	NotEqual
	Equal
	LeftLargeThanRight
	LeftLessThanRight
)

func MapComplexCompareWithKey added in v1.0.1

func MapComplexCompareWithKey[T comparable, V any](a map[T]V, b map[T]V, key T) MapCompareResult

MapComplexCompareWithKey 复杂值的key比较

func MapComplexFullCompare added in v1.0.1

func MapComplexFullCompare[T comparable, V any](a map[T]V, b map[T]V) MapCompareResult

MapComplexFullCompare 复杂值的全部比较

func MapNativeCompareWithKey added in v1.0.1

func MapNativeCompareWithKey[T comparable, V ttypes.Ordered](a map[T]V, b map[T]V, key T) MapCompareResult

MapNativeCompareWithKey 简单值的key比较

func MapNativeFullCompare added in v1.0.1

func MapNativeFullCompare[T comparable, V ttypes.Ordered](a map[T]V, b map[T]V) MapCompareResult

MapNativeFullCompare 简单值的全部比较

type MapLocker

type MapLocker[K comparable, V any] struct {
	// contains filtered or unexported fields
}

MapLocker 带锁的map,用于简单的并发读写场景

func MapNewMapLocker added in v1.0.7

func MapNewMapLocker[K comparable, V any]() *MapLocker[K, V]

func (*MapLocker[K, V]) Contain

func (m *MapLocker[K, V]) Contain(key K) bool

func (*MapLocker[K, V]) Foreach

func (m *MapLocker[K, V]) Foreach(handler func(key K, value V))

func (*MapLocker[K, V]) Get

func (m *MapLocker[K, V]) Get(key K) (V, bool)

func (*MapLocker[K, V]) Set

func (m *MapLocker[K, V]) Set(key K, value V)

type MapRWLocker

type MapRWLocker[K comparable, V any] struct {
	// contains filtered or unexported fields
}

MapRWLocker 简单的读写锁map

func MapNewMapRWLocker added in v1.0.7

func MapNewMapRWLocker[K comparable, V any]() *MapRWLocker[K, V]

func (*MapRWLocker[K, V]) Contain

func (m *MapRWLocker[K, V]) Contain(key K) bool

func (*MapRWLocker[K, V]) Foreach

func (m *MapRWLocker[K, V]) Foreach(handler func(key K, value V))

func (*MapRWLocker[K, V]) Get

func (m *MapRWLocker[K, V]) Get(key K) (V, bool)

func (*MapRWLocker[K, V]) Set

func (m *MapRWLocker[K, V]) Set(key K, value V)

type MutableIterator added in v1.0.1

type MutableIterator[T any] interface {
	Iterator[T]
	Pointer() *T // Return the pointer to the value of current element.
}

MutableIterator is the interface for container's mutable iterator.

type Queue added in v1.0.1

type Queue[T any] struct {
	// contains filtered or unexported fields
}

Queue represents a single instance of the queue data structure.

func NewRing added in v1.0.1

func NewRing[T any]() *Queue[T]

NewRing constructs and returns a new Queue.

func (*Queue[T]) Add added in v1.0.1

func (q *Queue[T]) Add(elem T)

Add puts an element on the end of the queue.

func (*Queue[T]) Get added in v1.0.1

func (q *Queue[T]) Get(i int) T

Get returns the element at index i in the queue. If the index is invalid, the call will panic. This method accepts both positive and negative index values. Index 0 refers to the first element, and index -1 refers to the last.

func (*Queue[T]) Length added in v1.0.1

func (q *Queue[T]) Length() int

Length returns the number of elements currently stored in the queue.

func (*Queue[T]) Peek added in v1.0.1

func (q *Queue[T]) Peek() T

Peek returns the element at the head of the queue. This call panics if the queue is empty.

func (*Queue[T]) Remove added in v1.0.1

func (q *Queue[T]) Remove() T

Remove removes and returns the element from the front of the queue. If the queue is empty, the call will panic.

type SortedMap

type SortedMap[K ttypes.Ordered, V any] struct {
	ReverseOpt bool
	Tuples     []ttypes.Tuple[K, V]
	RawMap     map[K]V
}

SortedMap 有序Map,底层维护了有序切片 如果需要对map进行修改需要执行Rebuild来维护有序行,否则会导致不一致

func MapNewSortedMap added in v1.0.7

func MapNewSortedMap[K ttypes.Ordered, V any](data map[K]V, reverseOpts ...bool) SortedMap[K, V]

func (*SortedMap[K, V]) Rebuild

func (s *SortedMap[K, V]) Rebuild()

Rebuild 重新构建有序Map,一般用于map修改后再次维护tuples的有序行

type Stack added in v1.0.1

type Stack[T any] struct {
	// contains filtered or unexported fields
}

Stack s is a container adaptor that provides the functionality of a stack, a LIFO (last-in, first-out) data structure.

func NewStack added in v1.0.1

func NewStack[T any]() *Stack[T]

NewStack creates a new Stack object.

func NewStackCap added in v1.0.1

func NewStackCap[T any](capacity int) *Stack[T]

NewStackCap creates a new Stack object with the specified capacity.

func (*Stack[T]) Cap added in v1.0.1

func (s *Stack[T]) Cap() int

Cap returns the capacity of the stack.

func (*Stack[T]) Clear added in v1.0.1

func (s *Stack[T]) Clear()

Clear implements the Container interface.

func (*Stack[T]) IsEmpty added in v1.0.1

func (s *Stack[T]) IsEmpty() bool

IsEmpty implements the Container interface.

func (*Stack[T]) Len added in v1.0.1

func (s *Stack[T]) Len() int

Len implements the Container interface.

func (*Stack[T]) Pop added in v1.0.1

func (s *Stack[T]) Pop() T

Pop popups an element from the top of the stack. It must be called when IsEmpty() returned false, otherwise it will panic.

func (*Stack[T]) Push added in v1.0.1

func (s *Stack[T]) Push(t T)

Push pushes the element to the top of the stack.

func (*Stack[T]) Reset added in v1.0.7

func (s *Stack[T]) Reset()

func (*Stack[T]) Top added in v1.0.1

func (s *Stack[T]) Top() T

Top returns the top element in the stack. It must be called when s.IsEmpty() returned false, otherwise it will panic.

func (*Stack[T]) TryPop added in v1.0.1

func (s *Stack[T]) TryPop() (val T, ok bool)

TryPop tries to popup an element from the top of the stack.

type Tuple10E added in v1.0.1

type Tuple10E[A any, B any, C any, D any, E any, F any, G any, H any, I any, J any] struct {
	Tuple9E[A, B, C, D, E, F, G, H, I]
	E10 J
}

func NewTuple10E added in v1.0.1

func NewTuple10E[A any, B any, C any, D any, E any, F any, G any, H any, I any, J any](a A, b B, c C, d D, e E, f F, g G, h H, i I, j J) *Tuple10E[A, B, C, D, E, F, G, H, I, J]

func (*Tuple10E[A, B, C, D, E, F, G, H, I, J]) Unpack added in v1.0.1

func (t *Tuple10E[A, B, C, D, E, F, G, H, I, J]) Unpack() (A, B, C, D, E, F, G, H, I, J)

type Tuple2E added in v1.0.1

type Tuple2E[A any, B any] struct {
	E1 A
	E2 B
}

Tuple2E 自定义两个元素的Tuple

func NewTuple2E added in v1.0.1

func NewTuple2E[A any, B any](a A, b B) *Tuple2E[A, B]

func (*Tuple2E[A, B]) Unpack added in v1.0.1

func (t *Tuple2E[A, B]) Unpack() (A, B)

type Tuple3E added in v1.0.1

type Tuple3E[A any, B any, C any] struct {
	Tuple2E[A, B]
	E3 C
}

func NewTuple3E added in v1.0.1

func NewTuple3E[A any, B any, C any](a A, b B, c C) *Tuple3E[A, B, C]

func (*Tuple3E[A, B, C]) Unpack added in v1.0.1

func (t *Tuple3E[A, B, C]) Unpack() (A, B, C)

type Tuple4E added in v1.0.1

type Tuple4E[A any, B any, C any, D any] struct {
	Tuple3E[A, B, C]
	E4 D
}

func NewTuple4E added in v1.0.1

func NewTuple4E[A any, B any, C any, D any](a A, b B, c C, d D) *Tuple4E[A, B, C, D]

func (*Tuple4E[A, B, C, D]) Unpack added in v1.0.1

func (t *Tuple4E[A, B, C, D]) Unpack() (A, B, C, D)

type Tuple5E added in v1.0.1

type Tuple5E[A any, B any, C any, D any, E any] struct {
	Tuple4E[A, B, C, D]
	E5 E
}

func NewTuple5E added in v1.0.1

func NewTuple5E[A any, B any, C any, D any, E any](a A, b B, c C, d D, e E) *Tuple5E[A, B, C, D, E]

func (*Tuple5E[A, B, C, D, E]) Unpack added in v1.0.1

func (t *Tuple5E[A, B, C, D, E]) Unpack() (A, B, C, D, E)

type Tuple6E added in v1.0.1

type Tuple6E[A any, B any, C any, D any, E any, F any] struct {
	Tuple5E[A, B, C, D, E]
	E6 F
}

func NewTuple6E added in v1.0.1

func NewTuple6E[A any, B any, C any, D any, E any, F any](a A, b B, c C, d D, e E, f F) *Tuple6E[A, B, C, D, E, F]

func (*Tuple6E[A, B, C, D, E, F]) Unpack added in v1.0.1

func (t *Tuple6E[A, B, C, D, E, F]) Unpack() (A, B, C, D, E, F)

type Tuple7E added in v1.0.1

type Tuple7E[A any, B any, C any, D any, E any, F any, G any] struct {
	Tuple6E[A, B, C, D, E, F]
	E7 G
}

func NewTuple7E added in v1.0.1

func NewTuple7E[A any, B any, C any, D any, E any, F any, G any](a A, b B, c C, d D, e E, f F, g G) *Tuple7E[A, B, C, D, E, F, G]

func (*Tuple7E[A, B, C, D, E, F, G]) Unpack added in v1.0.1

func (t *Tuple7E[A, B, C, D, E, F, G]) Unpack() (A, B, C, D, E, F, G)

type Tuple8E added in v1.0.1

type Tuple8E[A any, B any, C any, D any, E any, F any, G any, H any] struct {
	Tuple7E[A, B, C, D, E, F, G]
	E8 H
}

func NewTuple8E added in v1.0.1

func NewTuple8E[A any, B any, C any, D any, E any, F any, G any, H any](a A, b B, c C, d D, e E, f F, g G, h H) *Tuple8E[A, B, C, D, E, F, G, H]

func (*Tuple8E[A, B, C, D, E, F, G, H]) Unpack added in v1.0.1

func (t *Tuple8E[A, B, C, D, E, F, G, H]) Unpack() (A, B, C, D, E, F, G, H)

type Tuple9E added in v1.0.1

type Tuple9E[A any, B any, C any, D any, E any, F any, G any, H any, I any] struct {
	Tuple8E[A, B, C, D, E, F, G, H]
	E9 I
}

func NewTuple9E added in v1.0.1

func NewTuple9E[A any, B any, C any, D any, E any, F any, G any, H any, I any](a A, b B, c C, d D, e E, f F, g G, h H, i I) *Tuple9E[A, B, C, D, E, F, G, H, I]

func (*Tuple9E[A, B, C, D, E, F, G, H, I]) Unpack added in v1.0.1

func (t *Tuple9E[A, B, C, D, E, F, G, H, I]) Unpack() (A, B, C, D, E, F, G, H, I)

type WaitFor added in v1.0.4

type WaitFor[T comparable] struct {
	// contains filtered or unexported fields
}

WaitFor holds the data to add and the time it should be added

type WaitForPriorityQueue added in v1.0.4

type WaitForPriorityQueue[T comparable] struct {
	// contains filtered or unexported fields
}

WaitForPriorityQueue implements a priority queue for WaitFor items.

WaitForPriorityQueue implements heap.Interface. The item occurring next in time (i.e., the item with the smallest readyAt) is at the root (index 0). Peek returns this minimum item at index 0. Pop returns the minimum item after it has been removed from the queue and placed at index Len()-1 by container/heap. Push adds an item at index Len(), and container/heap percolates it into the correct location.

func NewWaitForPriorityQueue added in v1.0.4

func NewWaitForPriorityQueue[T comparable]() *WaitForPriorityQueue[T]

func (*WaitForPriorityQueue[T]) Len added in v1.0.4

func (pq *WaitForPriorityQueue[T]) Len() int

func (*WaitForPriorityQueue[T]) Peek added in v1.0.4

func (pq *WaitForPriorityQueue[T]) Peek() *WaitFor[T]

Peek returns the item at the beginning of the queue, without removing the item or otherwise mutating the queue. It is safe to call directly.

func (*WaitForPriorityQueue[T]) Pop added in v1.0.4

func (pq *WaitForPriorityQueue[T]) Pop() *WaitFor[T]

Pop 弹出优先级队列元素

func (*WaitForPriorityQueue[T]) Push added in v1.0.4

func (pq *WaitForPriorityQueue[T]) Push(entry *WaitFor[T], ignore bool)

Push adds the entry to the priority queue, or updates the readyAt if it already exists in the queue

Jump to

Keyboard shortcuts

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