Documentation ¶
Overview ¶
Package zarray provides array operations
Index ¶
- Variables
- func Contains[T comparable](collection []T, v T) bool
- func Diff[T comparable](list1 []T, list2 []T) ([]T, []T)
- func Filter[T any](slice []T, predicate func(index int, item T) bool) []T
- func Find[T any](collection []T, predicate func(index int, item T) bool) (T, bool)
- func GetInf(arr []interface{}, index int, def ...interface{}) (value interface{}, err error)
- func Keys[K comparable, V any](in map[K]V) []K
- func Map[T any, R any](collection []T, iteratee func(int, T) R) []R
- func Rand[T any](collection []T) T
- func Shuffle[T any](collection []T) []T
- func Unique[T comparable](collection []T) []T
- func Values[K comparable, V any](in map[K]V) []V
- type Array
- func (arr *Array) Add(index int, value interface{}) (err error)
- func (arr *Array) CapLength() int
- func (arr *Array) Clear()
- func (arr *Array) Contains(value interface{}) bool
- func (arr *Array) Format() (format string)
- func (arr *Array) Get(index int, def ...interface{}) (value interface{}, err error)
- func (arr *Array) Index(value interface{}) int
- func (arr *Array) IsEmpty() bool
- func (arr *Array) Length() int
- func (arr *Array) Map(fn func(int, interface{}) interface{}) *Array
- func (arr *Array) Pop() (interface{}, error)
- func (arr *Array) Push(values ...interface{})
- func (arr *Array) Raw() []interface{}
- func (arr *Array) Remove(index int, l ...int) (value []interface{}, err error)
- func (arr *Array) RemoveValue(value interface{}) (e interface{}, err error)
- func (arr *Array) Set(index int, value interface{}) (err error)
- func (arr *Array) Shift() (interface{}, error)
- func (arr *Array) Shuffle() (array *Array)
- func (arr *Array) Unshift(value interface{}) error
- type Maper
- func (m *Maper[K, V]) CAS(key K, oldValue, newValue V) bool
- func (m *Maper[K, V]) Delete(keys ...K)
- func (m *Maper[K, V]) Fillrate() uintptr
- func (m *Maper[K, V]) ForEach(lambda func(K, V) bool)
- func (m *Maper[K, V]) Get(key K) (value V, ok bool)
- func (m *Maper[K, V]) GetAndDelete(key K) (value V, ok bool)
- func (m *Maper[K, V]) GetOrSet(key K, value V) (actual V, loaded bool)
- func (m *Maper[K, V]) Grow(newSize uintptr)
- func (m *Maper[K, V]) Has(key K) (ok bool)
- func (m *Maper[K, V]) Len() uintptr
- func (m *Maper[K, V]) MarshalJSON() ([]byte, error)
- func (m *Maper[K, V]) ProvideGet(key K, provide func() (V, bool)) (actual V, loaded, computed bool)
- func (m *Maper[K, V]) Set(key K, value V)
- func (m *Maper[K, V]) SetHasher(hasher func(K) uintptr)
- func (m *Maper[K, V]) Swap(key K, newValue V) (oldValue V, swapped bool)
- func (m *Maper[K, V]) UnmarshalJSON(i []byte) error
- type SortMaper
- func (s *SortMaper[K, V]) Delete(key ...K)
- func (s *SortMaper[K, V]) ForEach(lambda func(K, V) bool)
- func (s *SortMaper[K, V]) Get(key K) (value V, ok bool)
- func (s *SortMaper[K, V]) Has(key K) (ok bool)
- func (s *SortMaper[K, V]) Keys() []K
- func (s *SortMaper[K, V]) Len() int
- func (s *SortMaper[K, V]) Set(key K, value V)
Constants ¶
This section is empty.
Variables ¶
var ErrIllegalIndex = errors.New("illegal index")
ErrIllegalIndex illegal index
Functions ¶
func Contains ¶ added in v1.4.3
func Contains[T comparable](collection []T, v T) bool
Contains returns true if an eent is present in a collection
func Diff ¶ added in v1.4.5
func Diff[T comparable](list1 []T, list2 []T) ([]T, []T)
func Find ¶ added in v1.4.5
Find search an eent in a slice based on a predicate. It returns eent and true if eent was found.
func GetInf ¶ added in v1.3.2
GetInf Get the element corresponding to the index position of [] interface {}
func Keys ¶ added in v1.4.3
func Keys[K comparable, V any](in map[K]V) []K
Keys creates an array of the map keys
func Shuffle ¶ added in v1.3.6
func Shuffle[T any](collection []T) []T
Shuffle creates a slice of shuffled values
func Unique ¶ added in v1.4.5
func Unique[T comparable](collection []T) []T
Unique returns a duplicate-free version of an array
func Values ¶ added in v1.4.3
func Values[K comparable, V any](in map[K]V) []V
Values creates an array of the map values
Types ¶
type Array ¶
type Array struct {
// contains filtered or unexported fields
}
Array insert, delete, random access according to the subscript operation, the data is interface type
func (*Array) Push ¶
func (arr *Array) Push(values ...interface{})
Push insert element to end of array
func (*Array) RemoveValue ¶
RemoveValue removes the specified element from the array
type Maper ¶ added in v1.4.5
type Maper[K hashable, V any] struct { // contains filtered or unexported fields }
Maper implements the concurrent hashmap
func NewHashMap ¶ added in v1.4.4
func (*Maper[K, V]) CAS ¶ added in v1.4.5
func (m *Maper[K, V]) CAS(key K, oldValue, newValue V) bool
func (*Maper[K, V]) GetAndDelete ¶ added in v1.5.0
func (m *Maper[K, V]) GetAndDelete(key K) (value V, ok bool)
func (*Maper[K, V]) GetOrSet ¶ added in v1.4.8
func (m *Maper[K, V]) GetOrSet(key K, value V) (actual V, loaded bool)
func (*Maper[K, V]) MarshalJSON ¶ added in v1.5.0
MarshalJSON implements the json.Marshaler interface.
func (*Maper[K, V]) ProvideGet ¶ added in v1.4.5
func (*Maper[K, V]) SetHasher ¶ added in v1.4.5
func (m *Maper[K, V]) SetHasher(hasher func(K) uintptr)
func (*Maper[K, V]) Swap ¶ added in v1.4.5
func (m *Maper[K, V]) Swap(key K, newValue V) (oldValue V, swapped bool)
func (*Maper[K, V]) UnmarshalJSON ¶ added in v1.5.0
UnmarshalJSON implements the json.Unmarshaler interface.