Documentation ¶
Index ¶
- func CompareByte(a, b byte) int
- func CompareFloat32(a, b float32) int
- func CompareFloat64(a, b float64) int
- func CompareInt(a, b int) int
- func CompareInt16(a, b int16) int
- func CompareInt32(a, b int32) int
- func CompareInt64(a, b int64) int
- func CompareInt8(a, b int8) int
- func CompareRune(a, b rune) int
- func CompareString(a, b string) int
- func CompareStringFold(a, b string) int
- func CompareUInt(a, b uint) int
- func CompareUInt16(a, b uint16) int
- func CompareUInt32(a, b uint32) int
- func CompareUInt64(a, b uint64) int
- func CompareUInt8(a, b uint8) int
- func CopyMap[K any, V any](dst, src Map[K, V])
- func LessByte(a, b byte) bool
- func LessFloat32(a, b float32) bool
- func LessFloat64(a, b float64) bool
- func LessInt(a, b int) bool
- func LessInt16(a, b int16) bool
- func LessInt32(a, b int32) bool
- func LessInt64(a, b int64) bool
- func LessInt8(a, b int8) bool
- func LessRune(a, b rune) bool
- func LessString(a, b string) bool
- func LessStringFold(a, b string) bool
- func LessUint(a, b uint) bool
- func LessUint16(a, b uint16) bool
- func LessUint32(a, b uint32) bool
- func LessUint64(a, b uint64) bool
- func LessUint8(a, b uint8) bool
- type ArrayList
- func (al *ArrayList[T]) Add(v T)
- func (al *ArrayList[T]) AddCol(ac Collection[T])
- func (al *ArrayList[T]) Adds(vs ...T)
- func (al *ArrayList[T]) Cap() int
- func (al *ArrayList[T]) Clear()
- func (al *ArrayList[T]) Contain(v T) bool
- func (al *ArrayList[T]) ContainCol(ac Collection[T]) bool
- func (al *ArrayList[T]) ContainIter(it Iterator[T]) bool
- func (al *ArrayList[T]) Contains(vs ...T) bool
- func (al *ArrayList[T]) DeleteAt(index int)
- func (al *ArrayList[T]) Each(f func(T))
- func (al *ArrayList[T]) Get(index int) T
- func (al *ArrayList[T]) Head() (v T)
- func (al *ArrayList[T]) Index(v T) int
- func (al *ArrayList[T]) IndexFunc(f func(T) bool) int
- func (al *ArrayList[T]) Insert(index int, v T)
- func (al *ArrayList[T]) InsertCol(index int, ac Collection[T])
- func (al *ArrayList[T]) Inserts(index int, vs ...T)
- func (al *ArrayList[T]) IsEmpty() bool
- func (al *ArrayList[T]) Iterator() Iterator[T]
- func (al *ArrayList[T]) Len() int
- func (al *ArrayList[T]) MarshalJSON() ([]byte, error)
- func (al *ArrayList[T]) Peek() (v T, ok bool)
- func (al *ArrayList[T]) PeekHead() (v T, ok bool)
- func (al *ArrayList[T]) PeekTail() (v T, ok bool)
- func (al *ArrayList[T]) Poll() (T, bool)
- func (al *ArrayList[T]) PollHead() (v T, ok bool)
- func (al *ArrayList[T]) PollTail() (v T, ok bool)
- func (al *ArrayList[T]) Push(v T)
- func (al *ArrayList[T]) PushHead(v T)
- func (al *ArrayList[T]) PushHeadCol(ac Collection[T])
- func (al *ArrayList[T]) PushHeads(vs ...T)
- func (al *ArrayList[T]) PushTail(v T)
- func (al *ArrayList[T]) PushTailCol(ac Collection[T])
- func (al *ArrayList[T]) PushTails(vs ...T)
- func (al *ArrayList[T]) Pushs(vs ...T)
- func (al *ArrayList[T]) Remove(v T)
- func (al *ArrayList[T]) RemoveCol(ac Collection[T])
- func (al *ArrayList[T]) RemoveFunc(f func(T) bool)
- func (al *ArrayList[T]) RemoveIter(it Iterator[T])
- func (al *ArrayList[T]) Removes(vs ...T)
- func (al *ArrayList[T]) Reserve(n int)
- func (al *ArrayList[T]) RetainCol(ac Collection[T])
- func (al *ArrayList[T]) RetainFunc(f func(T) bool)
- func (al *ArrayList[T]) Retains(vs ...T)
- func (al *ArrayList[T]) ReverseEach(f func(T))
- func (al *ArrayList[T]) Set(index int, v T) (ov T)
- func (al *ArrayList[T]) Sort(less Less[T])
- func (al *ArrayList[T]) String() string
- func (al *ArrayList[T]) Swap(i, j int)
- func (al *ArrayList[T]) Tail() (v T)
- func (al *ArrayList[T]) UnmarshalJSON(data []byte) error
- func (al *ArrayList[T]) Values() []T
- type Collection
- type Compare
- type Container
- type Deque
- type Eachable
- type Eachable2
- type HashMap
- func (hm *HashMap[K, V]) Clear()
- func (hm *HashMap[K, V]) Contain(k K) bool
- func (hm *HashMap[K, V]) Contains(ks ...K) bool
- func (hm *HashMap[K, V]) Copy(am Map[K, V])
- func (hm *HashMap[K, V]) Each(f func(k K, v V))
- func (hm *HashMap[K, V]) Entries() []P[K, V]
- func (hm *HashMap[K, V]) Get(key K) (v V, ok bool)
- func (hm *HashMap[K, V]) HashMap() map[K]V
- func (hm *HashMap[K, V]) IsEmpty() bool
- func (hm *HashMap[K, V]) Keys() []K
- func (hm *HashMap[K, V]) Len() int
- func (hm *HashMap[K, V]) MarshalJSON() ([]byte, error)
- func (hm *HashMap[K, V]) MustGet(key K, defaults ...V) V
- func (hm *HashMap[K, V]) Remove(k K) (ov V, ok bool)
- func (hm *HashMap[K, V]) Removes(ks ...K)
- func (hm *HashMap[K, V]) Set(key K, value V) (ov V, ok bool)
- func (hm *HashMap[K, V]) SetEntries(pairs ...P[K, V])
- func (hm *HashMap[K, V]) SetIfAbsent(key K, value V) (ov V, ok bool)
- func (hm *HashMap[K, V]) String() string
- func (hm *HashMap[K, V]) UnmarshalJSON(data []byte) error
- func (hm *HashMap[K, V]) Values() []V
- type HashSet
- func (hs *HashSet[T]) Add(v T)
- func (hs *HashSet[T]) AddCol(ac Collection[T])
- func (hs *HashSet[T]) Adds(vs ...T)
- func (hs *HashSet[T]) Clear()
- func (hs *HashSet[T]) Contain(v T) bool
- func (hs *HashSet[T]) ContainCol(ac Collection[T]) bool
- func (hs *HashSet[T]) ContainIter(it Iterator[T]) bool
- func (hs *HashSet[T]) Contains(vs ...T) bool
- func (hs *HashSet[T]) Difference(a *HashSet[T]) *HashSet[T]
- func (hs *HashSet[T]) Each(f func(T))
- func (hs *HashSet[T]) Intersection(a *HashSet[T]) *HashSet[T]
- func (hs *HashSet[T]) IsEmpty() bool
- func (hs *HashSet[T]) Len() int
- func (hs *HashSet[T]) MarshalJSON() ([]byte, error)
- func (hs *HashSet[T]) Remove(v T)
- func (hs *HashSet[T]) RemoveCol(ac Collection[T])
- func (hs *HashSet[T]) RemoveFunc(f func(T) bool)
- func (hs *HashSet[T]) RemoveIter(it Iterator[T])
- func (hs *HashSet[T]) Removes(vs ...T)
- func (hs *HashSet[T]) RetainCol(ac Collection[T])
- func (hs *HashSet[T]) RetainFunc(f func(T) bool)
- func (hs *HashSet[T]) Retains(vs ...T)
- func (hs *HashSet[T]) String() string
- func (hs *HashSet[T]) UnmarshalJSON(data []byte) error
- func (hs *HashSet[T]) Values() []T
- type Iterable
- type Iterable2
- type IterableMap
- type Iterator
- type Iterator2
- type Less
- type LinkedHashMap
- func (lm *LinkedHashMap[K, V]) Clear()
- func (lm *LinkedHashMap[K, V]) Contain(k K) bool
- func (lm *LinkedHashMap[K, V]) Contains(ks ...K) bool
- func (lm *LinkedHashMap[K, V]) Copy(am Map[K, V])
- func (lm *LinkedHashMap[K, V]) Each(f func(k K, v V))
- func (lm *LinkedHashMap[K, V]) Entries() []P[K, V]
- func (lm *LinkedHashMap[K, V]) Get(key K) (V, bool)
- func (lm *LinkedHashMap[K, V]) Head() *LinkedMapNode[K, V]
- func (lm *LinkedHashMap[K, V]) IsEmpty() bool
- func (lm *LinkedHashMap[K, V]) Items() []*LinkedMapNode[K, V]
- func (lm *LinkedHashMap[K, V]) Iterator() Iterator2[K, V]
- func (lm *LinkedHashMap[K, V]) IteratorOf(k K) Iterator2[K, V]
- func (lm *LinkedHashMap[K, V]) Keys() []K
- func (lm *LinkedHashMap[K, V]) Len() int
- func (lm *LinkedHashMap[K, V]) MarshalJSON() ([]byte, error)
- func (lm *LinkedHashMap[K, V]) MustGet(key K, defaults ...V) V
- func (lm *LinkedHashMap[K, V]) PollHead() *LinkedMapNode[K, V]
- func (lm *LinkedHashMap[K, V]) PollTail() *LinkedMapNode[K, V]
- func (lm *LinkedHashMap[K, V]) Remove(k K) (ov V, ok bool)
- func (lm *LinkedHashMap[K, V]) Removes(ks ...K)
- func (lm *LinkedHashMap[K, V]) ReverseEach(f func(k K, v V))
- func (lm *LinkedHashMap[K, V]) Set(key K, value V) (ov V, ok bool)
- func (lm *LinkedHashMap[K, V]) SetEntries(pairs ...P[K, V])
- func (lm *LinkedHashMap[K, V]) SetIfAbsent(key K, value V) (ov V, ok bool)
- func (lm *LinkedHashMap[K, V]) String() string
- func (lm *LinkedHashMap[K, V]) Tail() *LinkedMapNode[K, V]
- func (lm *LinkedHashMap[K, V]) UnmarshalJSON(data []byte) error
- func (lm *LinkedHashMap[K, V]) Values() []V
- type LinkedHashSet
- func (ls *LinkedHashSet[T]) Add(v T)
- func (ls *LinkedHashSet[T]) AddCol(ac Collection[T])
- func (ls *LinkedHashSet[T]) Adds(vs ...T)
- func (ls *LinkedHashSet[T]) Clear()
- func (ls *LinkedHashSet[T]) Contain(v T) bool
- func (ls *LinkedHashSet[T]) ContainCol(ac Collection[T]) bool
- func (ls *LinkedHashSet[T]) ContainIter(it Iterator[T]) bool
- func (ls *LinkedHashSet[T]) Contains(vs ...T) bool
- func (ls *LinkedHashSet[T]) DeleteAt(index int)
- func (ls *LinkedHashSet[T]) Each(f func(T))
- func (ls *LinkedHashSet[T]) Get(index int) T
- func (ls *LinkedHashSet[T]) Head() (v T)
- func (ls *LinkedHashSet[T]) Index(v T) int
- func (ls *LinkedHashSet[T]) Insert(index int, v T)
- func (ls *LinkedHashSet[T]) InsertCol(index int, ac Collection[T])
- func (ls *LinkedHashSet[T]) Inserts(index int, vs ...T)
- func (ls *LinkedHashSet[T]) IsEmpty() bool
- func (ls *LinkedHashSet[T]) Iterator() Iterator[T]
- func (ls *LinkedHashSet[T]) Len() int
- func (ls *LinkedHashSet[T]) MarshalJSON() ([]byte, error)
- func (ls *LinkedHashSet[T]) Peek() (v T, ok bool)
- func (ls *LinkedHashSet[T]) PeekHead() (v T, ok bool)
- func (ls *LinkedHashSet[T]) PeekTail() (v T, ok bool)
- func (ls *LinkedHashSet[T]) Poll() (T, bool)
- func (ls *LinkedHashSet[T]) PollHead() (v T, ok bool)
- func (ls *LinkedHashSet[T]) PollTail() (v T, ok bool)
- func (ls *LinkedHashSet[T]) Push(v T)
- func (ls *LinkedHashSet[T]) PushHead(v T)
- func (ls *LinkedHashSet[T]) PushHeadCol(ac Collection[T])
- func (ls *LinkedHashSet[T]) PushHeads(vs ...T)
- func (ls *LinkedHashSet[T]) PushTail(v T)
- func (ls *LinkedHashSet[T]) PushTailCol(ac Collection[T])
- func (ls *LinkedHashSet[T]) PushTails(vs ...T)
- func (ls *LinkedHashSet[T]) Pushs(vs ...T)
- func (ls *LinkedHashSet[T]) Remove(v T)
- func (ls *LinkedHashSet[T]) RemoveCol(ac Collection[T])
- func (ls *LinkedHashSet[T]) RemoveFunc(f func(T) bool)
- func (ls *LinkedHashSet[T]) RemoveIter(it Iterator[T])
- func (ls *LinkedHashSet[T]) Removes(vs ...T)
- func (ls *LinkedHashSet[T]) RetainCol(ac Collection[T])
- func (ls *LinkedHashSet[T]) RetainFunc(f func(T) bool)
- func (ls *LinkedHashSet[T]) Retains(vs ...T)
- func (ls *LinkedHashSet[T]) ReverseEach(f func(T))
- func (ls *LinkedHashSet[T]) Set(index int, v T) (ov T)
- func (ls *LinkedHashSet[T]) Sort(less Less[T])
- func (ls *LinkedHashSet[T]) String() string
- func (ls *LinkedHashSet[T]) Swap(i, j int)
- func (ls *LinkedHashSet[T]) Tail() (v T)
- func (ls *LinkedHashSet[T]) UnmarshalJSON(data []byte) error
- func (ls *LinkedHashSet[T]) Values() []T
- type LinkedList
- func (ll *LinkedList[T]) Add(v T)
- func (ll *LinkedList[T]) AddCol(ac Collection[T])
- func (ll *LinkedList[T]) Adds(vs ...T)
- func (ll *LinkedList[T]) Clear()
- func (ll *LinkedList[T]) Contain(v T) bool
- func (ll *LinkedList[T]) ContainCol(ac Collection[T]) bool
- func (ll *LinkedList[T]) ContainIter(it Iterator[T]) bool
- func (ll *LinkedList[T]) Contains(vs ...T) bool
- func (ll *LinkedList[T]) DeleteAt(index int)
- func (ll *LinkedList[T]) Each(f func(T))
- func (ll *LinkedList[T]) Get(index int) T
- func (ll *LinkedList[T]) Head() (v T)
- func (ll *LinkedList[T]) Index(v T) int
- func (ll *LinkedList[T]) IndexFunc(f func(T) bool) int
- func (ll *LinkedList[T]) Insert(index int, v T)
- func (ll *LinkedList[T]) InsertCol(index int, ac Collection[T])
- func (ll *LinkedList[T]) Inserts(index int, vs ...T)
- func (ll *LinkedList[T]) IsEmpty() bool
- func (ll *LinkedList[T]) Iterator() Iterator[T]
- func (ll *LinkedList[T]) LastIndex(v T) int
- func (ll *LinkedList[T]) Len() int
- func (ll *LinkedList[T]) MarshalJSON() ([]byte, error)
- func (ll *LinkedList[T]) Peek() (v T, ok bool)
- func (ll *LinkedList[T]) PeekHead() (v T, ok bool)
- func (ll *LinkedList[T]) PeekTail() (v T, ok bool)
- func (ll *LinkedList[T]) Poll() (T, bool)
- func (ll *LinkedList[T]) PollHead() (v T, ok bool)
- func (ll *LinkedList[T]) PollTail() (v T, ok bool)
- func (ll *LinkedList[T]) Push(v T)
- func (ll *LinkedList[T]) PushHead(v T)
- func (ll *LinkedList[T]) PushHeadCol(ac Collection[T])
- func (ll *LinkedList[T]) PushHeads(vs ...T)
- func (ll *LinkedList[T]) PushTail(v T)
- func (ll *LinkedList[T]) PushTailCol(ac Collection[T])
- func (ll *LinkedList[T]) PushTails(vs ...T)
- func (ll *LinkedList[T]) Pushs(vs ...T)
- func (ll *LinkedList[T]) Remove(v T)
- func (ll *LinkedList[T]) RemoveCol(ac Collection[T])
- func (ll *LinkedList[T]) RemoveFunc(f func(T) bool)
- func (ll *LinkedList[T]) RemoveIter(it Iterator[T])
- func (ll *LinkedList[T]) Removes(vs ...T)
- func (ll *LinkedList[T]) RetainCol(ac Collection[T])
- func (ll *LinkedList[T]) RetainFunc(f func(T) bool)
- func (ll *LinkedList[T]) Retains(vs ...T)
- func (ll *LinkedList[T]) ReverseEach(f func(T))
- func (ll *LinkedList[T]) Set(index int, v T) (ov T)
- func (ll *LinkedList[T]) Sort(less Less[T])
- func (ll *LinkedList[T]) String() string
- func (ll *LinkedList[T]) Swap(i, j int)
- func (ll *LinkedList[T]) Tail() (v T)
- func (ll *LinkedList[T]) UnmarshalJSON(data []byte) error
- func (ll *LinkedList[T]) Values() []T
- type LinkedMapNode
- type List
- type Map
- type P
- type Queue
- type ReverseEachable
- type ReverseEachable2
- type RingBuffer
- func (rb *RingBuffer[T]) Add(v T)
- func (rb *RingBuffer[T]) AddCol(ac Collection[T])
- func (rb *RingBuffer[T]) Adds(vs ...T)
- func (rb *RingBuffer[T]) Cap() int
- func (rb *RingBuffer[T]) Clear()
- func (rb *RingBuffer[T]) Contain(v T) bool
- func (rb *RingBuffer[T]) ContainCol(ac Collection[T]) bool
- func (rb *RingBuffer[T]) ContainIter(it Iterator[T]) bool
- func (rb *RingBuffer[T]) Contains(vs ...T) bool
- func (rb *RingBuffer[T]) DeleteAt(index int)
- func (rb *RingBuffer[T]) Each(f func(T))
- func (rb *RingBuffer[T]) Get(index int) T
- func (rb *RingBuffer[T]) Head() (v T)
- func (rb *RingBuffer[T]) Index(v T) int
- func (rb *RingBuffer[T]) IndexFunc(f func(T) bool) int
- func (rb *RingBuffer[T]) Insert(index int, v T)
- func (rb *RingBuffer[T]) InsertCol(index int, ac Collection[T])
- func (rb *RingBuffer[T]) Inserts(index int, vs ...T)
- func (rb *RingBuffer[T]) IsEmpty() bool
- func (rb *RingBuffer[T]) Iterator() Iterator[T]
- func (rb *RingBuffer[T]) Len() int
- func (rb *RingBuffer[T]) MarshalJSON() ([]byte, error)
- func (rb *RingBuffer[T]) MustPeek() T
- func (rb *RingBuffer[T]) MustPoll() T
- func (rb *RingBuffer[T]) Peek() (v T, ok bool)
- func (rb *RingBuffer[T]) PeekHead() (v T, ok bool)
- func (rb *RingBuffer[T]) PeekTail() (v T, ok bool)
- func (rb *RingBuffer[T]) Poll() (T, bool)
- func (rb *RingBuffer[T]) PollHead() (v T, ok bool)
- func (rb *RingBuffer[T]) PollTail() (v T, ok bool)
- func (rb *RingBuffer[T]) Push(v T)
- func (rb *RingBuffer[T]) PushHead(v T)
- func (rb *RingBuffer[T]) PushHeadCol(ac Collection[T])
- func (rb *RingBuffer[T]) PushHeads(vs ...T)
- func (rb *RingBuffer[T]) PushTail(v T)
- func (rb *RingBuffer[T]) PushTailCol(ac Collection[T])
- func (rb *RingBuffer[T]) PushTails(vs ...T)
- func (rb *RingBuffer[T]) Pushs(vs ...T)
- func (rb *RingBuffer[T]) Remove(v T)
- func (rb *RingBuffer[T]) RemoveCol(ac Collection[T])
- func (rb *RingBuffer[T]) RemoveFunc(f func(T) bool)
- func (rb *RingBuffer[T]) RemoveIter(it Iterator[T])
- func (rb *RingBuffer[T]) Removes(vs ...T)
- func (rb *RingBuffer[T]) RetainCol(ac Collection[T])
- func (rb *RingBuffer[T]) RetainFunc(f func(T) bool)
- func (rb *RingBuffer[T]) Retains(vs ...T)
- func (rb *RingBuffer[T]) ReverseEach(f func(T))
- func (rb *RingBuffer[T]) Set(index int, v T) (ov T)
- func (rb *RingBuffer[T]) Sort(less Less[T])
- func (rb *RingBuffer[T]) String() string
- func (rb *RingBuffer[T]) Swap(i, j int)
- func (rb *RingBuffer[T]) Tail() (v T)
- func (rb *RingBuffer[T]) UnmarshalJSON(data []byte) error
- func (rb *RingBuffer[T]) Values() []T
- type Set
- type Sortable
- type TreeMap
- func (tm *TreeMap[K, V]) Ceiling(key K) *TreeMapNode[K, V]
- func (tm *TreeMap[K, V]) Clear()
- func (tm *TreeMap[K, V]) Contain(k K) bool
- func (tm *TreeMap[K, V]) Contains(ks ...K) bool
- func (tm *TreeMap[K, V]) Copy(am Map[K, V])
- func (tm *TreeMap[K, V]) Each(f func(k K, v V))
- func (tm *TreeMap[K, V]) Entries() []P[K, V]
- func (tm *TreeMap[K, V]) Floor(key K) *TreeMapNode[K, V]
- func (tm *TreeMap[K, V]) Get(key K) (V, bool)
- func (tm *TreeMap[K, V]) Graph(value bool) string
- func (tm *TreeMap[K, V]) Head() *TreeMapNode[K, V]
- func (tm *TreeMap[K, V]) IsEmpty() bool
- func (tm *TreeMap[K, V]) Items() []*TreeMapNode[K, V]
- func (tm *TreeMap[K, V]) Iterator() Iterator2[K, V]
- func (tm *TreeMap[K, V]) Keys() []K
- func (tm *TreeMap[K, V]) Len() int
- func (tm *TreeMap[K, V]) MarshalJSON() ([]byte, error)
- func (tm *TreeMap[K, V]) MustGet(key K, defaults ...V) V
- func (tm *TreeMap[K, V]) PollHead() *TreeMapNode[K, V]
- func (tm *TreeMap[K, V]) PollTail() *TreeMapNode[K, V]
- func (tm *TreeMap[K, V]) Remove(k K) (ov V, ok bool)
- func (tm *TreeMap[K, V]) Removes(ks ...K)
- func (tm *TreeMap[K, V]) ReverseEach(f func(k K, v V))
- func (tm *TreeMap[K, V]) Set(key K, value V) (ov V, ok bool)
- func (tm *TreeMap[K, V]) SetEntries(pairs ...P[K, V])
- func (tm *TreeMap[K, V]) SetIfAbsent(key K, value V) (ov V, ok bool)
- func (tm *TreeMap[K, V]) String() string
- func (tm *TreeMap[K, V]) Tail() *TreeMapNode[K, V]
- func (tm *TreeMap[K, V]) UnmarshalJSON(data []byte) error
- func (tm *TreeMap[K, V]) Values() []V
- type TreeMapNode
- type TreeSet
- func (ts *TreeSet[T]) Add(v T)
- func (ts *TreeSet[T]) AddCol(ac Collection[T])
- func (ts *TreeSet[T]) Adds(vs ...T)
- func (ts *TreeSet[T]) Ceiling(v T) *T
- func (ts *TreeSet[T]) Clear()
- func (ts *TreeSet[T]) Contain(v T) bool
- func (ts *TreeSet[T]) ContainCol(ac Collection[T]) bool
- func (ts *TreeSet[T]) ContainIter(it Iterator[T]) bool
- func (ts *TreeSet[T]) Contains(vs ...T) bool
- func (ts *TreeSet[T]) Each(f func(v T))
- func (ts *TreeSet[T]) Floor(v T) *T
- func (ts *TreeSet[T]) Graph() string
- func (ts *TreeSet[T]) Head() (v T)
- func (ts *TreeSet[T]) IsEmpty() bool
- func (ts *TreeSet[T]) Iterator() Iterator[T]
- func (ts *TreeSet[T]) Len() int
- func (ts *TreeSet[T]) MarshalJSON() ([]byte, error)
- func (ts *TreeSet[T]) PeekHead() (v T, ok bool)
- func (ts *TreeSet[T]) PeekTail() (v T, ok bool)
- func (ts *TreeSet[T]) PollHead() (v T, ok bool)
- func (ts *TreeSet[T]) PollTail() (v T, ok bool)
- func (ts *TreeSet[T]) Remove(v T)
- func (ts *TreeSet[T]) RemoveCol(ac Collection[T])
- func (ts *TreeSet[T]) RemoveFunc(f func(T) bool)
- func (ts *TreeSet[T]) RemoveIter(it Iterator[T])
- func (ts *TreeSet[T]) Removes(vs ...T)
- func (ts *TreeSet[T]) RetainCol(ac Collection[T])
- func (ts *TreeSet[T]) RetainFunc(f func(T) bool)
- func (ts *TreeSet[T]) Retains(vs ...T)
- func (ts *TreeSet[T]) ReverseEach(f func(v T))
- func (ts *TreeSet[T]) String() string
- func (ts *TreeSet[T]) Tail() (v T)
- func (ts *TreeSet[T]) UnmarshalJSON(data []byte) error
- func (ts *TreeSet[T]) Values() []T
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CompareFloat32 ¶
CompareFloat32 provides a basic comparison on float32
func CompareFloat64 ¶
CompareFloat64 provides a basic comparison on float64
func CompareInt16 ¶
CompareInt16 provides a basic comparison on int16
func CompareInt32 ¶
CompareInt32 provides a basic comparison on int32
func CompareInt64 ¶
CompareInt64 provides a basic comparison on int64
func CompareString ¶
CompareString provides a basic comparison on string
func CompareStringFold ¶ added in v1.0.11
CompareStringFold provides a basic case-insensitive comparison on string
func CompareUInt16 ¶
CompareUInt16 provides a basic comparison on uint16
func CompareUInt32 ¶
CompareUInt32 provides a basic comparison on uint32
func CompareUInt64 ¶
CompareUInt64 provides a basic comparison on uint64
func CompareUInt8 ¶
CompareUInt8 provides a basic comparison on uint8
func LessStringFold ¶ added in v1.0.11
LessStringFold string case-insensitive less function
Types ¶
type ArrayList ¶
type ArrayList[T any] struct { // contains filtered or unexported fields }
ArrayList implements a list holdes the item in a array. The zero value for ArrayList is an empty list ready to use.
To iterate over a list (where al is a *ArrayList):
it := al.Iterator() for it.Next() { // do something with it.Value() }
Example ¶
list := NewArrayList[string]() list.Add("a") // ["a"] list.Adds("c", "b") // ["a","c","b"] list.Sort(LessString) // ["a","b","c"] _ = list.Get(0) // "a" //_ = list.Get(100) --> panic _ = list.Contain("a") // true _ = list.Contains("a", "b", "c") // true _ = list.Contains("a", "b", "c", "d") // false list.Swap(0, 1) // ["b","a",c"] list.DeleteAt(2) // ["b","a"] list.DeleteAt(1) // ["b"] list.DeleteAt(0) // [] _ = list.IsEmpty() // true _ = list.Len() // 0 list.Add("a") // ["a"] list.Clear() // [] list.Insert(0, "b") // ["b"] list.Insert(0, "a") // ["a","b"]
Output:
func AsArrayList ¶
AsArrayList returns an initialized list. Example: AsArrayList([]T{1, 2, 3})
func NewArrayList ¶
NewArrayList returns an initialized list. Example: cog.NewArrayList(1, 2, 3)
func (*ArrayList[T]) AddCol ¶ added in v1.0.10
func (al *ArrayList[T]) AddCol(ac Collection[T])
AddCol adds all items of another collection
func (*ArrayList[T]) Adds ¶ added in v1.0.10
func (al *ArrayList[T]) Adds(vs ...T)
Adds adds all items of vs
func (*ArrayList[T]) Contain ¶ added in v1.0.10
Contain Test to see if the list contains the value v
func (*ArrayList[T]) ContainCol ¶ added in v1.0.10
func (al *ArrayList[T]) ContainCol(ac Collection[T]) bool
ContainCol Test to see if the collection contains all items of another collection
func (*ArrayList[T]) ContainIter ¶ added in v1.0.12
ContainIter Test to see if the collection contains all items of iterator 'it'
func (*ArrayList[T]) DeleteAt ¶ added in v1.0.12
DeleteAt remove the item at the specified position in this list.
func (*ArrayList[T]) Each ¶
func (al *ArrayList[T]) Each(f func(T))
Each call f for each item in the list
func (*ArrayList[T]) Get ¶
Get returns the item at the specified position in this list if i < -al.Len() or i >= al.Len(), panic if i < 0, returns al.Get(al.Len() + i)
func (*ArrayList[T]) Index ¶
Index returns the index of the first occurrence of the specified v in this list, or -1 if this list does not contain v.
func (*ArrayList[T]) IndexFunc ¶ added in v1.0.12
IndexFunc returns the index of the first true returned by function f in this list, or -1 if this list does not contain v.
func (*ArrayList[T]) Insert ¶
Insert insert the item v at specified index position shifting the value at that position (if any) and any subsequent elements to the right. Panic if position is bigger than list's size Note: position equal to list's size is valid, i.e. append.
func (*ArrayList[T]) InsertCol ¶ added in v1.0.10
func (al *ArrayList[T]) InsertCol(index int, ac Collection[T])
InsertCol inserts values of another collection ac at specified index position shifting the value at that position (if any) and any subsequent elements to the right. Panic if position is bigger than list's size Note: position equal to list's size is valid, i.e. append.
func (*ArrayList[T]) Inserts ¶ added in v1.0.10
Insert inserts values at specified index position shifting the value at that position (if any) and any subsequent elements to the right. Panic if position is bigger than list's size Note: position equal to list's size is valid, i.e. append.
func (*ArrayList[T]) MarshalJSON ¶
MarshalJSON implements type json.Marshaler interface, so can be called in json.Marshal(al)
func (*ArrayList[T]) Push ¶
func (al *ArrayList[T]) Push(v T)
Push insert item v at the tail of list al.
func (*ArrayList[T]) PushHead ¶
func (al *ArrayList[T]) PushHead(v T)
PushHead inserts the item v at the head of list al.
func (*ArrayList[T]) PushHeadCol ¶ added in v1.0.10
func (al *ArrayList[T]) PushHeadCol(ac Collection[T])
PushHeadCol inserts a copy of another collection at the head of list al. The al and ac may be the same. They must not be nil.
func (*ArrayList[T]) PushHeads ¶ added in v1.0.10
func (al *ArrayList[T]) PushHeads(vs ...T)
PushHeads inserts all items of vs at the head of list al.
func (*ArrayList[T]) PushTail ¶
func (al *ArrayList[T]) PushTail(v T)
PushTail inserts the item v at the tail of list al.
func (*ArrayList[T]) PushTailCol ¶ added in v1.0.10
func (al *ArrayList[T]) PushTailCol(ac Collection[T])
PushTailCol inserts a copy of another collection at the tail of list al. The al and ac may be the same. They must not be nil.
func (*ArrayList[T]) PushTails ¶ added in v1.0.10
func (al *ArrayList[T]) PushTails(vs ...T)
PushTails inserts all items of vs at the tail of list al.
func (*ArrayList[T]) Pushs ¶ added in v1.0.10
func (al *ArrayList[T]) Pushs(vs ...T)
Push inserts all items of vs at the tail of list al.
func (*ArrayList[T]) Remove ¶
func (al *ArrayList[T]) Remove(v T)
Remove remove all items with associated value v of vs
func (*ArrayList[T]) RemoveCol ¶ added in v1.0.10
func (al *ArrayList[T]) RemoveCol(ac Collection[T])
RemoveCol remove all of this collection's elements that are also contained in the specified collection
func (*ArrayList[T]) RemoveFunc ¶ added in v1.0.12
RemoveFunc remove all items that function f returns true
func (*ArrayList[T]) RemoveIter ¶ added in v1.0.12
RemoveIter remove all items in the iterator it
func (*ArrayList[T]) Removes ¶ added in v1.0.10
func (al *ArrayList[T]) Removes(vs ...T)
Removes remove all items in the array vs
func (*ArrayList[T]) RetainCol ¶ added in v1.0.10
func (al *ArrayList[T]) RetainCol(ac Collection[T])
RetainCol Retains only the elements in this collection that are contained in the specified collection.
func (*ArrayList[T]) RetainFunc ¶ added in v1.0.12
RetainFunc Retains all items that function f returns true
func (*ArrayList[T]) Retains ¶ added in v1.0.10
func (al *ArrayList[T]) Retains(vs ...T)
Retains Retains only the elements in this collection that are contained in the argument array vs.
func (*ArrayList[T]) ReverseEach ¶
func (al *ArrayList[T]) ReverseEach(f func(T))
ReverseEach call f for each item in the list with reverse order
func (*ArrayList[T]) Set ¶
Set set the v at the specified index in this list and returns the old value.
func (*ArrayList[T]) Sort ¶
Sort Sorts this list according to the order induced by the specified Comparator.
func (*ArrayList[T]) UnmarshalJSON ¶
UnmarshalJSON implements type json.Unmarshaler interface, so can be called in json.Unmarshal(data, al)
type Collection ¶
type Collection[T any] interface { Container // Add adds item v to the collection Add(v T) // Adds adds items of vs to the collection Adds(vs ...T) // AddCol adds all items of another collection AddCol(ac Collection[T]) // Remove remove all items with associated value v Remove(v T) // Removes remove all items in the array vs Removes(vs ...T) // RemoveCol remove all of this collection's elements that are also contained in the specified collection RemoveCol(ac Collection[T]) // RemoveIter remove all items in the iterator it RemoveIter(it Iterator[T]) // RemoveFunc remove all items that function f returns true RemoveFunc(f func(T) bool) // Contain Test to see if the collection contains item v Contain(v T) bool // Contains Test to see if the collection contains all items of vs Contains(vs ...T) bool // ContainCol Test to see if the collection contains all items of another collection ContainCol(ac Collection[T]) bool // ContainIter Test to see if the collection contains all items of iterator 'it' ContainIter(it Iterator[T]) bool // Retains Retains only the elements in this collection that are contained in the argument array vs. Retains(vs ...T) // RetainCol Retains only the elements in this collection that are contained in the specified collection. RetainCol(ac Collection[T]) // RetainFunc Retains all items that function f returns true RetainFunc(f func(T) bool) // Values returns a slice contains all the items of the collection Values() []T Eachable[T] }
Collection the base collection interface
type Compare ¶
Compare will make type assertion (see CompareString(a,b) for example), which will panic if a or b are not of the asserted type.
Should return a int:
negative , if a < b zero , if a == b positive , if a > b
type Container ¶
type Container interface { // Len returns the length of the container. Len() int // IsEmpty returns true if the container length == 0 IsEmpty() bool // Clear clears the container Clear() }
Container the base container interface
type Deque ¶
type Deque[T any] interface { // PeekHead Retrieves, but does not remove, the head of this queue, or returns (nil, false) if this queue is empty. PeekHead() (T, bool) // PollHead Retrieves and removes the head of this queue, or returns (nil, false) if this queue is empty. PollHead() (T, bool) // PushHead add item v to the head of queue PushHead(v T) // PushHeads adds items of vs to the head of queue PushHeads(vs ...T) // PeekTail Retrieves, but does not remove, the tail of this queue, or returns (nil, false) if this queue is empty. PeekTail() (T, bool) // PollTail Retrieves and removes the tail of this queue, or returns (nil, false) if this queue is empty. PollTail() (T, bool) // PushTail add item v to the tail of queue PushTail(v T) // PushTails adds items of vs to the tail of queue PushTails(vs ...T) }
Deque A linear collection that supports element insertion and removal at both ends.
type Eachable ¶
type Eachable[T any] interface { // Each call f for each item in the collection Each(f func(value T)) }
Eachable a value each interface for collection
type Eachable2 ¶
type Eachable2[K any, V any] interface { // Each call f for each key/value in the collection Each(f func(key K, value V)) }
Eachable2 a key/value each interface for collection
type HashMap ¶
type HashMap[K comparable, V any] struct { // contains filtered or unexported fields }
HashMap hash map type
Example ¶
m := NewHashMap[int, string]() m.Set(1, "x") // 1->x m.Set(2, "b") // 2->b, 1->x (random order) m.Set(1, "a") // 2->b, 1->a (random order) _, _ = m.Get(2) // b, true _, _ = m.Get(3) // nil, false _ = m.Values() // []interface {}{"b", "a"} (random order) _ = m.Keys() // []interface {}{1, 2} (random order) m.Remove(1) // 2->b m.Clear() // empty m.IsEmpty() // true m.Len() // 0
Output:
func AsHashMap ¶
func AsHashMap[K comparable, V any](m map[K]V) *HashMap[K, V]
AsHashMap creates a new HashMap from a map. Example: AsHashMap(map[K]V{"k1": "v1", "k2": "v2"})
func NewHashMap ¶
func NewHashMap[K comparable, V any](kvs ...P[K, V]) *HashMap[K, V]
NewHashMap creates a new HashMap.
func (*HashMap[K, V]) Contains ¶
Contains looks for the given key, and returns true if the key exists in the map.
func (*HashMap[K, V]) Copy ¶ added in v1.0.10
Copy copy items from another map am, override the existing items
func (*HashMap[K, V]) Each ¶
func (hm *HashMap[K, V]) Each(f func(k K, v V))
Each call f for each item(k,v) in the map
func (*HashMap[K, V]) Get ¶
Get looks for the given key, and returns the value associated with it, or nil if not found. The boolean it returns says whether the key is ok in the map.
func (*HashMap[K, V]) HashMap ¶
func (hm *HashMap[K, V]) HashMap() map[K]V
HashMap returns underlying hash map
func (*HashMap[K, V]) MarshalJSON ¶
MarshalJSON implements type json.Marshaler interface, so can be called in json.Marshal(lm)
func (*HashMap[K, V]) MustGet ¶ added in v1.0.12
func (hm *HashMap[K, V]) MustGet(key K, defaults ...V) V
MustGet looks for the given key, and returns the value associated with it. If not found, return defaults[0] or panic if defaults is not supplied.
func (*HashMap[K, V]) Remove ¶ added in v1.0.10
Remove remove the item with key k, and returns what `Get` would have returned on that key prior to the call to `Set`.
func (*HashMap[K, V]) Removes ¶ added in v1.0.10
func (hm *HashMap[K, V]) Removes(ks ...K)
Removes remove all items with key of ks.
func (*HashMap[K, V]) Set ¶
Set sets the paired key-value items, and returns what `Get` would have returned on that key prior to the call to `Set`.
func (*HashMap[K, V]) SetEntries ¶ added in v1.0.12
SetEntries set items from key-value items array, override the existing items
func (*HashMap[K, V]) SetIfAbsent ¶
SetIfAbsent sets the key-value item if the key does not exists in the map, and returns what `Get` would have returned on that key prior to the call to `Set`.
func (*HashMap[K, V]) UnmarshalJSON ¶
UnmarshalJSON implements type json.Unmarshaler interface, so can be called in json.Unmarshal(data, lm)
type HashSet ¶
type HashSet[T comparable] struct { // contains filtered or unexported fields }
HashSet an unordered collection of unique values. The zero value for HashSet is an empty set ready to use. http://en.wikipedia.org/wiki/Set_(computer_science%29)
Example ¶
set := NewHashSet[int]() set.Add(1) // 1 set.Adds(2, 2, 3, 4, 5) // 3, 1, 2, 4, 5 (random order, duplicates ignored) set.Remove(4) // 5, 3, 2, 1 (random order) set.Removes(2, 3) // 1, 5 (random order) set.Contain(1) // true set.Contains(1, 5) // true set.Contains(1, 6) // false _ = set.Values() // []int{5,1} (random order) set.Clear() // empty set.IsEmpty() // true set.Len() // 0
Output:
func NewHashSet ¶
func NewHashSet[T comparable](vs ...T) *HashSet[T]
NewHashSet Create a new hash set
func (*HashSet[T]) AddCol ¶ added in v1.0.10
func (hs *HashSet[T]) AddCol(ac Collection[T])
AddCol adds all items of another collection
func (*HashSet[T]) Adds ¶ added in v1.0.10
func (hs *HashSet[T]) Adds(vs ...T)
Adds Adds all items of vs to the set
func (*HashSet[T]) ContainCol ¶ added in v1.0.10
func (hs *HashSet[T]) ContainCol(ac Collection[T]) bool
ContainCol Test to see if the collection contains all items of another collection
func (*HashSet[T]) ContainIter ¶ added in v1.0.12
ContainIter Test to see if the collection contains all items of iterator 'it'
func (*HashSet[T]) Difference ¶
Difference Find the difference btween two sets
func (*HashSet[T]) Each ¶
func (hs *HashSet[T]) Each(f func(T))
Each Call f for each item in the set
func (*HashSet[T]) Intersection ¶
Intersection Find the intersection of two sets
func (*HashSet[T]) MarshalJSON ¶
MarshalJSON implements type json.Marshaler interface, so can be called in json.Marshal(hs)
func (*HashSet[T]) Remove ¶ added in v1.0.10
func (hs *HashSet[T]) Remove(v T)
Remove remove all items with associated value v of vs
func (*HashSet[T]) RemoveCol ¶ added in v1.0.10
func (hs *HashSet[T]) RemoveCol(ac Collection[T])
RemoveCol remove all of this collection's elements that are also contained in the specified collection
func (*HashSet[T]) RemoveFunc ¶ added in v1.0.12
RemoveFunc remove all items that function f returns true
func (*HashSet[T]) RemoveIter ¶ added in v1.0.12
RemoveIter remove all items in the iterator it
func (*HashSet[T]) Removes ¶ added in v1.0.10
func (hs *HashSet[T]) Removes(vs ...T)
Removes delete items of vs
func (*HashSet[T]) RetainCol ¶ added in v1.0.10
func (hs *HashSet[T]) RetainCol(ac Collection[T])
RetainCol Retains only the elements in this collection that are contained in the specified collection.
func (*HashSet[T]) RetainFunc ¶ added in v1.0.12
RetainFunc Retains all items that function f returns true
func (*HashSet[T]) Retains ¶ added in v1.0.10
func (hs *HashSet[T]) Retains(vs ...T)
Retains Retains only the elements in this collection that are contained in the argument array vs.
func (*HashSet[T]) UnmarshalJSON ¶
UnmarshalJSON implements type json.Unmarshaler interface, so can be called in json.Unmarshal(data, hs)
type Iterable ¶
type Iterable[T any] interface { // Iterator returns a iterator for collection Iterator() Iterator[T] }
Iterable a value iterable interface for collection
type Iterable2 ¶
type Iterable2[K any, V any] interface { // Iterator returns a iterator for collection Iterator() Iterator2[K, V] }
Iterable2 a key/value iterable interface for collection
type IterableMap ¶
type IterableMap[K any, V any] interface { Map[K, V] ReverseEachable2[K, V] Iterable2[K, V] }
IterableMap a iterable map interface
type Iterator ¶
type Iterator[T any] interface { // Prev moves the iterator to the previous item and returns true if there was a previous item in collection. // If Prev() returns true, then previous item's index and value can be retrieved by Index() and Value(). // Modifies the state of the iterator. Prev() bool // Next moves the iterator to the next item and returns true if there was a next item in the collection. // If Next() returns true, then next item's value can be retrieved by Value(). // If Next() was called for the first time, then it will point the iterator to the first item if it exists. // Modifies the state of the iterator. Next() bool // Value returns the current item's value. Value() T // SetValue set the current item's value. SetValue(v T) // Remove remove the current item Remove() // Reset resets the iterator to its initial state (one-before-first/one-after-last) // Call Next()/Prev() to fetch the first/last item if any. Reset() }
Iterator is stateful iterator for collection.
type Iterator2 ¶
type Iterator2[K any, V any] interface { Iterator[V] // Key returns the current item's key. Key() K }
Iterator2 is stateful iterator for Key/Value paire.
type Less ¶
Less will make type assertion (see LessString(a,b) for example), which will panic if a or b are not of the asserted type.
Should return a bool:
true , if a < b false, if a >= b
type LinkedHashMap ¶
type LinkedHashMap[K comparable, V any] struct { // contains filtered or unexported fields }
LinkedHashMap implements an linked map that keeps track of the order in which keys were inserted. The zero value for LinkedHashMap is an empty map ready to use.
To iterate over a linked map (where lm is a *LinkedHashMap):
it := lm.Iterator() for it.Next() { // do something with it.Key(), it.Value() }
Example ¶
m := NewLinkedHashMap[int, string]() m.Set(2, "b") // 2->b m.Set(1, "x") // 2->b, 1->x (insertion-order) m.Set(1, "a") // 2->b, 1->a (insertion-order) _, _ = m.Get(2) // b, true _, _ = m.Get(3) // nil, false _ = m.Values() // []interface {}{"b", "a"} (insertion-order) _ = m.Keys() // []interface {}{2, 1} (insertion-order) m.Remove(1) // 2->b m.Clear() // empty m.IsEmpty() // true m.Len() // 0
Output:
func NewLinkedHashMap ¶
func NewLinkedHashMap[K comparable, V any](kvs ...P[K, V]) *LinkedHashMap[K, V]
NewLinkedHashMap creates a new LinkedHashMap.
Example ¶
// initialize from a list of key-value pairs lm := NewLinkedHashMap([]P[string, any]{ {"country", "United States"}, {"countryCode", "US"}, {"region", "CA"}, {"regionName", "California"}, {"city", "Mountain View"}, {"zip", "94043"}, {"lat", 37.4192}, {"lon", -122.0574}, {"timezone", "America/Los_Angeles"}, {"isp", "Google Cloud"}, {"org", "Google Cloud"}, {"as", "AS15169 Google Inc."}, {"mobile", true}, {"proxy", false}, {"query", "35.192.xx.xxx"}, }...) for it := lm.Iterator(); it.Next(); { fmt.Printf("%-12s: %v\n", it.Key(), it.Value()) }
Output: country : United States countryCode : US region : CA regionName : California city : Mountain View zip : 94043 lat : 37.4192 lon : -122.0574 timezone : America/Los_Angeles isp : Google Cloud org : Google Cloud as : AS15169 Google Inc. mobile : true proxy : false query : 35.192.xx.xxx
func (*LinkedHashMap[K, V]) Contain ¶ added in v1.0.10
func (lm *LinkedHashMap[K, V]) Contain(k K) bool
Contain Test to see if the list contains the key k
func (*LinkedHashMap[K, V]) Contains ¶
func (lm *LinkedHashMap[K, V]) Contains(ks ...K) bool
Contains looks for the given key, and returns true if the key exists in the map.
func (*LinkedHashMap[K, V]) Copy ¶ added in v1.0.10
func (lm *LinkedHashMap[K, V]) Copy(am Map[K, V])
Copy copy items from another map am, override the existing items
func (*LinkedHashMap[K, V]) Each ¶
func (lm *LinkedHashMap[K, V]) Each(f func(k K, v V))
Each call f for each item in the map
func (*LinkedHashMap[K, V]) Entries ¶ added in v1.0.12
func (lm *LinkedHashMap[K, V]) Entries() []P[K, V]
Entries returns the key-value pair slice
func (*LinkedHashMap[K, V]) Get ¶
func (lm *LinkedHashMap[K, V]) Get(key K) (V, bool)
Get looks for the given key, and returns the value associated with it, or nil if not found. The boolean it returns says whether the key is ok in the map.
func (*LinkedHashMap[K, V]) Head ¶
func (lm *LinkedHashMap[K, V]) Head() *LinkedMapNode[K, V]
Head returns the oldest key/value item.
func (*LinkedHashMap[K, V]) IsEmpty ¶
func (lm *LinkedHashMap[K, V]) IsEmpty() bool
IsEmpty returns true if the map has no items
func (*LinkedHashMap[K, V]) Items ¶
func (lm *LinkedHashMap[K, V]) Items() []*LinkedMapNode[K, V]
Items returns the map item slice
func (*LinkedHashMap[K, V]) Iterator ¶
func (lm *LinkedHashMap[K, V]) Iterator() Iterator2[K, V]
Iterator returns a iterator for the map
func (*LinkedHashMap[K, V]) IteratorOf ¶
func (lm *LinkedHashMap[K, V]) IteratorOf(k K) Iterator2[K, V]
IteratorOf returns a iterator at the specified key Returns nil if the map does not contains the key
func (*LinkedHashMap[K, V]) Keys ¶
func (lm *LinkedHashMap[K, V]) Keys() []K
Keys returns the key slice
func (*LinkedHashMap[K, V]) Len ¶
func (lm *LinkedHashMap[K, V]) Len() int
Len returns the length of the linked map.
func (*LinkedHashMap[K, V]) MarshalJSON ¶
func (lm *LinkedHashMap[K, V]) MarshalJSON() ([]byte, error)
MarshalJSON implements type json.Marshaler interface, so can be called in json.Marshal(lm)
func (*LinkedHashMap[K, V]) MustGet ¶ added in v1.0.12
func (lm *LinkedHashMap[K, V]) MustGet(key K, defaults ...V) V
MustGet looks for the given key, and returns the value associated with it. If not found, return defaults[0] or panic if defaults is not supplied.
func (*LinkedHashMap[K, V]) PollHead ¶
func (lm *LinkedHashMap[K, V]) PollHead() *LinkedMapNode[K, V]
PollHead remove the first item of map.
func (*LinkedHashMap[K, V]) PollTail ¶
func (lm *LinkedHashMap[K, V]) PollTail() *LinkedMapNode[K, V]
PollTail remove the last item of map.
func (*LinkedHashMap[K, V]) Remove ¶ added in v1.0.10
func (lm *LinkedHashMap[K, V]) Remove(k K) (ov V, ok bool)
Remove remove the item with key k, and returns what `Get` would have returned on that key prior to the call to `Set`.
func (*LinkedHashMap[K, V]) Removes ¶ added in v1.0.10
func (lm *LinkedHashMap[K, V]) Removes(ks ...K)
Remove remove all items with key of ks.
func (*LinkedHashMap[K, V]) ReverseEach ¶
func (lm *LinkedHashMap[K, V]) ReverseEach(f func(k K, v V))
ReverseEach call f for each item in the map with reverse order
func (*LinkedHashMap[K, V]) Set ¶
func (lm *LinkedHashMap[K, V]) Set(key K, value V) (ov V, ok bool)
Set sets the paired key-value items, and returns what `Get` would have returned on that key prior to the call to `Set`.
func (*LinkedHashMap[K, V]) SetEntries ¶ added in v1.0.12
func (lm *LinkedHashMap[K, V]) SetEntries(pairs ...P[K, V])
SetEntries set items from key-value items array, override the existing items
func (*LinkedHashMap[K, V]) SetIfAbsent ¶
func (lm *LinkedHashMap[K, V]) SetIfAbsent(key K, value V) (ov V, ok bool)
SetIfAbsent sets the key-value item if the key does not exists in the map, and returns what `Get` would have returned on that key prior to the call to `Set`. Example: lm.SetIfAbsent("k1", "v1", "k2", "v2")
func (*LinkedHashMap[K, V]) String ¶
func (lm *LinkedHashMap[K, V]) String() string
String print map to string
func (*LinkedHashMap[K, V]) Tail ¶
func (lm *LinkedHashMap[K, V]) Tail() *LinkedMapNode[K, V]
Tail returns the newest key/value item.
func (*LinkedHashMap[K, V]) UnmarshalJSON ¶
func (lm *LinkedHashMap[K, V]) UnmarshalJSON(data []byte) error
UnmarshalJSON implements type json.Unmarshaler interface, so can be called in json.Unmarshal(data, lm)
Example ¶
const jsonStream = `{ "country" : "United States", "countryCode" : "US", "region" : "CA", "regionName" : "California", "city" : "Mountain View", "zip" : "94043", "lat" : "37.4192", "lon" : "-122.0574", "timezone" : "America/Los_Angeles", "isp" : "Google Cloud", "org" : "Google Cloud", "as" : "AS15169 Google Inc.", "mobile" : "true", "proxy" : "false", "query" : "35.192.xx.xxx" }` // compare with if using a regular generic map, the unmarshalled result // is a map with unpredictable order of keys var m map[string]any err := json.Unmarshal([]byte(jsonStream), &m) if err != nil { fmt.Println("error:", err) } for key := range m { // fmt.Printf("%-12s: %v\n", key, m[key]) _ = key } // use the LinkedHashMap to Unmarshal from JSON object lm := NewLinkedHashMap[string, string]() err = json.Unmarshal([]byte(jsonStream), lm) if err != nil { fmt.Println("error:", err) } // loop over all key-value pairs, // it is ok to call Set append-modify new key-value pairs, // but not safe to call Delete during iteration. for it := lm.Iterator(); it.Next(); { fmt.Printf("%-12s: %v\n", it.Key(), it.Value()) if it.Key() == "city" { lm.Set("mobile", "false") lm.Set("extra", "42") } }
Output: country : United States countryCode : US region : CA regionName : California city : Mountain View zip : 94043 lat : 37.4192 lon : -122.0574 timezone : America/Los_Angeles isp : Google Cloud org : Google Cloud as : AS15169 Google Inc. mobile : false proxy : false query : 35.192.xx.xxx extra : 42
func (*LinkedHashMap[K, V]) Values ¶
func (lm *LinkedHashMap[K, V]) Values() []V
Values returns the value slice
type LinkedHashSet ¶
type LinkedHashSet[T comparable] struct { // contains filtered or unexported fields }
LinkedHashSet implements a doubly linked set. The zero value for LinkedHashSet is an empty set ready to use. Note that insertion order is not affected if an element is re-inserted into the set. (An element e is reinserted into a set s if s.Add(e) is invoked when s.Contains(e) would return true immediately prior to the invocation.)
To iterate over a set (where ls is a *LinkedHashSet):
it := ls.Iterator() for it.Next() { // do something with it.Value() }
func NewLinkedHashSet ¶
func NewLinkedHashSet[T comparable](vs ...T) *LinkedHashSet[T]
NewLinkedHashSet returns an initialized set. Example: cog.NewLinkedHashSet(1, 2, 3)
Example ¶
set := NewLinkedHashSet[int]() set.Add(5) // 5 set.Adds(4, 4, 3, 2, 1) // 5, 4, 3, 2, 1 (in insertion-order, duplicates ignored) set.Add(4) // 5, 4, 3, 2, 1 (duplicates ignored, insertion-order unchanged) set.Remove(4) // 5, 3, 2, 1 (in insertion-order) set.Removes(2, 3) // 5, 1 (in insertion-order) set.Contains(1) // true set.Contains(1, 5) // true set.Contains(1, 6) // false _ = set.Values() // []int{5, 1} (in insertion-order) set.Clear() // empty set.IsEmpty() // true set.Len() // 0
Output:
func (*LinkedHashSet[T]) Add ¶
func (ls *LinkedHashSet[T]) Add(v T)
Add add the item v. Note: existing item's order will not change.
func (*LinkedHashSet[T]) AddCol ¶ added in v1.0.10
func (ls *LinkedHashSet[T]) AddCol(ac Collection[T])
AddCol adds all items of another collection Note: existing item's order will not change.
func (*LinkedHashSet[T]) Adds ¶ added in v1.0.10
func (ls *LinkedHashSet[T]) Adds(vs ...T)
Adds adds all items of vs. Note: existing item's order will not change.
func (*LinkedHashSet[T]) Contain ¶ added in v1.0.10
func (ls *LinkedHashSet[T]) Contain(v T) bool
Contain Test to see if the list contains the value v
func (*LinkedHashSet[T]) ContainCol ¶ added in v1.0.10
func (ls *LinkedHashSet[T]) ContainCol(ac Collection[T]) bool
ContainCol Test to see if the collection contains all items of another collection
func (*LinkedHashSet[T]) ContainIter ¶ added in v1.0.12
func (ls *LinkedHashSet[T]) ContainIter(it Iterator[T]) bool
ContainIter Test to see if the collection contains all items of iterator 'it'
func (*LinkedHashSet[T]) Contains ¶
func (ls *LinkedHashSet[T]) Contains(vs ...T) bool
Contains Test to see if the collection contains all items of vs
func (*LinkedHashSet[T]) DeleteAt ¶ added in v1.0.12
func (ls *LinkedHashSet[T]) DeleteAt(index int)
DeleteAt removes the element at the specified position in this set.
func (*LinkedHashSet[T]) Each ¶
func (ls *LinkedHashSet[T]) Each(f func(T))
Each call f for each item in the set
func (*LinkedHashSet[T]) Get ¶
func (ls *LinkedHashSet[T]) Get(index int) T
Get returns the element at the specified position in this set if i < -ls.Len() or i >= ls.Len(), panic if i < 0, returns ls.Get(ls.Len() + i)
func (*LinkedHashSet[T]) Head ¶
func (ls *LinkedHashSet[T]) Head() (v T)
Head get the first item of set.
func (*LinkedHashSet[T]) Index ¶
func (ls *LinkedHashSet[T]) Index(v T) int
Index returns the index of the specified v in this set, or -1 if this set does not contain v.
func (*LinkedHashSet[T]) Insert ¶
func (ls *LinkedHashSet[T]) Insert(index int, v T)
Insert insert value v at specified index position shifting the value at that position (if any) and any subsequent elements to the right. Panic if position is bigger than set's size Note: position equal to set's size is valid, i.e. append. Note: existing item's order will not change.
func (*LinkedHashSet[T]) InsertCol ¶ added in v1.0.10
func (ls *LinkedHashSet[T]) InsertCol(index int, ac Collection[T])
InsertCol inserts values of another collection ac at specified index position shifting the value at that position (if any) and any subsequent elements to the right. Panic if position is bigger than list's size Note: position equal to list's size is valid, i.e. append. Note: existing item's order will not change.
func (*LinkedHashSet[T]) Inserts ¶ added in v1.0.10
func (ls *LinkedHashSet[T]) Inserts(index int, vs ...T)
Insert inserts values at specified index position shifting the value at that position (if any) and any subsequent elements to the right. Panic if position is bigger than set's size Note: position equal to set's size is valid, i.e. append. Note: existing item's order will not change.
func (*LinkedHashSet[T]) IsEmpty ¶
func (ls *LinkedHashSet[T]) IsEmpty() bool
IsEmpty returns true if the set length == 0
func (*LinkedHashSet[T]) Iterator ¶
func (ls *LinkedHashSet[T]) Iterator() Iterator[T]
Iterator returns a iterator for the set
func (*LinkedHashSet[T]) Len ¶
func (ls *LinkedHashSet[T]) Len() int
Len returns the length of the set.
func (*LinkedHashSet[T]) MarshalJSON ¶
func (ls *LinkedHashSet[T]) MarshalJSON() ([]byte, error)
MarshalJSON implements type json.Marshaler interface, so can be called in json.Marshal(ls)
func (*LinkedHashSet[T]) Peek ¶
func (ls *LinkedHashSet[T]) Peek() (v T, ok bool)
Peek get the first item of set.
func (*LinkedHashSet[T]) PeekHead ¶
func (ls *LinkedHashSet[T]) PeekHead() (v T, ok bool)
PeekHead get the first item of set.
func (*LinkedHashSet[T]) PeekTail ¶
func (ls *LinkedHashSet[T]) PeekTail() (v T, ok bool)
PeekTail get the last item of set.
func (*LinkedHashSet[T]) Poll ¶
func (ls *LinkedHashSet[T]) Poll() (T, bool)
Poll get and remove the first item of set.
func (*LinkedHashSet[T]) PollHead ¶
func (ls *LinkedHashSet[T]) PollHead() (v T, ok bool)
PollHead remove the first item of set.
func (*LinkedHashSet[T]) PollTail ¶
func (ls *LinkedHashSet[T]) PollTail() (v T, ok bool)
PollTail remove the last item of set.
func (*LinkedHashSet[T]) Push ¶
func (ls *LinkedHashSet[T]) Push(v T)
Push insert the item v at the tail of set al.
func (*LinkedHashSet[T]) PushHead ¶
func (ls *LinkedHashSet[T]) PushHead(v T)
PushHead insert the item v at the head of set ls.
func (*LinkedHashSet[T]) PushHeadCol ¶ added in v1.0.10
func (ls *LinkedHashSet[T]) PushHeadCol(ac Collection[T])
PushHeadCol inserts a copy of another collection at the head of set ls. The ls and ac may be the same. They must not be nil.
func (*LinkedHashSet[T]) PushHeads ¶ added in v1.0.10
func (ls *LinkedHashSet[T]) PushHeads(vs ...T)
PushHeads inserts all items of vs at the head of set ls.
func (*LinkedHashSet[T]) PushTail ¶
func (ls *LinkedHashSet[T]) PushTail(v T)
PushTail insert the item v at the tail of set ls.
func (*LinkedHashSet[T]) PushTailCol ¶ added in v1.0.10
func (ls *LinkedHashSet[T]) PushTailCol(ac Collection[T])
PushTailCol inserts a copy of another collection at the tail of set ls. The ls and ac may be the same. They must not be nil.
func (*LinkedHashSet[T]) PushTails ¶ added in v1.0.10
func (ls *LinkedHashSet[T]) PushTails(vs ...T)
PushTails inserts all items of vs at the tail of set ls.
func (*LinkedHashSet[T]) Pushs ¶ added in v1.0.10
func (ls *LinkedHashSet[T]) Pushs(vs ...T)
Pushs inserts all items of vs at the tail of set al.
func (*LinkedHashSet[T]) Remove ¶
func (ls *LinkedHashSet[T]) Remove(v T)
Remove remove all items with associated value v
func (*LinkedHashSet[T]) RemoveCol ¶ added in v1.0.10
func (ls *LinkedHashSet[T]) RemoveCol(ac Collection[T])
RemoveCol remove all of this collection's elements that are also contained in the specified collection
func (*LinkedHashSet[T]) RemoveFunc ¶ added in v1.0.12
func (ls *LinkedHashSet[T]) RemoveFunc(f func(T) bool)
RemoveFunc remove all items that function f returns true
func (*LinkedHashSet[T]) RemoveIter ¶ added in v1.0.12
func (ls *LinkedHashSet[T]) RemoveIter(it Iterator[T])
RemoveIter remove all items in the iterator it
func (*LinkedHashSet[T]) Removes ¶ added in v1.0.10
func (ls *LinkedHashSet[T]) Removes(vs ...T)
Removes remove all items in the array vs
func (*LinkedHashSet[T]) RetainCol ¶ added in v1.0.10
func (ls *LinkedHashSet[T]) RetainCol(ac Collection[T])
RetainCol Retains only the elements in this collection that are contained in the specified collection.
func (*LinkedHashSet[T]) RetainFunc ¶ added in v1.0.12
func (ls *LinkedHashSet[T]) RetainFunc(f func(T) bool)
RetainFunc Retains all items that function f returns true
func (*LinkedHashSet[T]) Retains ¶ added in v1.0.10
func (ls *LinkedHashSet[T]) Retains(vs ...T)
Retains Retains only the elements in this collection that are contained in the argument array vs.
func (*LinkedHashSet[T]) ReverseEach ¶
func (ls *LinkedHashSet[T]) ReverseEach(f func(T))
ReverseEach call f for each item in the set with reverse order
func (*LinkedHashSet[T]) Set ¶
func (ls *LinkedHashSet[T]) Set(index int, v T) (ov T)
Set set the v at the specified index in this set and returns the old value. Old item at index will be removed.
func (*LinkedHashSet[T]) Sort ¶
func (ls *LinkedHashSet[T]) Sort(less Less[T])
Sort Sorts this set according to the order induced by the specified Comparator.
func (*LinkedHashSet[T]) String ¶
func (ls *LinkedHashSet[T]) String() string
String print list to string
func (*LinkedHashSet[T]) Swap ¶
func (ls *LinkedHashSet[T]) Swap(i, j int)
Swap swaps values of two items at the given index.
func (*LinkedHashSet[T]) Tail ¶
func (ls *LinkedHashSet[T]) Tail() (v T)
Tail get the last item of set.
func (*LinkedHashSet[T]) UnmarshalJSON ¶
func (ls *LinkedHashSet[T]) UnmarshalJSON(data []byte) error
UnmarshalJSON implements type json.Unmarshaler interface, so can be called in json.Unmarshal(data, ls)
func (*LinkedHashSet[T]) Values ¶
func (ls *LinkedHashSet[T]) Values() []T
Values returns a slice contains all the items of the set ls
type LinkedList ¶
type LinkedList[T any] struct { // contains filtered or unexported fields }
LinkedList implements a doubly linked list. The zero value for LinkedList is an empty list ready to use.
To iterate over a list (where ll is a *LinkedList):
it := ll.Iterator() for it.Next() { // do something with it.Value() }
func NewLinkedList ¶
func NewLinkedList[T any](vs ...T) *LinkedList[T]
NewLinkedList returns an initialized list. Example: cog.NewLinkedList(1, 2, 3)
Example ¶
list := NewLinkedList[string]() list.Add("a") // ["a"] list.Adds("c", "b") // ["a","c","b"] list.Sort(LessString) // ["a","b","c"] _ = list.Get(0) // "a" //_ = list.Get(100) --> panic _ = list.Contains("a", "b", "c") // true _ = list.Contains("a", "b", "c", "d") // false list.Swap(0, 1) // ["b","a",c"] list.DeleteAt(2) // ["b","a"] list.DeleteAt(1) // ["b"] list.DeleteAt(0) // [] _ = list.IsEmpty() // true _ = list.Len() // 0 list.Add("a") // ["a"] list.Clear() // [] list.Insert(0, "b") // ["b"] list.Insert(0, "a") // ["a","b"]
Output:
func (*LinkedList[T]) AddCol ¶ added in v1.0.10
func (ll *LinkedList[T]) AddCol(ac Collection[T])
AddCol adds all items of another collection
func (*LinkedList[T]) Adds ¶ added in v1.0.10
func (ll *LinkedList[T]) Adds(vs ...T)
Adds adds all items of vs.
func (*LinkedList[T]) Contain ¶ added in v1.0.10
func (ll *LinkedList[T]) Contain(v T) bool
Contain Test to see if the list contains the value v
func (*LinkedList[T]) ContainCol ¶ added in v1.0.10
func (ll *LinkedList[T]) ContainCol(ac Collection[T]) bool
ContainCol Test to see if the collection contains all items of another collection
func (*LinkedList[T]) ContainIter ¶ added in v1.0.12
func (ll *LinkedList[T]) ContainIter(it Iterator[T]) bool
ContainIter Test to see if the collection contains all items of iterator 'it'
func (*LinkedList[T]) Contains ¶
func (ll *LinkedList[T]) Contains(vs ...T) bool
Contains Test to see if the collection contains all items of vs
func (*LinkedList[T]) DeleteAt ¶ added in v1.0.12
func (ll *LinkedList[T]) DeleteAt(index int)
DeleteAt remove the element at the specified position in this list.
func (*LinkedList[T]) Each ¶
func (ll *LinkedList[T]) Each(f func(T))
Each call f for each item in the list
func (*LinkedList[T]) Get ¶
func (ll *LinkedList[T]) Get(index int) T
Get returns the element at the specified position in this list if i < -ll.Len() or i >= ll.Len(), panic if i < 0, returns ll.Get(ll.Len() + i)
func (*LinkedList[T]) Index ¶
func (ll *LinkedList[T]) Index(v T) int
Index returns the index of the first occurrence of the specified v in this list, or -1 if this list does not contain v.
func (*LinkedList[T]) IndexFunc ¶ added in v1.0.12
func (ll *LinkedList[T]) IndexFunc(f func(T) bool) int
IndexFunc returns the index of the first true returned by function f in this list, or -1 if this list does not contain v.
func (*LinkedList[T]) Insert ¶
func (ll *LinkedList[T]) Insert(index int, v T)
Insert insert value v at specified index position shifting the value at that position (if any) and any subsequent elements to the right. Panic if position is bigger than list's size Note: position equal to list's size is valid, i.e. append.
func (*LinkedList[T]) InsertCol ¶ added in v1.0.10
func (ll *LinkedList[T]) InsertCol(index int, ac Collection[T])
InsertCol inserts values of another collection ac at specified index position shifting the value at that position (if any) and any subsequent elements to the right. Panic if position is bigger than list's size Note: position equal to list's size is valid, i.e. append.
func (*LinkedList[T]) Inserts ¶ added in v1.0.10
func (ll *LinkedList[T]) Inserts(index int, vs ...T)
Inserts inserts values at specified index position shifting the value at that position (if any) and any subsequent elements to the right. Panic if position is bigger than list's size Note: position equal to list's size is valid, i.e. append.
func (*LinkedList[T]) IsEmpty ¶
func (ll *LinkedList[T]) IsEmpty() bool
IsEmpty returns true if the list length == 0
func (*LinkedList[T]) Iterator ¶
func (ll *LinkedList[T]) Iterator() Iterator[T]
Iterator returns a iterator for the list
func (*LinkedList[T]) LastIndex ¶
func (ll *LinkedList[T]) LastIndex(v T) int
LastIndex returns the index of the last occurrence of the specified v in this list, or -1 if this list does not contain v.
func (*LinkedList[T]) MarshalJSON ¶
func (ll *LinkedList[T]) MarshalJSON() ([]byte, error)
MarshalJSON implements type json.Marshaler interface, so can be called in json.Marshal(ll)
func (*LinkedList[T]) Peek ¶
func (ll *LinkedList[T]) Peek() (v T, ok bool)
Peek get the first item of list.
func (*LinkedList[T]) PeekHead ¶
func (ll *LinkedList[T]) PeekHead() (v T, ok bool)
PeekHead get the first item of list.
func (*LinkedList[T]) PeekTail ¶
func (ll *LinkedList[T]) PeekTail() (v T, ok bool)
PeekTail get the last item of list.
func (*LinkedList[T]) Poll ¶
func (ll *LinkedList[T]) Poll() (T, bool)
Poll get and remove the first item of list.
func (*LinkedList[T]) PollHead ¶
func (ll *LinkedList[T]) PollHead() (v T, ok bool)
PollHead remove the first item of list.
func (*LinkedList[T]) PollTail ¶
func (ll *LinkedList[T]) PollTail() (v T, ok bool)
PollTail remove the last item of list.
func (*LinkedList[T]) Push ¶
func (ll *LinkedList[T]) Push(v T)
Push insert the item v at the tail of list al.
func (*LinkedList[T]) PushHead ¶
func (ll *LinkedList[T]) PushHead(v T)
PushHead insert the item v at the head of list ll.
func (*LinkedList[T]) PushHeadCol ¶ added in v1.0.10
func (ll *LinkedList[T]) PushHeadCol(ac Collection[T])
PushHeadCol inserts a copy of another collection at the head of list ll. The ll and ac may be the same. They must not be nil.
func (*LinkedList[T]) PushHeads ¶ added in v1.0.10
func (ll *LinkedList[T]) PushHeads(vs ...T)
PushHeads inserts all items of vs at the head of list ll.
func (*LinkedList[T]) PushTail ¶
func (ll *LinkedList[T]) PushTail(v T)
PushTail insert the item v at the tail of list ll.
func (*LinkedList[T]) PushTailCol ¶ added in v1.0.10
func (ll *LinkedList[T]) PushTailCol(ac Collection[T])
PushTailCol inserts a copy of another collection at the tail of list ll. The ll and ac may be the same. They must not be nil.
func (*LinkedList[T]) PushTails ¶ added in v1.0.10
func (ll *LinkedList[T]) PushTails(vs ...T)
PushTails inserts all items of vs at the tail of list ll.
func (*LinkedList[T]) Pushs ¶ added in v1.0.10
func (ll *LinkedList[T]) Pushs(vs ...T)
Pushs inserts all items of vs at the tail of list al.
func (*LinkedList[T]) Remove ¶
func (ll *LinkedList[T]) Remove(v T)
Remove remove all items with associated value v of vs
func (*LinkedList[T]) RemoveCol ¶ added in v1.0.10
func (ll *LinkedList[T]) RemoveCol(ac Collection[T])
RemoveCol remove all of this collection's elements that are also contained in the specified collection
func (*LinkedList[T]) RemoveFunc ¶ added in v1.0.12
func (ll *LinkedList[T]) RemoveFunc(f func(T) bool)
RemoveFunc remove all items that function f returns true
func (*LinkedList[T]) RemoveIter ¶ added in v1.0.12
func (ll *LinkedList[T]) RemoveIter(it Iterator[T])
RemoveIter remove all items in the iterator it
func (*LinkedList[T]) Removes ¶ added in v1.0.10
func (ll *LinkedList[T]) Removes(vs ...T)
Removes remove all items in the array vs
func (*LinkedList[T]) RetainCol ¶ added in v1.0.10
func (ll *LinkedList[T]) RetainCol(ac Collection[T])
RetainCol Retains only the elements in this collection that are contained in the specified collection.
func (*LinkedList[T]) RetainFunc ¶ added in v1.0.12
func (ll *LinkedList[T]) RetainFunc(f func(T) bool)
RetainFunc Retains all items that function f returns true
func (*LinkedList[T]) Retains ¶ added in v1.0.10
func (ll *LinkedList[T]) Retains(vs ...T)
Retains Retains only the elements in this collection that are contained in the argument array vs.
func (*LinkedList[T]) ReverseEach ¶
func (ll *LinkedList[T]) ReverseEach(f func(T))
ReverseEach call f for each item in the list with reverse order
func (*LinkedList[T]) Set ¶
func (ll *LinkedList[T]) Set(index int, v T) (ov T)
Set set the v at the specified index in this list and returns the old value.
func (*LinkedList[T]) Sort ¶
func (ll *LinkedList[T]) Sort(less Less[T])
Sort Sorts this list according to the order induced by the specified Comparator.
func (*LinkedList[T]) Swap ¶
func (ll *LinkedList[T]) Swap(i, j int)
Swap swaps values of two items at the given index.
func (*LinkedList[T]) UnmarshalJSON ¶
func (ll *LinkedList[T]) UnmarshalJSON(data []byte) error
UnmarshalJSON implements type json.Unmarshaler interface, so can be called in json.Unmarshal(data, ll)
func (*LinkedList[T]) Values ¶
func (ll *LinkedList[T]) Values() []T
Values returns a slice contains all the items of the list ll
type LinkedMapNode ¶
LinkedMapNode is a node of a linked hash map.
func (*LinkedMapNode[K, V]) SetValue ¶
func (ln *LinkedMapNode[K, V]) SetValue(v V)
SetValue sets the value
func (*LinkedMapNode[K, V]) String ¶
func (ln *LinkedMapNode[K, V]) String() string
String print the list item to string
type List ¶
type List[T any] interface { Collection[T] ReverseEachable[T] Iterable[T] // Get returns the value at the specified index in this list. 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. Get(index int) T // Set set the v at the specified index in this list and returns the old value. Set(index int, v T) T // Insert insert item v at specified index position shifting the value at that position (if any) and any subsequent elements to the right. // Does not do anything if position is bigger than list's size // Note: position equal to list's size is valid, i.e. append. Insert(index int, v T) // Insert inserts values at specified index position shifting the value at that position (if any) and any subsequent elements to the right. // Does not do anything if position is bigger than list's size // Note: position equal to list's size is valid, i.e. append. Inserts(index int, vs ...T) // InsertCol inserts values of another collection ac at specified index position shifting the value at that position (if any) and any subsequent elements to the right. // Does not do anything if position is bigger than list's size // Note: position equal to list's size is valid, i.e. append. InsertCol(index int, ac Collection[T]) // Index returns the index of the first occurrence of the specified v in this list, or -1 if this list does not contain v. Index(v T) int // IndexFunc returns the index of the first true returned by function f in this list, or -1 if this list does not contain v. IndexFunc(f func(T) bool) int // DeleteAt remove the item at the specified position in this list DeleteAt(index int) // Swap swaps values of two items at the given index. Swap(i, j int) }
List a doubly linked list interface
type Map ¶
type Map[K any, V any] interface { Container // Get looks for the given key, and returns the value associated with it, // or nil if not found. The boolean it returns says whether the key is ok in the map. Get(key K) (V, bool) // MustGet looks for the given key, and returns the value associated with it. // If not found, return defaults[0] or panic if defaults is not supplied. MustGet(key K, defaults ...V) V // Set sets the paired key-value items, and returns what `Get` would have returned // on that key prior to the call to `Set`. // Example: lm.Set("k1", "v1", "k2", "v2") Set(key K, value V) (ov V, ok bool) // SetIfAbsent sets the key-value item if the key does not exists in the map, // and returns what `Get` would have returned // on that key prior to the call to `Set`. SetIfAbsent(key K, value V) (ov V, ok bool) // SetEntries set items from key-value items array, override the existing items SetEntries(pairs ...P[K, V]) // Copy copy items from another map am, override the existing items Copy(am Map[K, V]) // Remove remove the item with key k, // and returns what `Get` would have returned // on that key prior to the call to `Set`. Remove(k K) (ov V, ok bool) // Removes remove all items with key of ks. Removes(ks ...K) // Contain looks for the given key, and returns true if the key exists in the map. Contain(k K) bool // Contains looks for the given key, and returns true if the key exists in the map. Contains(ks ...K) bool // Keys returns the key slice Keys() []K // Values returns a slice contains all the items of the collection Values() []V // Entries returns the key-value pair slice Entries() []P[K, V] Eachable2[K, V] }
Map map interface
type Queue ¶
type Queue[T any] interface { // Peek Retrieves, but does not remove, the head of this queue, or returns (nil, false) if this queue is empty. Peek() (T, bool) // Poll Retrieves and removes the head of this queue, or returns (nil, false) if this queue is empty. Poll() (T, bool) // Push add item v to the tail of queue Push(v T) // Pushs adds items of vs to the tail of queue Pushs(vs ...T) }
Queue A queue interface
type ReverseEachable ¶
type ReverseEachable[T any] interface { // ReverseEach call f for each item in the collection with reverse order ReverseEach(f func(value T)) }
ReverseEachable a value each interface for collection
type ReverseEachable2 ¶
type ReverseEachable2[K any, V any] interface { // ReverseEach call f for each key/value in the collection with reverse order ReverseEach(f func(key K, value V)) }
ReverseEachable2 a key/value reverse each interface for collection
type RingBuffer ¶
type RingBuffer[T any] struct { // contains filtered or unexported fields }
RingBuffer A fast Golang queue using a ring-buffer, based on the version suggested by Dariusz Górecki. Using this instead of other, simpler, queue implementations (slice+append or linked list) provides substantial memory and time benefits, and fewer GC pauses. The queue implemented here is as fast as it is in part because it is not thread-safe.
func NewRingBuffer ¶
func NewRingBuffer[T any](vs ...T) *RingBuffer[T]
NewRingBuffer constructs and returns a new RingBuffer. Example: cog.NewRingBuffer(1, 2, 3)
func (*RingBuffer[T]) AddCol ¶ added in v1.0.10
func (rb *RingBuffer[T]) AddCol(ac Collection[T])
AddCol adds all items of another collection
func (*RingBuffer[T]) Adds ¶ added in v1.0.10
func (rb *RingBuffer[T]) Adds(vs ...T)
Adds adds all items of vs.
func (*RingBuffer[T]) Cap ¶
func (rb *RingBuffer[T]) Cap() int
Cap returns the capcity of the buffer.
func (*RingBuffer[T]) Contain ¶ added in v1.0.10
func (rb *RingBuffer[T]) Contain(v T) bool
Contain Test to see if the list contains the value v
func (*RingBuffer[T]) ContainCol ¶ added in v1.0.10
func (rb *RingBuffer[T]) ContainCol(ac Collection[T]) bool
ContainCol Test to see if the collection contains all items of another collection
func (*RingBuffer[T]) ContainIter ¶ added in v1.0.12
func (rb *RingBuffer[T]) ContainIter(it Iterator[T]) bool
ContainIter Test to see if the collection contains all items of iterator 'it'
func (*RingBuffer[T]) Contains ¶
func (rb *RingBuffer[T]) Contains(vs ...T) bool
Contains Test to see if the RingBuffer contains the value v
func (*RingBuffer[T]) DeleteAt ¶ added in v1.0.12
func (rb *RingBuffer[T]) DeleteAt(index int)
DeleteAt remove the item at the specified position in this RingBuffer.
func (*RingBuffer[T]) Each ¶
func (rb *RingBuffer[T]) Each(f func(T))
Each call f for each item in the RingBuffer
func (*RingBuffer[T]) Get ¶
func (rb *RingBuffer[T]) Get(index int) T
Get returns the item at the specified position in this RingBuffer if i < -rb.Len() or i >= rb.Len(), panic if i < 0, returns rb.Get(rb.Len() + i)
func (*RingBuffer[T]) Head ¶
func (rb *RingBuffer[T]) Head() (v T)
Head get the first item of RingBuffer.
func (*RingBuffer[T]) Index ¶
func (rb *RingBuffer[T]) Index(v T) int
Index returns the index of the first occurrence of the specified v in this RingBuffer, or -1 if this RingBuffer does not contain v.
func (*RingBuffer[T]) IndexFunc ¶ added in v1.0.12
func (rb *RingBuffer[T]) IndexFunc(f func(T) bool) int
IndexFunc returns the index of the first true returned by function f in this list, or -1 if this list does not contain v.
func (*RingBuffer[T]) Insert ¶
func (rb *RingBuffer[T]) Insert(index int, v T)
Insert insert value v at specified index position shifting the value at that position (if any) and any subsequent elements to the right. Panic if position is bigger than RingBuffer's size Note: position equal to RingBuffer's size is valid, i.e. append.
func (*RingBuffer[T]) InsertCol ¶ added in v1.0.10
func (rb *RingBuffer[T]) InsertCol(index int, ac Collection[T])
InsertCol inserts values of another collection ac at specified index position shifting the value at that position (if any) and any subsequent elements to the right. Panic if position is bigger than RingBuffer's size Note: position equal to RingBuffer's size is valid, i.e. append.
func (*RingBuffer[T]) Inserts ¶ added in v1.0.10
func (rb *RingBuffer[T]) Inserts(index int, vs ...T)
Inserts inserts values at specified index position shifting the value at that position (if any) and any subsequent elements to the right. Panic if position is bigger than RingBuffer's size Note: position equal to RingBuffer's size is valid, i.e. append.
func (*RingBuffer[T]) IsEmpty ¶
func (rb *RingBuffer[T]) IsEmpty() bool
IsEmpty returns true if the container length == 0
func (*RingBuffer[T]) Iterator ¶
func (rb *RingBuffer[T]) Iterator() Iterator[T]
Iterator returns a iterator for the RingBuffer
func (*RingBuffer[T]) Len ¶
func (rb *RingBuffer[T]) Len() int
Len returns the number of elements currently stored in the buffer.
func (*RingBuffer[T]) MarshalJSON ¶
func (rb *RingBuffer[T]) MarshalJSON() ([]byte, error)
MarshalJSON implements type json.Marshaler interface, so can be called in json.Marshal(rb)
func (*RingBuffer[T]) MustPeek ¶
func (rb *RingBuffer[T]) MustPeek() T
MustPeek Retrieves, but does not remove, the head of this queue, panic if this queue is empty.
func (*RingBuffer[T]) MustPoll ¶
func (rb *RingBuffer[T]) MustPoll() T
MustPoll Retrieves and removes the head of this queue, panic if this queue is empty.
func (*RingBuffer[T]) Peek ¶
func (rb *RingBuffer[T]) Peek() (v T, ok bool)
Peek get the first item of RingBuffer.
func (*RingBuffer[T]) PeekHead ¶
func (rb *RingBuffer[T]) PeekHead() (v T, ok bool)
PeekHead get the first item of RingBuffer.
func (*RingBuffer[T]) PeekTail ¶
func (rb *RingBuffer[T]) PeekTail() (v T, ok bool)
PeekTail get the last item of RingBuffer.
func (*RingBuffer[T]) Poll ¶
func (rb *RingBuffer[T]) Poll() (T, bool)
Poll get and remove the first item of RingBuffer.
func (*RingBuffer[T]) PollHead ¶
func (rb *RingBuffer[T]) PollHead() (v T, ok bool)
PollHead get and remove the first item of RingBuffer.
func (*RingBuffer[T]) PollTail ¶
func (rb *RingBuffer[T]) PollTail() (v T, ok bool)
PollTail get and remove the last item of RingBuffer.
func (*RingBuffer[T]) Push ¶
func (rb *RingBuffer[T]) Push(v T)
Push insert item v at the tail of RingBuffer rb.
func (*RingBuffer[T]) PushHead ¶
func (rb *RingBuffer[T]) PushHead(v T)
PushHead insert item v at the head of RingBuffer rb.
func (*RingBuffer[T]) PushHeadCol ¶ added in v1.0.10
func (rb *RingBuffer[T]) PushHeadCol(ac Collection[T])
PushHeadCol inserts a copy of another collection at the head of RingBuffer rb. The rb and ac may be the same. They must not be nil.
func (*RingBuffer[T]) PushHeads ¶ added in v1.0.10
func (rb *RingBuffer[T]) PushHeads(vs ...T)
PushHeads inserts all items of vs at the head of RingBuffer rb.
func (*RingBuffer[T]) PushTail ¶
func (rb *RingBuffer[T]) PushTail(v T)
PushTail insert item v at the tail of RingBuffer rb.
func (*RingBuffer[T]) PushTailCol ¶ added in v1.0.10
func (rb *RingBuffer[T]) PushTailCol(ac Collection[T])
PushTailCol inserts a copy of another collection at the tail of RingBuffer rb. The rb and ac may be the same. They must not be nil.
func (*RingBuffer[T]) PushTails ¶ added in v1.0.10
func (rb *RingBuffer[T]) PushTails(vs ...T)
PushTails inserts all items of vs at the tail of RingBuffer rb.
func (*RingBuffer[T]) Pushs ¶ added in v1.0.10
func (rb *RingBuffer[T]) Pushs(vs ...T)
Pushs inserts all items of vs at the tail of RingBuffer rb.
func (*RingBuffer[T]) Remove ¶
func (rb *RingBuffer[T]) Remove(v T)
Remove remove all items with associated value v of vs
func (*RingBuffer[T]) RemoveCol ¶ added in v1.0.10
func (rb *RingBuffer[T]) RemoveCol(ac Collection[T])
RemoveCol remove all of this collection's elements that are also contained in the specified collection
func (*RingBuffer[T]) RemoveFunc ¶ added in v1.0.12
func (rb *RingBuffer[T]) RemoveFunc(f func(T) bool)
RemoveFunc remove all items that function f returns true
func (*RingBuffer[T]) RemoveIter ¶ added in v1.0.12
func (rb *RingBuffer[T]) RemoveIter(it Iterator[T])
RemoveIter remove all items in the iterator it
func (*RingBuffer[T]) Removes ¶ added in v1.0.10
func (rb *RingBuffer[T]) Removes(vs ...T)
Removes remove all items in the array vs
func (*RingBuffer[T]) RetainCol ¶ added in v1.0.10
func (rb *RingBuffer[T]) RetainCol(ac Collection[T])
RetainCol Retains only the elements in this collection that are contained in the specified collection.
func (*RingBuffer[T]) RetainFunc ¶ added in v1.0.12
func (rb *RingBuffer[T]) RetainFunc(f func(T) bool)
RetainFunc Retains all items that function f returns true
func (*RingBuffer[T]) Retains ¶ added in v1.0.10
func (rb *RingBuffer[T]) Retains(vs ...T)
Retains Retains only the elements in this collection that are contained in the argument array vs.
func (*RingBuffer[T]) ReverseEach ¶
func (rb *RingBuffer[T]) ReverseEach(f func(T))
ReverseEach call f for each item in the RingBuffer with reverse order
func (*RingBuffer[T]) Set ¶
func (rb *RingBuffer[T]) Set(index int, v T) (ov T)
Set set the v at the specified index in this RingBuffer and returns the old value.
func (*RingBuffer[T]) Sort ¶
func (rb *RingBuffer[T]) Sort(less Less[T])
Sort Sorts this RingBuffer according to the order induced by the specified Comparator.
func (*RingBuffer[T]) String ¶
func (rb *RingBuffer[T]) String() string
String print RingBuffer to string
func (*RingBuffer[T]) Swap ¶
func (rb *RingBuffer[T]) Swap(i, j int)
Swap swaps values of two items at the given index.
func (*RingBuffer[T]) Tail ¶
func (rb *RingBuffer[T]) Tail() (v T)
Tail get the last item of RingBuffer.
func (*RingBuffer[T]) UnmarshalJSON ¶
func (rb *RingBuffer[T]) UnmarshalJSON(data []byte) error
UnmarshalJSON implements type json.Unmarshaler interface, so can be called in json.Unmarshal(data, rb)
func (*RingBuffer[T]) Values ¶
func (rb *RingBuffer[T]) Values() []T
Values returns a slice contains all the items of the RingBuffer rb
type Sortable ¶
type Sortable[T any] interface { // Sorts this container according to the order induced by the specified Comparator. Sort(less Less[T]) }
Sortable a value each interface for collection
type TreeMap ¶
TreeMap implements an tree map that keeps the compare order of keys. The zero value for TreeMap is an empty map ready to use.
https://en.wikipedia.org/wiki/Red%E2%80%93black_tree
To iterate over a tree map (where tm is a *TreeMap):
for it := tm.Iterator(); it.Next(); { // do something with it.Key(), it.Value() }
Example ¶
m := NewTreeMap[int, string](CompareInt) m.Set(1, "x") // 1->x m.Set(2, "b") // 1->x, 2->b (in order) m.Set(1, "a") // 1->a, 2->b (in order) _, _ = m.Get(2) // b, true _, _ = m.Get(3) // nil, false _ = m.Values() // []interface {}{"a", "b"} (in order) _ = m.Keys() // []interface {}{1, 2} (in order) m.Remove(1) // 2->b m.Clear() // empty m.IsEmpty() // true m.Len() // 0 // Other: m.Head() // Returns the minimum key and its value from map. m.Tail() // Returns the maximum key and its value from map.
Output:
func NewTreeMap ¶
NewTreeMap creates a new TreeMap. Example: cog.NewTreeMap(cog.CompareString, cog.KV("k1", "v1"), cog.KV("k2", "v2"))
func (*TreeMap[K, V]) Ceiling ¶
func (tm *TreeMap[K, V]) Ceiling(key K) *TreeMapNode[K, V]
Ceiling finds ceiling node of the input key, return the ceiling node or nil if no ceiling is found.
Ceiling node is defined as the smallest node that is larger than or equal to the given node. A ceiling node may not be found, either because the tree is empty, or because all nodes in the tree are smaller than the given node.
key should adhere to the comparator's type assertion, otherwise method panics.
func (*TreeMap[K, V]) Contains ¶
Contains looks for the given key, and returns true if the key exists in the map.
func (*TreeMap[K, V]) Copy ¶ added in v1.0.10
Copy copy items from another map am, override the existing items
func (*TreeMap[K, V]) Each ¶
func (tm *TreeMap[K, V]) Each(f func(k K, v V))
Each call f for each item in the map
func (*TreeMap[K, V]) Floor ¶
func (tm *TreeMap[K, V]) Floor(key K) *TreeMapNode[K, V]
Floor Finds floor node of the input key, return the floor node or nil if no floor is found.
Floor node is defined as the largest node that is smaller than or equal to the given node. A floor node may not be found, either because the tree is empty, or because all nodes in the tree are larger than the given node.
key should adhere to the comparator's type assertion, otherwise method panics.
func (*TreeMap[K, V]) Get ¶
Get looks for the given key, and returns the value associated with it, or nil if not found. The boolean it returns says whether the key is ok in the map.
func (*TreeMap[K, V]) Head ¶
func (tm *TreeMap[K, V]) Head() *TreeMapNode[K, V]
Head returns a pointer to the minimum item.
func (*TreeMap[K, V]) Items ¶
func (tm *TreeMap[K, V]) Items() []*TreeMapNode[K, V]
Items returns the map item slice
func (*TreeMap[K, V]) MarshalJSON ¶
MarshalJSON implements type json.Marshaler interface, so can be called in json.Marshal(tm)
func (*TreeMap[K, V]) MustGet ¶ added in v1.0.12
func (tm *TreeMap[K, V]) MustGet(key K, defaults ...V) V
MustGet looks for the given key, and returns the value associated with it. If not found, return defaults[0] or panic if defaults is not supplied.
func (*TreeMap[K, V]) PollHead ¶
func (tm *TreeMap[K, V]) PollHead() *TreeMapNode[K, V]
PollHead remove the first item of map.
func (*TreeMap[K, V]) PollTail ¶
func (tm *TreeMap[K, V]) PollTail() *TreeMapNode[K, V]
PollTail remove the last item of map.
func (*TreeMap[K, V]) Remove ¶ added in v1.0.10
Remove remove the item with key k, and returns what `Get` would have returned on that key prior to the call to `Set`.
func (*TreeMap[K, V]) Removes ¶ added in v1.0.10
func (tm *TreeMap[K, V]) Removes(ks ...K)
Removes remove all items with key of ks.
func (*TreeMap[K, V]) ReverseEach ¶
func (tm *TreeMap[K, V]) ReverseEach(f func(k K, v V))
ReverseEach call f for each item in the map with reverse order
func (*TreeMap[K, V]) Set ¶
Set sets the paired key-value item, and returns what `Get` would have returned on that key prior to the call to `Set`. key should adhere to the comparator's type assertion, otherwise method panics.
func (*TreeMap[K, V]) SetEntries ¶ added in v1.0.12
SetEntries set items from key-value items array, override the existing items
func (*TreeMap[K, V]) SetIfAbsent ¶
SetIfAbsent sets the key-value item if the key does not exists in the map, and returns true if the tree is changed.
func (*TreeMap[K, V]) Tail ¶
func (tm *TreeMap[K, V]) Tail() *TreeMapNode[K, V]
Tail returns a pointer to the maximum item.
func (*TreeMap[K, V]) UnmarshalJSON ¶
UnmarshalJSON implements type json.Unmarshaler interface, so can be called in json.Unmarshal(data, tm)
type TreeMapNode ¶
TreeMapNode is a node of red-black tree
func (*TreeMapNode[K, V]) SetValue ¶
func (tn *TreeMapNode[K, V]) SetValue(v V)
SetValue sets the value
func (*TreeMapNode[K, V]) String ¶
func (tn *TreeMapNode[K, V]) String() string
String print the key/value node to string
type TreeSet ¶
type TreeSet[T any] struct { // contains filtered or unexported fields }
TreeSet implements an tree set that keeps the compare order of keys. The zero value for TreeSet is an empty set ready to use.
https://en.wikipedia.org/wiki/Red%E2%80%93black_tree
To iterate over a tree set (where ts is a *TreeSet):
for it := ts.Iterator(); it.Next(); { // do something with it.Value() }
func NewTreeSet ¶
NewTreeSet creates a new TreeSet. Example: cog.NewTreeSet(cog.CompareString, "v1", "v2")
Example ¶
set := NewTreeSet(CompareInt) set.Add(1) // 1 set.Adds(2, 2, 3, 4, 5) // 1, 2, 3, 4, 5 (in order, duplicates ignored) set.Remove(4) // 1, 2, 3, 5 (in order) set.Removes(2, 3) // 1, 5 (in order) set.Contain(1) // true set.Contains(1, 5) // true set.Contains(1, 6) // false _ = set.Values() // []int{1,5} (in order) set.Clear() // empty set.IsEmpty() // true set.Len() // 0
Output:
func (*TreeSet[T]) AddCol ¶ added in v1.0.10
func (ts *TreeSet[T]) AddCol(ac Collection[T])
AddCol adds all items of another collection
func (*TreeSet[T]) Adds ¶ added in v1.0.10
func (ts *TreeSet[T]) Adds(vs ...T)
Adds adds all items of vs.
func (*TreeSet[T]) Ceiling ¶
func (ts *TreeSet[T]) Ceiling(v T) *T
Ceiling finds ceiling node of the input key, return the ceiling node's value or nil if no ceiling is found.
Ceiling node is defined as the smallest node that is larger than or equal to the given node. A ceiling node may not be found, either because the tree is empty, or because all nodes in the tree are smaller than the given node.
key should adhere to the comparator's type assertion, otherwise method panics.
func (*TreeSet[T]) ContainCol ¶ added in v1.0.10
func (ts *TreeSet[T]) ContainCol(ac Collection[T]) bool
ContainCol Test to see if the collection contains all items of another collection
func (*TreeSet[T]) ContainIter ¶ added in v1.0.12
ContainIter Test to see if the collection contains all items of iterator 'it'
func (*TreeSet[T]) Each ¶
func (ts *TreeSet[T]) Each(f func(v T))
Each call f for each item in the set
func (*TreeSet[T]) Floor ¶
func (ts *TreeSet[T]) Floor(v T) *T
Floor Finds floor node of the input key, return the floor node's value or nil if no floor is found.
Floor node is defined as the largest node that is smaller than or equal to the given node. A floor node may not be found, either because the tree is empty, or because all nodes in the tree are larger than the given node.
key should adhere to the comparator's type assertion, otherwise method panics.
func (*TreeSet[T]) Head ¶
func (ts *TreeSet[T]) Head() (v T)
Head returns the first item of set ts or nil if the set is empty.
func (*TreeSet[T]) MarshalJSON ¶
MarshalJSON implements type json.Marshaler interface, so can be called in json.Marshal(ts)
func (*TreeSet[T]) Remove ¶ added in v1.0.10
func (ts *TreeSet[T]) Remove(v T)
Remove remove all items with associated value v of vs
func (*TreeSet[T]) RemoveCol ¶ added in v1.0.10
func (ts *TreeSet[T]) RemoveCol(ac Collection[T])
RemoveCol remove all of this collection's elements that are also contained in the specified collection
func (*TreeSet[T]) RemoveFunc ¶ added in v1.0.12
RemoveFunc remove all items that function f returns true
func (*TreeSet[T]) RemoveIter ¶ added in v1.0.12
RemoveIter remove all items in the iterator it
func (*TreeSet[T]) Removes ¶ added in v1.0.10
func (ts *TreeSet[T]) Removes(vs ...T)
Removes remove all items in the array vs
func (*TreeSet[T]) RetainCol ¶ added in v1.0.10
func (ts *TreeSet[T]) RetainCol(ac Collection[T])
RetainCol Retains only the elements in this collection that are contained in the specified collection.
func (*TreeSet[T]) RetainFunc ¶ added in v1.0.12
RetainFunc Retains all items that function f returns true
func (*TreeSet[T]) Retains ¶ added in v1.0.10
func (ts *TreeSet[T]) Retains(vs ...T)
Retains Retains only the elements in this collection that are contained in the argument array vs.
func (*TreeSet[T]) ReverseEach ¶
func (ts *TreeSet[T]) ReverseEach(f func(v T))
ReverseEach call f for each item in the set with reverse order
func (*TreeSet[T]) Tail ¶
func (ts *TreeSet[T]) Tail() (v T)
Tail returns the last item of set ts or nil if the set is empty.
func (*TreeSet[T]) UnmarshalJSON ¶
UnmarshalJSON implements type json.Unmarshaler interface, so can be called in json.Unmarshal(data, ts)
Source Files ¶
- array_list.go
- array_list_iter.go
- collection.go
- compare.go
- hash_map.go
- hash_set.go
- iterator.go
- json.go
- less.go
- linked_hash_map.go
- linked_hash_map_iter.go
- linked_hash_map_node.go
- linked_hash_set.go
- linked_hash_set_iter.go
- linked_hash_set_node.go
- linked_list.go
- linked_list_iter.go
- linked_list_node.go
- red_black_color.go
- ring_buffer.go
- ring_buffer_iter.go
- sorter.go
- tree_map.go
- tree_map_iter.go
- tree_map_node.go
- tree_set.go
- tree_set_iter.go
- tree_set_node.go
- util.go