Documentation
¶
Index ¶
- type Int
- type Int64
- type List
- func (l *List[V]) Clear()
- func (l *List[V]) Contains(value V) bool
- func (l *List[V]) Filter(f func(V) bool) *List[V]
- func (l *List[V]) Find(f func(V) bool) V
- func (l *List[V]) First() V
- func (l *List[V]) ForEach(f func(V) (stop bool))
- func (l *List[V]) Get(index int) V
- func (l *List[V]) IndexOf(value V) int
- func (l *List[V]) Iterator() []V
- func (l *List[V]) LPop() V
- func (l *List[V]) LPush(value V)
- func (l *List[V]) Last() V
- func (l *List[V]) Length() int
- func (l *List[V]) Map(f func(V) V) *List[V]
- func (l *List[V]) MarshalJSON() ([]byte, error)
- func (l *List[V]) Pop() V
- func (l *List[V]) Push(value V)
- func (l *List[V]) Reduce(f func(V, V) V) V
- func (l *List[V]) Reverse() *List[V]
- func (l *List[V]) Shift() V
- func (l *List[V]) Size() int
- func (l *List[V]) Slice(start int, end int) *List[V]
- func (l *List[V]) Splice(index int, count int) *List[V]
- func (l *List[V]) String() string
- func (l *List[V]) Swap(index1 int, index2 int)
- func (l *List[V]) ToSlice() []V
- func (l *List[V]) UnmarshalJSON(data []byte) error
- func (l *List[V]) Unshift(value V)
- func (l *List[V]) Unshifts(values V)
- type ListConfig
- type ListOption
- type Map
- func (m *Map[K, V]) Clear() error
- func (m *Map[K, V]) Del(key K) error
- func (m *Map[K, V]) ForEach(f func(K, V) (stop bool))
- func (m *Map[K, V]) Get(key K) V
- func (m *Map[K, V]) Has(key K) bool
- func (m *Map[K, V]) Iterator() map[K]V
- func (m *Map[K, V]) Keys() []K
- func (m *Map[K, V]) MarshalJSON() ([]byte, error)
- func (m *Map[K, V]) Set(key K, value V) error
- func (m *Map[K, V]) String() string
- func (m *Map[K, V]) ToMap() map[K]V
- func (m *Map[K, V]) UnmarshalJSON(data []byte) error
- type MapConfig
- type MapOption
- type Queue
- func (q *Queue[V]) Back() V
- func (q *Queue[V]) Clear()
- func (q *Queue[V]) Dequeue() V
- func (q *Queue[V]) Enqueue(value V)
- func (q *Queue[V]) ForEach(fn func(value V, index int) (stop bool))
- func (q *Queue[V]) ForEachReverse(fn func(value V, index int) (stop bool))
- func (q *Queue[V]) Front() V
- func (q *Queue[V]) IsEmpty() bool
- func (q *Queue[V]) MarshalJSON() ([]byte, error)
- func (q *Queue[V]) Size() int
- func (q *Queue[V]) String() string
- func (q *Queue[V]) ToSlice() []V
- func (q *Queue[V]) UnmarshalJSON(data []byte) error
- type QueueConfig
- type QueueOption
- type Stack
- func (m *Stack[V]) Clear(key string)
- func (m *Stack[V]) ForEach(key string, fn func(value V, index int) (stop bool))
- func (m *Stack[V]) ForEachReverse(key string, fn func(value V, index int) (stop bool))
- func (m *Stack[V]) IsEmpty(key string) bool
- func (m *Stack[V]) MarshalJSON() ([]byte, error)
- func (m *Stack[V]) Peek(key string) V
- func (m *Stack[V]) Pop(key string) V
- func (m *Stack[V]) Push(key string, value V)
- func (m *Stack[V]) Size(key string) int
- func (m *Stack[V]) String() string
- func (m *Stack[V]) ToSlice(key string) []V
- func (m *Stack[V]) UnmarshalJSON(data []byte) error
- type String
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Int ¶ added in v1.0.7
Int ...
func (*Int) MarshalJSON ¶ added in v1.4.4
MarshalJSON returns the JSON encoding of the int
func (*Int) UnmarshalJSON ¶ added in v1.4.4
UnmarshalJSON decodes the JSON-encoded data and stores the result in the int
type Int64 ¶ added in v1.0.7
Int64 ...
func (*Int64) MarshalJSON ¶ added in v1.4.4
MarshalJSON returns the JSON encoding of the int
func (*Int64) UnmarshalJSON ¶ added in v1.4.4
UnmarshalJSON decodes the JSON-encoded data and stores the result in the int
type List ¶ added in v1.0.7
List ...
func NewList ¶
func NewList[V any](opts ...ListOption) *List[V]
NewList returns a new safe list
@TODO generic type comparable interface cannot implement by struct,so we use any type for generic type
func (*List[V]) Clear ¶ added in v1.0.7
func (l *List[V]) Clear()
Clear removes all elements from the list
func (*List[V]) Contains ¶ added in v1.0.7
Contains returns true if the list contains the given element
func (*List[V]) Filter ¶ added in v1.0.7
Filter returns a new list with all elements that satisfy the given function
func (*List[V]) Find ¶ added in v1.0.7
Find returns the first element that satisfies the given function
func (*List[V]) First ¶ added in v1.0.7
func (l *List[V]) First() V
First returns the first element of the list
func (*List[V]) ForEach ¶ added in v1.0.7
ForEach iterates over the list and calls the given function for each element
func (*List[V]) Iterator ¶ added in v1.0.8
func (l *List[V]) Iterator() []V
Iterator returns a channel that will yield successive elements of the list
func (*List[V]) LPop ¶ added in v1.4.3
func (l *List[V]) LPop() V
LPop removes and returns the first element of the list
func (*List[V]) LPush ¶ added in v1.4.3
func (l *List[V]) LPush(value V)
LPush adds an element to the beginning of the list
func (*List[V]) Last ¶ added in v1.0.7
func (l *List[V]) Last() V
Last returns the last element of the list
func (*List[V]) Map ¶ added in v1.0.7
Map returns a new list with the result of calling the given function on each element
func (*List[V]) MarshalJSON ¶ added in v1.4.2
MarshalJSON returns the JSON encoding of the list
func (*List[V]) Pop ¶ added in v1.0.7
func (l *List[V]) Pop() V
Pop removes and returns the last element of the list
func (*List[V]) Push ¶ added in v1.0.7
func (l *List[V]) Push(value V)
Push adds an element to the end of the list
func (*List[V]) Reduce ¶ added in v1.0.7
func (l *List[V]) Reduce(f func(V, V) V) V
Reduce returns the result of reducing the list to a single value
func (*List[V]) Shift ¶ added in v1.0.7
func (l *List[V]) Shift() V
Shift removes and returns the first element of the list
like JavaScript Array.shift
func (*List[V]) Slice ¶ added in v1.0.7
Slice returns a new list with a copy of a given number of elements from the given index
func (*List[V]) Splice ¶ added in v1.0.7
Splice removes the given number of elements from the given index
func (*List[V]) ToSlice ¶ added in v1.0.12
func (l *List[V]) ToSlice() []V
ToSlice returns the origin map
func (*List[V]) UnmarshalJSON ¶ added in v1.4.2
UnmarshalJSON parses the JSON-encoded data and stores the result in the list
type Map ¶ added in v1.0.7
type Map[K comparable, V any] struct { sync.RWMutex // contains filtered or unexported fields }
Map ...
func NewMap ¶
func NewMap[K comparable, V any](opts ...MapOption) *Map[K, V]
NewMap returns a new safe map
func (*Map[K, V]) ForEach ¶ added in v1.4.8
ForEach iterates over the map and calls the given function for each key and value
func (*Map[K, V]) Get ¶ added in v1.0.7
func (m *Map[K, V]) Get(key K) V
Get returns the value for a key
func (*Map[K, V]) Iterator ¶ added in v1.0.8
func (m *Map[K, V]) Iterator() map[K]V
Iterator returns a channel that will yield all the keys and values in the map
func (*Map[K, V]) Keys ¶ added in v1.0.7
func (m *Map[K, V]) Keys() []K
Keys returns all the keys in the map
func (*Map[K, V]) MarshalJSON ¶ added in v1.4.2
MarshalJSON returns the JSON encoding of the map
func (*Map[K, V]) ToMap ¶ added in v1.0.12
func (m *Map[K, V]) ToMap() map[K]V
ToMap returns the origin map
func (*Map[K, V]) UnmarshalJSON ¶ added in v1.4.2
UnmarshalJSON decodes the JSON encoding of the map
type Queue ¶ added in v1.0.7
Queue ...
func NewQueue ¶
func NewQueue[V any](opts ...QueueOption) *Queue[V]
NewQueue returns a new safe queue
func (*Queue[V]) Back ¶ added in v1.0.7
func (q *Queue[V]) Back() V
Back returns the last element of the queue
func (*Queue[V]) Clear ¶ added in v1.0.7
func (q *Queue[V]) Clear()
Clear removes all elements from the queue
func (*Queue[V]) Dequeue ¶ added in v1.0.7
func (q *Queue[V]) Dequeue() V
Dequeue removes and returns the first element of the queue
func (*Queue[V]) Enqueue ¶ added in v1.0.7
func (q *Queue[V]) Enqueue(value V)
Enqueue adds an element to the end of the queue
func (*Queue[V]) ForEach ¶ added in v1.4.8
ForEach iterates over the queue and calls the given function for each element from front to back
func (*Queue[V]) ForEachReverse ¶ added in v1.4.8
ForEachReverse iterates over the queue and calls the given function for each element from back to front
func (*Queue[V]) Front ¶ added in v1.0.7
func (q *Queue[V]) Front() V
Front returns the first element of the queue
func (*Queue[V]) MarshalJSON ¶ added in v1.4.2
MarshalJSON returns the JSON encoding of the queue
func (*Queue[V]) ToSlice ¶ added in v1.4.9
func (q *Queue[V]) ToSlice() []V
ToSlice returns the origin queue
func (*Queue[V]) UnmarshalJSON ¶ added in v1.4.2
UnmarshalJSON decodes the JSON encoding of the queue
type Stack ¶ added in v1.0.7
Stack ...
func (*Stack[V]) ForEach ¶ added in v1.4.8
ForEach iterates over the stack, calling the given function for each element from top to bottom
func (*Stack[V]) ForEachReverse ¶ added in v1.4.8
ForEachReverse iterates over the stack, calling the given function for each element from bottom to top
func (*Stack[V]) MarshalJSON ¶ added in v1.4.2
MarshalJSON returns the JSON encoding of the stack
func (*Stack[V]) UnmarshalJSON ¶ added in v1.4.2
UnmarshalJSON decodes the JSON encoding of the stack