cog

package
v1.0.9 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2023 License: MIT Imports: 12 Imported by: 2

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func CompareByte

func CompareByte(a, b byte) int

CompareByte provides a basic comparison on byte

func CompareFloat32

func CompareFloat32(a, b float32) int

CompareFloat32 provides a basic comparison on float32

func CompareFloat64

func CompareFloat64(a, b float64) int

CompareFloat64 provides a basic comparison on float64

func CompareInt

func CompareInt(a, b int) int

CompareInt provides a basic comparison on int

func CompareInt16

func CompareInt16(a, b int16) int

CompareInt16 provides a basic comparison on int16

func CompareInt32

func CompareInt32(a, b int32) int

CompareInt32 provides a basic comparison on int32

func CompareInt64

func CompareInt64(a, b int64) int

CompareInt64 provides a basic comparison on int64

func CompareInt8

func CompareInt8(a, b int8) int

CompareInt8 provides a basic comparison on int8

func CompareRune

func CompareRune(a, b rune) int

CompareRune provides a basic comparison on rune

func CompareString

func CompareString(a, b string) int

CompareString provides a fast comparison on strings

func CompareUInt

func CompareUInt(a, b uint) int

CompareUInt provides a basic comparison on uint

func CompareUInt16

func CompareUInt16(a, b uint16) int

CompareUInt16 provides a basic comparison on uint16

func CompareUInt32

func CompareUInt32(a, b uint32) int

CompareUInt32 provides a basic comparison on uint32

func CompareUInt64

func CompareUInt64(a, b uint64) int

CompareUInt64 provides a basic comparison on uint64

func CompareUInt8

func CompareUInt8(a, b uint8) int

CompareUInt8 provides a basic comparison on uint8

func LessByte

func LessByte(a, b byte) bool

LessByte byte less function

func LessFloat32

func LessFloat32(a, b float32) bool

LessFloat32 float32 less function

func LessFloat64

func LessFloat64(a, b float64) bool

LessFloat64 float64 less function

func LessInt

func LessInt(a, b int) bool

LessInt int less function

func LessInt16

func LessInt16(a, b int16) bool

LessInt16 int16 less function

func LessInt32

func LessInt32(a, b int32) bool

LessInt32 int32 less function

func LessInt64

func LessInt64(a, b int64) bool

LessInt64 int64 less function

func LessInt8

func LessInt8(a, b int8) bool

LessInt8 int8 less function

func LessRune

func LessRune(a, b rune) bool

LessRune rune less function

func LessString

func LessString(a, b string) bool

LessString string less function

func LessUint

func LessUint(a, b uint) bool

LessUint uint less function

func LessUint16

func LessUint16(a, b uint16) bool

LessUint16 uint16 less function

func LessUint32

func LessUint32(a, b uint32) bool

LessUint32 uint32 less function

func LessUint64

func LessUint64(a, b uint64) bool

LessUint64 uint64 less function

func LessUint8

func LessUint8(a, b uint8) bool

LessUint8 uint8 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.Add("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.Remove(2)                        // ["b","a"]
list.Remove(1)                        // ["b"]
list.Remove(0)                        // []
list.Remove(0)                        // [] (ignored)
_ = 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

func AsArrayList[T any](vs []T) *ArrayList[T]

AsArrayList returns an initialized list. Example: AsArrayList([]T{1, 2, 3})

func NewArrayList

func NewArrayList[T any](vs ...T) *ArrayList[T]

NewArrayList returns an initialized list. Example: NewArrayList(1, 2, 3)

func (*ArrayList[T]) Add

func (al *ArrayList[T]) Add(vs ...T)

Add adds all items of vs and returns the last added item.

func (*ArrayList[T]) AddAll

func (al *ArrayList[T]) AddAll(ac Collection[T])

AddAll adds all items of another collection

func (*ArrayList[T]) Cap

func (al *ArrayList[T]) Cap() int

Cap returns the capcity of the list.

func (*ArrayList[T]) Clear

func (al *ArrayList[T]) Clear()

Clear clears list al.

func (*ArrayList[T]) Contains

func (al *ArrayList[T]) Contains(vs ...T) bool

Contains Test to see if the list contains the value v

func (*ArrayList[T]) ContainsAll

func (al *ArrayList[T]) ContainsAll(ac Collection[T]) bool

ContainsAll Test to see if the collection contains all items of another collection

func (*ArrayList[T]) Delete

func (al *ArrayList[T]) Delete(vs ...T)

Delete delete all items with associated value v of vs

func (*ArrayList[T]) DeleteAll

func (al *ArrayList[T]) DeleteAll(ac Collection[T])

DeleteAll delete all of this collection's elements that are also contained in the specified collection

func (*ArrayList[T]) DeleteIf

func (al *ArrayList[T]) DeleteIf(f func(T) bool)

DeleteIf delete all items that function f returns true

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

func (al *ArrayList[T]) Get(index int) T

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]) Head

func (al *ArrayList[T]) Head() (v T)

Head get the first item of list.

func (*ArrayList[T]) Index

func (al *ArrayList[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 (*ArrayList[T]) IndexIf

func (al *ArrayList[T]) IndexIf(f func(T) bool) int

IndexIf 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

func (al *ArrayList[T]) Insert(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 list's size Note: position equal to list's size is valid, i.e. append.

func (*ArrayList[T]) InsertAll

func (al *ArrayList[T]) InsertAll(index int, ac Collection[T])

InsertAll 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]) IsEmpty

func (al *ArrayList[T]) IsEmpty() bool

IsEmpty returns true if the list length == 0

func (*ArrayList[T]) Iterator

func (al *ArrayList[T]) Iterator() Iterator[T]

Iterator returns a iterator for the list

func (*ArrayList[T]) Len

func (al *ArrayList[T]) Len() int

Len returns the length of the list.

func (*ArrayList[T]) MarshalJSON

func (al *ArrayList[T]) MarshalJSON() ([]byte, error)

MarshalJSON implements type json.Marshaler interface, so can be called in json.Marshal(al)

func (*ArrayList[T]) Peek

func (al *ArrayList[T]) Peek() (v T, ok bool)

Peek get the first item of list.

func (*ArrayList[T]) PeekHead

func (al *ArrayList[T]) PeekHead() (v T, ok bool)

PeekHead get the first item of list.

func (*ArrayList[T]) PeekTail

func (al *ArrayList[T]) PeekTail() (v T, ok bool)

PeekTail get the last item of list.

func (*ArrayList[T]) Poll

func (al *ArrayList[T]) Poll() (T, bool)

Poll get and remove the first item of list.

func (*ArrayList[T]) PollHead

func (al *ArrayList[T]) PollHead() (v T, ok bool)

PollHead get and remove the first item of list.

func (*ArrayList[T]) PollTail

func (al *ArrayList[T]) PollTail() (v T, ok bool)

PollTail get and remove the last item of list.

func (*ArrayList[T]) Push

func (al *ArrayList[T]) Push(vs ...T)

Push inserts all items of vs at the tail of list al.

func (*ArrayList[T]) PushHead

func (al *ArrayList[T]) PushHead(vs ...T)

PushHead inserts all items of vs at the head of list al.

func (*ArrayList[T]) PushHeadAll

func (al *ArrayList[T]) PushHeadAll(ac Collection[T])

PushHeadAll 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]) PushTail

func (al *ArrayList[T]) PushTail(vs ...T)

PushTail inserts all items of vs at the tail of list al.

func (*ArrayList[T]) PushTailAll

func (al *ArrayList[T]) PushTailAll(ac Collection[T])

PushTailAll 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]) Remove

func (al *ArrayList[T]) Remove(index int)

Remove removes the item at the specified position in this list.

func (*ArrayList[T]) Reserve

func (al *ArrayList[T]) Reserve(n int)

Reserve Increase the capacity of the underlying array.

func (*ArrayList[T]) Retain

func (al *ArrayList[T]) Retain(vs ...T)

Retain Retains only the elements in this collection that are contained in the argument array vs.

func (*ArrayList[T]) RetainAll

func (al *ArrayList[T]) RetainAll(ac Collection[T])

RetainAll Retains only the elements in this collection that are contained in the specified collection.

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

func (al *ArrayList[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 (*ArrayList[T]) Sort

func (al *ArrayList[T]) Sort(less Less[T])

Sort Sorts this list according to the order induced by the specified Comparator.

func (*ArrayList[T]) String

func (al *ArrayList[T]) String() string

String print list to string

func (*ArrayList[T]) Swap

func (al *ArrayList[T]) Swap(i, j int)

Swap swaps values of two items at the given index.

func (*ArrayList[T]) Tail

func (al *ArrayList[T]) Tail() (v T)

Tail get the last item of list.

func (*ArrayList[T]) UnmarshalJSON

func (al *ArrayList[T]) UnmarshalJSON(data []byte) error

UnmarshalJSON implements type json.Unmarshaler interface, so can be called in json.Unmarshal(data, al)

func (*ArrayList[T]) Values

func (al *ArrayList[T]) Values() []T

Values returns a slice contains all the items of the list al

type Collection

type Collection[T any] interface {
	Container

	// Add adds items of vs to the collection
	Add(vs ...T)

	// AddAll adds all items of another collection
	AddAll(ac Collection[T])

	// Delete delete all items of vs
	Delete(vs ...T)

	// DeleteIf delete all items that function f returns true
	DeleteIf(f func(T) bool)

	// DeleteAll delete all of this collection's elements that are also contained in the specified collection
	DeleteAll(ac Collection[T])

	// Contains Test to see if the collection contains all items of vs
	Contains(vs ...T) bool

	// ContainsAll Test to see if the collection contains all items of another collection
	ContainsAll(ac Collection[T]) bool

	// Retain Retains only the elements in this collection that are contained in the argument array vs.
	Retain(vs ...T)

	// RetainAll Retains only the elements in this collection that are contained in the specified collection.
	RetainAll(ac Collection[T])

	// Values returns a slice contains all the items of the collection
	Values() []T

	Eachable[T]
}

Collection the base collection interface

type Compare

type Compare[T any] func(a, b T) int

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 adds items of vs to the head of queue
	PushHead(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 adds items of vs to the tail of queue
	PushTail(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]() // empty
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.Delete(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]) Clear

func (hm *HashMap[K, V]) Clear()

Clear clears the map

func (*HashMap[K, V]) Contains

func (hm *HashMap[K, V]) Contains(ks ...K) bool

Contains looks for the given key, and returns true if the key exists in the map.

func (*HashMap[K, V]) Delete

func (hm *HashMap[K, V]) Delete(ks ...K) (ov V, ok bool)

Delete delete all items with key of ks, and returns what `Get` would have returned on that key prior to the call to `Set`.

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

func (hm *HashMap[K, V]) Get(key K) (v V, ok 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 (*HashMap[K, V]) HashMap

func (hm *HashMap[K, V]) HashMap() map[K]V

HashMap returns underlying hash map

func (*HashMap[K, V]) IsEmpty

func (hm *HashMap[K, V]) IsEmpty() bool

IsEmpty returns true if the map has no items

func (*HashMap[K, V]) Keys

func (hm *HashMap[K, V]) Keys() []K

Keys returns the key slice

func (*HashMap[K, V]) Len

func (hm *HashMap[K, V]) Len() int

Len returns the length of the linked map.

func (*HashMap[K, V]) MarshalJSON

func (hm *HashMap[K, V]) MarshalJSON() ([]byte, error)

MarshalJSON implements type json.Marshaler interface, so can be called in json.Marshal(lm)

func (*HashMap[K, V]) Set

func (hm *HashMap[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 (*HashMap[K, V]) SetAll

func (hm *HashMap[K, V]) SetAll(am Map[K, V])

SetAll set items from another map am, override the existing items

func (*HashMap[K, V]) SetIfAbsent

func (hm *HashMap[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`.

func (*HashMap[K, V]) SetPairs

func (hm *HashMap[K, V]) SetPairs(pairs ...P[K, V])

SetPairs set items from key-value items array, override the existing items

func (*HashMap[K, V]) String

func (hm *HashMap[K, V]) String() string

String print map to string

func (*HashMap[K, V]) UnmarshalJSON

func (hm *HashMap[K, V]) UnmarshalJSON(data []byte) error

UnmarshalJSON implements type json.Unmarshaler interface, so can be called in json.Unmarshal(data, lm)

func (*HashMap[K, V]) Values

func (hm *HashMap[K, V]) Values() []V

Values returns the value slice

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]() // empty
set.Add(1)               // 1
set.Add(2, 2, 3, 4, 5)   // 3, 1, 2, 4, 5 (random order, duplicates ignored)
set.Delete(4)            // 5, 3, 2, 1 (random order)
set.Delete(2, 3)         // 1, 5 (random order)
set.Contains(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]) Add

func (hs *HashSet[T]) Add(vs ...T)

Add Adds all items of vs to the set

func (*HashSet[T]) AddAll

func (hs *HashSet[T]) AddAll(ac Collection[T])

AddAll adds all items of another collection

func (*HashSet[T]) Clear

func (hs *HashSet[T]) Clear()

Clear clears the hash set.

func (*HashSet[T]) Contains

func (hs *HashSet[T]) Contains(vs ...T) bool

Contains Test to see if the collection contains all items of vs

func (*HashSet[T]) ContainsAll

func (hs *HashSet[T]) ContainsAll(ac Collection[T]) bool

ContainsAll Test to see if the collection contains all items of another collection

func (*HashSet[T]) Delete

func (hs *HashSet[T]) Delete(vs ...T)

Delete delete items of vs

func (*HashSet[T]) DeleteAll

func (hs *HashSet[T]) DeleteAll(ac Collection[T])

DeleteAll delete all of this collection's elements that are also contained in the specified collection

func (*HashSet[T]) DeleteIf

func (hs *HashSet[T]) DeleteIf(f func(T) bool)

DeleteIf delete all items that function f returns true

func (*HashSet[T]) Difference

func (hs *HashSet[T]) Difference(a *HashSet[T]) *HashSet[T]

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

func (hs *HashSet[T]) Intersection(a *HashSet[T]) *HashSet[T]

Intersection Find the intersection of two sets

func (*HashSet[T]) IsEmpty

func (hs *HashSet[T]) IsEmpty() bool

IsEmpty returns true if the set's length == 0

func (*HashSet[T]) Len

func (hs *HashSet[T]) Len() int

Len Return the number of items in the set

func (*HashSet[T]) MarshalJSON

func (hs *HashSet[T]) MarshalJSON() ([]byte, error)

MarshalJSON implements type json.Marshaler interface, so can be called in json.Marshal(hs)

func (*HashSet[T]) Retain

func (hs *HashSet[T]) Retain(vs ...T)

Retain Retains only the elements in this collection that are contained in the argument array vs.

func (*HashSet[T]) RetainAll

func (hs *HashSet[T]) RetainAll(ac Collection[T])

RetainAll Retains only the elements in this collection that are contained in the specified collection.

func (*HashSet[T]) String

func (hs *HashSet[T]) String() string

String print the set to string

func (*HashSet[T]) UnmarshalJSON

func (hs *HashSet[T]) UnmarshalJSON(data []byte) error

UnmarshalJSON implements type json.Unmarshaler interface, so can be called in json.Unmarshal(data, hs)

func (*HashSet[T]) Values

func (hs *HashSet[T]) Values() []T

Values returns a slice contains all the items of the set 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

type Less[T any] func(a, b T) bool

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]() // empty (keys are of type int)
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.Delete(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]) Clear

func (lm *LinkedHashMap[K, V]) Clear()

Clear clears the map

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]) Delete

func (lm *LinkedHashMap[K, V]) Delete(ks ...K) (ov V, ok bool)

Delete delete all items with key of ks, and returns what `Get` would have returned on that key prior to the call to `Set`.

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]) 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]) 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]) 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]) SetAll

func (lm *LinkedHashMap[K, V]) SetAll(am Map[K, V])

SetAll set items from another map am, 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]) SetPairs

func (lm *LinkedHashMap[K, V]) SetPairs(pairs ...P[K, V])

SetPairs set items from key-value items array, override the existing items

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: NewLinkedHashSet(1, 2, 3)

Example
set := NewLinkedHashSet[int]() // empty
set.Add(5)                     // 5
set.Add(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.Delete(4)                  // 5, 3, 2, 1 (in insertion-order)
set.Delete(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(vs ...T)

Add adds all items of vs and returns the last added item. Note: existing item's order will not change.

func (*LinkedHashSet[T]) AddAll

func (ls *LinkedHashSet[T]) AddAll(ac Collection[T])

AddAll adds all items of another collection Note: existing item's order will not change.

func (*LinkedHashSet[T]) Clear

func (ls *LinkedHashSet[T]) Clear()

Clear clears set ls.

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]) ContainsAll

func (ls *LinkedHashSet[T]) ContainsAll(ac Collection[T]) bool

ContainsAll Test to see if the collection contains all items of another collection

func (*LinkedHashSet[T]) Delete

func (ls *LinkedHashSet[T]) Delete(vs ...T)

Delete delete all items with associated value v of vs

func (*LinkedHashSet[T]) DeleteAll

func (ls *LinkedHashSet[T]) DeleteAll(ac Collection[T])

DeleteAll delete all of this collection's elements that are also contained in the specified collection

func (*LinkedHashSet[T]) DeleteIf

func (ls *LinkedHashSet[T]) DeleteIf(f func(T) bool)

DeleteIf delete all items that function f returns true

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, 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]) InsertAll

func (ls *LinkedHashSet[T]) InsertAll(index int, ac Collection[T])

InsertAll 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]) 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(vs ...T)

Push inserts all items of vs at the tail of set al.

func (*LinkedHashSet[T]) PushHead

func (ls *LinkedHashSet[T]) PushHead(vs ...T)

PushHead inserts all items of vs at the head of set ls.

func (*LinkedHashSet[T]) PushHeadAll

func (ls *LinkedHashSet[T]) PushHeadAll(ac Collection[T])

PushHeadAll 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]) PushTail

func (ls *LinkedHashSet[T]) PushTail(vs ...T)

PushTail inserts all items of vs at the tail of set ls.

func (*LinkedHashSet[T]) PushTailAll

func (ls *LinkedHashSet[T]) PushTailAll(ac Collection[T])

PushTailAll 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]) Remove

func (ls *LinkedHashSet[T]) Remove(index int)

Remove removes the element at the specified position in this set.

func (*LinkedHashSet[T]) Retain

func (ls *LinkedHashSet[T]) Retain(vs ...T)

Retain Retains only the elements in this collection that are contained in the argument array vs.

func (*LinkedHashSet[T]) RetainAll

func (ls *LinkedHashSet[T]) RetainAll(ac Collection[T])

RetainAll Retains only the elements in this collection that are contained in the specified collection.

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: NewLinkedList(1, 2, 3)

Example
list := NewLinkedList[string]()
list.Add("a")                         // ["a"]
list.Add("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.Remove(2)                        // ["b","a"]
list.Remove(1)                        // ["b"]
list.Remove(0)                        // []
list.Remove(0)                        // [] (ignored)
_ = 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]) Add

func (ll *LinkedList[T]) Add(vs ...T)

Add adds all items of vs and returns the last added item.

func (*LinkedList[T]) AddAll

func (ll *LinkedList[T]) AddAll(ac Collection[T])

AddAll adds all items of another collection

func (*LinkedList[T]) Clear

func (ll *LinkedList[T]) Clear()

Clear clears list ll.

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]) ContainsAll

func (ll *LinkedList[T]) ContainsAll(ac Collection[T]) bool

ContainsAll Test to see if the collection contains all items of another collection

func (*LinkedList[T]) Delete

func (ll *LinkedList[T]) Delete(vs ...T)

Delete delete all items with associated value v of vs

func (*LinkedList[T]) DeleteAll

func (ll *LinkedList[T]) DeleteAll(ac Collection[T])

DeleteAll delete all of this collection's elements that are also contained in the specified collection

func (*LinkedList[T]) DeleteIf

func (ll *LinkedList[T]) DeleteIf(f func(T) bool)

DeleteIf delete all items that function f returns true

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]) Head

func (ll *LinkedList[T]) Head() (v T)

Head get the first item of list.

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]) IndexIf

func (ll *LinkedList[T]) IndexIf(f func(T) bool) int

IndexIf 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, 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 list's size Note: position equal to list's size is valid, i.e. append.

func (*LinkedList[T]) InsertAll

func (ll *LinkedList[T]) InsertAll(index int, ac Collection[T])

InsertAll 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]) 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]) Len

func (ll *LinkedList[T]) Len() int

Len returns the length of the list.

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(vs ...T)

Push inserts all items of vs at the tail of list al.

func (*LinkedList[T]) PushHead

func (ll *LinkedList[T]) PushHead(vs ...T)

PushHead inserts all items of vs at the head of list ll.

func (*LinkedList[T]) PushHeadAll

func (ll *LinkedList[T]) PushHeadAll(ac Collection[T])

PushHeadAll 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]) PushTail

func (ll *LinkedList[T]) PushTail(vs ...T)

PushTail inserts all items of vs at the tail of list ll.

func (*LinkedList[T]) PushTailAll

func (ll *LinkedList[T]) PushTailAll(ac Collection[T])

PushTailAll 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]) Remove

func (ll *LinkedList[T]) Remove(index int)

Remove removes the element at the specified position in this list.

func (*LinkedList[T]) Retain

func (ll *LinkedList[T]) Retain(vs ...T)

Retain Retains only the elements in this collection that are contained in the argument array vs.

func (*LinkedList[T]) RetainAll

func (ll *LinkedList[T]) RetainAll(ac Collection[T])

RetainAll Retains only the elements in this collection that are contained in the specified collection.

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]) String

func (ll *LinkedList[T]) String() string

String print list to string

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]) Tail

func (ll *LinkedList[T]) Tail() (v T)

Tail get the last item of list.

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

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

LinkedMapNode is a node of a linked hash map.

func (*LinkedMapNode[K, V]) Key

func (ln *LinkedMapNode[K, V]) Key() K

Key returns the key

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

func (*LinkedMapNode[K, V]) Value

func (ln *LinkedMapNode[K, V]) Value() V

Value returns the key

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 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.
	Insert(index int, vs ...T)

	// InsertAll 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.
	InsertAll(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

	// IndexIf returns the index of the first true returned by function f in this list, or -1 if this list does not contain v.
	IndexIf(f func(T) bool) int

	// Remove delete the item at the specified position in this list
	Remove(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)

	// 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)

	// SetPairs set items from key-value items array, override the existing items
	SetPairs(pairs ...P[K, V])

	// SetAll set items from another map am, override the existing items
	SetAll(am Map[K, V])

	// 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)

	// Delete delete all items with key of ks,
	// and returns what `Get` would have returned
	// on that key prior to the call to `Set`.
	Delete(ks ...K) (ov V, ok 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

	Eachable2[K, V]
}

Map map interface

type P

type P[K any, V any] struct {
	Key   K
	Value V
}

P key/value pair

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 adds items of vs to the tail of queue
	Push(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: NewRingBuffer(1, 2, 3)

func (*RingBuffer[T]) Add

func (rb *RingBuffer[T]) Add(vs ...T)

Add adds all items of vs and returns the last added item.

func (*RingBuffer[T]) AddAll

func (rb *RingBuffer[T]) AddAll(ac Collection[T])

AddAll adds all items of another collection

func (*RingBuffer[T]) Cap

func (rb *RingBuffer[T]) Cap() int

Cap returns the capcity of the buffer.

func (*RingBuffer[T]) Clear

func (rb *RingBuffer[T]) Clear()

Clear clears list al.

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]) ContainsAll

func (rb *RingBuffer[T]) ContainsAll(ac Collection[T]) bool

ContainsAll Test to see if the collection contains all items of another collection

func (*RingBuffer[T]) Delete

func (rb *RingBuffer[T]) Delete(vs ...T)

Delete delete all items with associated value v of vs

func (*RingBuffer[T]) DeleteAll

func (rb *RingBuffer[T]) DeleteAll(ac Collection[T])

DeleteAll delete all of this collection's elements that are also contained in the specified collection

func (*RingBuffer[T]) DeleteIf

func (rb *RingBuffer[T]) DeleteIf(f func(T) bool)

DeleteIf delete all items that function f returns true

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]) IndexIf

func (rb *RingBuffer[T]) IndexIf(f func(T) bool) int

IndexIf 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, 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 RingBuffer's size Note: position equal to RingBuffer's size is valid, i.e. append.

func (*RingBuffer[T]) InsertAll

func (rb *RingBuffer[T]) InsertAll(index int, ac Collection[T])

InsertAll 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]) 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(vs ...T)

Push inserts all items of vs at the tail of RingBuffer rb.

func (*RingBuffer[T]) PushHead

func (rb *RingBuffer[T]) PushHead(vs ...T)

PushHead inserts all items of vs at the head of RingBuffer rb.

func (*RingBuffer[T]) PushHeadAll

func (rb *RingBuffer[T]) PushHeadAll(ac Collection[T])

PushHeadAll 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]) PushTail

func (rb *RingBuffer[T]) PushTail(vs ...T)

PushTail inserts all items of vs at the tail of RingBuffer rb.

func (*RingBuffer[T]) PushTailAll

func (rb *RingBuffer[T]) PushTailAll(ac Collection[T])

PushTailAll 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]) Remove

func (rb *RingBuffer[T]) Remove(index int)

Remove removes the item at the specified position in this RingBuffer.

func (*RingBuffer[T]) Retain

func (rb *RingBuffer[T]) Retain(vs ...T)

Retain Retains only the elements in this collection that are contained in the argument array vs.

func (*RingBuffer[T]) RetainAll

func (rb *RingBuffer[T]) RetainAll(ac Collection[T])

RetainAll Retains only the elements in this collection that are contained in the specified collection.

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 S

type S interface {
	~string
}

S string type constraint

type Set

type Set[T any] Collection[T]

Set a set interface

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

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

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) // empty (keys are of type int)
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.Delete(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

func NewTreeMap[K any, V any](compare Compare[K], kvs ...P[K, V]) *TreeMap[K, V]

NewTreeMap creates a new TreeMap. Example: NewTreeMap(CompareString, []P{{"k1", "v1"}, {"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]) Clear

func (tm *TreeMap[K, V]) Clear()

Clear clears the map

func (*TreeMap[K, V]) Contains

func (tm *TreeMap[K, V]) Contains(ks ...K) bool

Contains looks for the given key, and returns true if the key exists in the map.

func (*TreeMap[K, V]) Delete

func (tm *TreeMap[K, V]) Delete(ks ...K) (ov V, ok bool)

Delete delete all items with key of ks, and returns what `Get` would have returned on that key prior to the call to `Delete`.

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

func (tm *TreeMap[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 (*TreeMap[K, V]) Graph

func (tm *TreeMap[K, V]) Graph(value bool) string

Graph return the map's graph

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]) IsEmpty

func (tm *TreeMap[K, V]) IsEmpty() bool

IsEmpty returns true if the map has no items

func (*TreeMap[K, V]) Items

func (tm *TreeMap[K, V]) Items() []*TreeMapNode[K, V]

Items returns the map item slice

func (*TreeMap[K, V]) Iterator

func (tm *TreeMap[K, V]) Iterator() Iterator2[K, V]

Iterator returns a iterator for the map

func (*TreeMap[K, V]) Keys

func (tm *TreeMap[K, V]) Keys() []K

Keys returns the key slice

func (*TreeMap[K, V]) Len

func (tm *TreeMap[K, V]) Len() int

Len returns the length of the tree map.

func (*TreeMap[K, V]) MarshalJSON

func (tm *TreeMap[K, V]) MarshalJSON() ([]byte, error)

MarshalJSON implements type json.Marshaler interface, so can be called in json.Marshal(tm)

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]) 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

func (tm *TreeMap[K, V]) Set(key K, value V) (ov V, ok bool)

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]) SetAll

func (tm *TreeMap[K, V]) SetAll(am Map[K, V])

SetAll add items from another map am, override the existing items

func (*TreeMap[K, V]) SetIfAbsent

func (tm *TreeMap[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 true if the tree is changed.

func (*TreeMap[K, V]) SetPairs

func (tm *TreeMap[K, V]) SetPairs(pairs ...P[K, V])

SetPairs set items from key-value items array, override the existing items

func (*TreeMap[K, V]) String

func (tm *TreeMap[K, V]) String() string

String print map to string

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

func (tm *TreeMap[K, V]) UnmarshalJSON(data []byte) error

UnmarshalJSON implements type json.Unmarshaler interface, so can be called in json.Unmarshal(data, tm)

func (*TreeMap[K, V]) Values

func (tm *TreeMap[K, V]) Values() []V

Values returns the value slice

type TreeMapNode

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

TreeMapNode is a node of red-black tree

func (*TreeMapNode[K, V]) Key

func (tn *TreeMapNode[K, V]) Key() K

Key returns the key

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

func (*TreeMapNode[K, V]) Value

func (tn *TreeMapNode[K, V]) Value() V

Value returns the key

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

func NewTreeSet[T any](compare Compare[T], vs ...T) *TreeSet[T]

NewTreeSet creates a new TreeSet. Example: NewTreeSet(CompareString, "v1", "v2")

Example
set := NewTreeSet(CompareInt) // empty (keys are of type int)
set.Add(1)                    // 1
set.Add(2, 2, 3, 4, 5)        // 1, 2, 3, 4, 5 (in order, duplicates ignored)
set.Delete(4)                 // 1, 2, 3, 5 (in order)
set.Delete(2, 3)              // 1, 5 (in order)
set.Contains(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]) Add

func (ts *TreeSet[T]) Add(vs ...T)

Add adds all items of vs and returns the last added item.

func (*TreeSet[T]) AddAll

func (ts *TreeSet[T]) AddAll(ac Collection[T])

AddAll adds all items of another collection

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]) Clear

func (ts *TreeSet[T]) Clear()

Clear clears the set

func (*TreeSet[T]) Contains

func (ts *TreeSet[T]) Contains(vs ...T) bool

Contains Test to see if the collection contains all items of vs

func (*TreeSet[T]) ContainsAll

func (ts *TreeSet[T]) ContainsAll(ac Collection[T]) bool

ContainsAll Test to see if the collection contains all items of another collection

func (*TreeSet[T]) Delete

func (ts *TreeSet[T]) Delete(vs ...T)

Delete delete all items with associated value v of vs

func (*TreeSet[T]) DeleteAll

func (ts *TreeSet[T]) DeleteAll(ac Collection[T])

DeleteAll delete all of this collection's elements that are also contained in the specified collection

func (*TreeSet[T]) DeleteIf

func (ts *TreeSet[T]) DeleteIf(f func(T) bool)

DeleteIf delete all items that function f returns true

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]) Graph

func (ts *TreeSet[T]) Graph() string

Graph return the set's graph

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]) IsEmpty

func (ts *TreeSet[T]) IsEmpty() bool

IsEmpty returns true if the set has no items

func (*TreeSet[T]) Iterator

func (ts *TreeSet[T]) Iterator() Iterator[T]

Iterator returns a iterator for the set

func (*TreeSet[T]) Len

func (ts *TreeSet[T]) Len() int

Len returns the length of the tree set.

func (*TreeSet[T]) MarshalJSON

func (ts *TreeSet[T]) MarshalJSON() ([]byte, error)

MarshalJSON implements type json.Marshaler interface, so can be called in json.Marshal(ts)

func (*TreeSet[T]) PeekHead

func (ts *TreeSet[T]) PeekHead() (v T, ok bool)

PeekHead get the first item of set.

func (*TreeSet[T]) PeekTail

func (ts *TreeSet[T]) PeekTail() (v T, ok bool)

PeekTail get the last item of set.

func (*TreeSet[T]) PollHead

func (ts *TreeSet[T]) PollHead() (v T, ok bool)

PollHead remove the first item of set.

func (*TreeSet[T]) PollTail

func (ts *TreeSet[T]) PollTail() (v T, ok bool)

PollTail remove the last item of set.

func (*TreeSet[T]) Retain

func (ts *TreeSet[T]) Retain(vs ...T)

Retain Retains only the elements in this collection that are contained in the argument array vs.

func (*TreeSet[T]) RetainAll

func (ts *TreeSet[T]) RetainAll(ac Collection[T])

RetainAll Retains only the elements in this collection that are contained in the specified collection.

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]) String

func (ts *TreeSet[T]) String() string

String print set to string

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

func (ts *TreeSet[T]) UnmarshalJSON(data []byte) error

UnmarshalJSON implements type json.Unmarshaler interface, so can be called in json.Unmarshal(data, ts)

func (*TreeSet[T]) Values

func (ts *TreeSet[T]) Values() []T

Values returns the value slice

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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