Documentation
¶
Index ¶
- func All[T any](items []T, predicate func(T) bool) bool
- func Any[T any](items []T, predicate func(T) bool) bool
- func At[T any](items []T, index int) T
- func Average[T int | int32 | int64 | float32 | float64](items []T) float64
- func Chunk[T any](items []T, size int) [][]T
- func Contains[T comparable](items []T, value T) bool
- func ContainsValue[T comparable](slice []T, element T) bool
- func Count[T any](items []T, predicate func(T) bool) int
- func CountEntries[K comparable, V any](m map[K]V, predicate func(key K, value V) bool) int
- func DeepCopy[T any](s T) (T, error)
- func Default[T any](value T, defaultValue T) T
- func Distinct[T comparable](items []T) []T
- func DistinctBy[T any, U comparable](items []T, keySelector func(T) U) []T
- func Equals[T any](a T, b T) bool
- func Except[T comparable](items []T, other []T) []T
- func Filter[T any](items []T, predicate func(T) bool) []T
- func FilterMap[K comparable, V any](m map[K]V, predicate func(key K, value V) bool) map[K]V
- func Find[T any](items []T, predicate func(T) bool) T
- func FindIndex[T any](items []T, value T) int
- func FindIndexWhere[T any](items []T, predicate func(T) bool) int
- func FindKey[K comparable, V any](m map[K]V, predicate func(key K, value V) bool) (K, bool)
- func FindLast[T any](items []T, val T) T
- func FindLastIndex[T any](items []T, value T) int
- func FindLastIndexWhere[T any](items []T, predicate func(T) bool) int
- func FindLastWhere[T any](items []T, predicate func(T) bool) T
- func FindValue[K comparable, V any](m map[K]V, predicate func(key K, value V) bool) (V, bool)
- func First[T any](items []T) T
- func Flatten[T any](items [][]T) []T
- func ForEach[T any](items []T, action func(T))
- func ForEachEntry[K comparable, V any](m map[K]V, f func(key K, value V))
- func FromMap(m map[string]interface{}, s any) error
- func Get(s any, path string) (any, error)
- func GetFieldNames(s any) []string
- func Group[T any, U comparable](items []T, path string) map[U][]T
- func GroupBy[K comparable, V any, G comparable](m map[K]V, keySelector func(K, V) G) map[G][]MapEntry[K, V]
- func GroupWhere[T any, U comparable](items []T, selector func(T) U) map[U][]T
- func HasField(s any, fieldName string) bool
- func IfEmpty[T any](val T, def T) T
- func Intersect[T comparable](items []T, other []T) []T
- func Invert[K comparable, V comparable](m map[K]V) map[V]K
- func IsEmpty[T any](val T) bool
- func IsZero[T any](value T) bool
- func Key[T any, U comparable](items []T, path string) map[U]T
- func KeyWhere[T any, U comparable](items []T, selector func(T) U) map[U]T
- func Keys[K comparable, V any](m map[K]V) []K
- func Last[T any](items []T) T
- func Map[T any, U any](items []T, selector func(T) U) []U
- func MapEntries[K comparable, V any](m map[K]V, f func(key K, value V) (K, V)) map[K]V
- func MapFromEntries[K comparable, V any](entries []MapEntry[K, V]) map[K]V
- func MapKeys[K comparable, V any](m map[K]V, f func(K) K) map[K]V
- func MapValues[K comparable, V any](m map[K]V, f func(V) V) map[K]V
- func Max[T int | int32 | int64 | float32 | float64](items []T) T
- func Merge[K comparable, V any](maps ...map[K]V) map[K]V
- func Min[T int | int32 | int64 | float32 | float64](items []T) T
- func Omit[K comparable, V any](m map[K]V, keys ...K) map[K]V
- func Partition[T any](items []T, predicate func(T) bool) ([]T, []T)
- func Pick[K comparable, V any](m map[K]V, keys ...K) map[K]V
- func Pop[T any](items []T) (T, []T)
- func Push[T any](items []T, item T) []T
- func Randomize[T any](items []T) []T
- func Reduce[T any, U any](items []T, accumulator func(U, T) U, initialValue ...U) U
- func ReduceEntries[K comparable, V any, R any](m map[K]V, initial R, f func(acc R, key K, value V) R) R
- func Remove[T any](items []T, value T) []T
- func RemoveAt[T any](items []T, index int) []T
- func RemoveWhere[T any](items []T, predicate func(T) bool) []T
- func Replace[T any](items []T, oldValue T, newValue T) []T
- func ReplaceAll[T any](items []T, oldValue T, newValue T) []T
- func ReplaceAllWhere[T any](items []T, value T, predicate func(T) bool) []T
- func ReplaceWhere[T any](items []T, value T, predicate func(T) bool) []T
- func Reverse[T any](items []T) []T
- func SequenceEqual[T any](items []T, other []T) bool
- func Set(s any, path string, value any) error
- func Shift[T any](items []T) (T, []T)
- func Skip[T any](items []T, count int) []T
- func SkipLast[T any](items []T, count int) []T
- func SkipWhile[T any](items []T, predicate func(T) bool) []T
- func Slice[T any](items []T, start int, end int) []T
- func SortWhere[T any](items []T, comparer func(T, T) bool) []T
- func Sum[T int | int32 | int64 | float32 | float64](items []T) T
- func Take[T any](items []T, count int) []T
- func TakeLast[T any](items []T, count int) []T
- func TakeWhile[T any](items []T, predicate func(T) bool) []T
- func Ternary[T any](condition bool, trueVal, falseVal T) T
- func ToMap(s any) (map[string]interface{}, error)
- func Union[T comparable](items []T, other []T) []T
- func Unshift[T any](items []T, item T) []T
- func Values[K comparable, V any](m map[K]V) []V
- func Zip[T any, U any, V any](items []T, other []U, selector func(T, U) V) []V
- type ConcurrentDictionary
- func (d *ConcurrentDictionary[T]) Clear()
- func (d *ConcurrentDictionary[T]) ContainsKey(key string) bool
- func (d *ConcurrentDictionary[T]) ContainsValue(value T) bool
- func (d *ConcurrentDictionary[T]) ContainsWhere(fn func(string, T) bool) bool
- func (d *ConcurrentDictionary[T]) Count() int
- func (d *ConcurrentDictionary[T]) Get(key string) (T, bool)
- func (d *ConcurrentDictionary[T]) Keys() []string
- func (d *ConcurrentDictionary[T]) Merge(dicts ...*ConcurrentDictionary[T])
- func (d *ConcurrentDictionary[T]) MergeMaps(maps ...map[string]T)
- func (d *ConcurrentDictionary[T]) Remove(key string)
- func (d *ConcurrentDictionary[T]) RemoveValue(value T)
- func (d *ConcurrentDictionary[T]) RemoveWhere(fn func(string, T) bool)
- func (d *ConcurrentDictionary[T]) Set(key string, value T)
- func (d *ConcurrentDictionary[T]) ToArray() []T
- func (d *ConcurrentDictionary[T]) ToList() List[T]
- func (d *ConcurrentDictionary[T]) ToMap() map[string]T
- type Dictionary
- func (d *Dictionary[T]) Clear()
- func (d *Dictionary[T]) ContainsKey(key string) bool
- func (d *Dictionary[T]) ContainsValue(value T) bool
- func (d *Dictionary[T]) ContainsWhere(fn func(string, T) bool) bool
- func (d *Dictionary[T]) Count() int
- func (d *Dictionary[T]) Get(key string) (T, bool)
- func (d *Dictionary[T]) Keys() []string
- func (d *Dictionary[T]) Merge(dicts ...Dictionary[T]) *Dictionary[T]
- func (d *Dictionary[T]) MergeMaps(maps ...map[string]T)
- func (d *Dictionary[T]) Remove(key string)
- func (d *Dictionary[T]) RemoveValue(value T)
- func (d *Dictionary[T]) RemoveWhere(fn func(string, T) bool)
- func (d *Dictionary[T]) Set(key string, value T)
- func (d *Dictionary[T]) ToArray() []T
- func (d *Dictionary[T]) ToList() List[T]
- func (d *Dictionary[T]) ToMap() map[string]T
- func (d *Dictionary[T]) Values() []T
- type List
- func (l List[T]) All(predicate func(T) bool) bool
- func (l List[T]) Any(predicate func(T) bool) bool
- func (l List[T]) Chunk(size int) []List[T]
- func (l List[T]) Concat(other List[T]) List[T]
- func (l List[T]) Contains(value T) bool
- func (l List[T]) Count(predicate func(T) bool) int
- func (l List[T]) Distinct() List[T]
- func (l List[T]) Except(other []T) List[T]
- func (l List[T]) Filter(predicate func(T) bool) List[T]
- func (l List[T]) Find(fn func(T) bool) T
- func (l List[T]) FindIndex(value T) int
- func (l List[T]) FindIndexWhere(predicate func(T) bool) int
- func (l List[T]) FindLast(val T) T
- func (l List[T]) FindLastIndex(value T) int
- func (l List[T]) FindLastIndexWhere(predicate func(T) bool) int
- func (l List[T]) FindLastWhere(predicate func(T) bool) T
- func (l List[T]) First() T
- func (l List[T]) ForEach(fn func(T)) List[T]
- func (l List[T]) Intersect(other []T) List[T]
- func (l List[T]) Last() T
- func (l List[T]) Length() int
- func (l List[T]) Partition(predicate func(T) bool) (List[T], List[T])
- func (l List[T]) Pop() (T, List[T])
- func (l List[T]) Push(value T) List[T]
- func (l List[T]) Randomize() List[T]
- func (l List[T]) Reduce(accumulator func(T, T) T, initialValue ...T) T
- func (l List[T]) Remove(value T) List[T]
- func (l List[T]) RemoveAt(index int) List[T]
- func (l List[T]) RemoveWhere(predicate func(T) bool) List[T]
- func (l List[T]) Replace(oldValue T, newValue T) List[T]
- func (l List[T]) ReplaceAll(oldValue T, newValue T) List[T]
- func (l List[T]) ReplaceAllWhere(value T, predicate func(T) bool) List[T]
- func (l List[T]) ReplaceWhere(value T, predicate func(T) bool) List[T]
- func (l List[T]) Reverse() List[T]
- func (l List[T]) SequenceEqual(other []T) bool
- func (l List[T]) Shift() (T, List[T])
- func (l List[T]) Skip(count int) List[T]
- func (l List[T]) SkipLast(count int) List[T]
- func (l List[T]) SkipWhile(predicate func(T) bool) List[T]
- func (l List[T]) Slice(start int, end int) List[T]
- func (l List[T]) SortWhere(comparer func(T, T) bool) List[T]
- func (l List[T]) Take(count int) List[T]
- func (l List[T]) TakeLast(count int) List[T]
- func (l List[T]) TakeWhile(predicate func(T) bool) List[T]
- func (l List[T]) Union(other []T) List[T]
- func (l List[T]) Unshift(value T) List[T]
- func (l List[T]) Zip(other []T, selector func(T, T) T) List[T]
- type MapEntry
- type Queue
- func (q *Queue[T]) Clear()
- func (q *Queue[T]) Contains(item T) bool
- func (q *Queue[T]) ContainsWhere(fn func(T) bool) bool
- func (q *Queue[T]) Count() int
- func (q *Queue[T]) Dequeue() T
- func (q *Queue[T]) Enqueue(item T)
- func (q *Queue[T]) Peek() T
- func (q *Queue[T]) ToArray() []T
- func (q *Queue[T]) ToList() List[T]
- type Stack
- func (s *Stack[T]) Clear()
- func (s *Stack[T]) Contains(item T) bool
- func (s *Stack[T]) ContainsWhere(fn func(T) bool) bool
- func (s *Stack[T]) Count() int
- func (s *Stack[T]) Peek() (T, error)
- func (s *Stack[T]) Pop() (T, error)
- func (s *Stack[T]) Push(item T)
- func (s *Stack[T]) ToArray() []T
- func (s *Stack[T]) ToList() List[T]
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func All ¶
All determines whether all elements of an slice satisfy a condition items: The slice to search predicate: The predicate to test each element against
func Any ¶
Any determines whether any element of an slice satisfies a condition items: The slice to search predicate: The predicate to test each element against
func At ¶
At returns the value at the provided index or the default value if the index is out of bounds items: the slice index: the index
func Chunk ¶
Chunk returns a new slice with elements grouped into chunks of the specified size items: The slice to chunk size: The size of each chunk
func Contains ¶
func Contains[T comparable](items []T, value T) bool
Contains determines whether an slice contains a specific value items: The slice to search value: The value to locate in the slice
func ContainsValue ¶
func ContainsValue[T comparable](slice []T, element T) bool
ContainsValue checks if a slice contains a specific element
func Count ¶
Count returns the number of elements in an slice that satisfy a condition items: The slice to search predicate: The predicate to test each element against
func CountEntries ¶
func CountEntries[K comparable, V any](m map[K]V, predicate func(key K, value V) bool) int
CountEntries returns the number of key-value pairs in the map that satisfy the predicate
func Default ¶ added in v1.0.2
func Default[T any](value T, defaultValue T) T
Default returns the value if it is not zero, otherwise it returns the default value
func Distinct ¶
func Distinct[T comparable](items []T) []T
Distinct returns distinct elements from an slice items: The slice to search
func DistinctBy ¶
func DistinctBy[T any, U comparable](items []T, keySelector func(T) U) []T
DistinctBy returns distinct elements from an slice based on a key selector items: The slice to search keySelector: The function to extract the key from each element
func Equals ¶
Equals compares two values for equality. It uses reflect.DeepEqual for the comparison.
func Except ¶
func Except[T comparable](items []T, other []T) []T
Except returns the elements of an slice that do not appear in a second slice items: The slice to search other: The slice whose elements that also occur in the first slice will cause those elements to be removed from the returned slice
func Filter ¶
Filter removes all elements from an slice that satisfy the predicate items: The slice to filter predicate: The predicate to test each element against
func FilterMap ¶
func FilterMap[K comparable, V any](m map[K]V, predicate func(key K, value V) bool) map[K]V
FilterMap Returns a map with the elements that satisfy the predicate
func Find ¶
Find returns the first element in the slice that satisfies the predicate items: The slice to search predicate: The predicate to test each element against
func FindIndex ¶
FindIndex returns the index of the first occurrence of a value in the slice items: The slice to search value: The value to locate in the slice
func FindIndexWhere ¶
FindIndexWhere returns the index of the first element in the slice that satisfies the predicate items: The slice to search predicate: The predicate to test each element against
func FindKey ¶
func FindKey[K comparable, V any](m map[K]V, predicate func(key K, value V) bool) (K, bool)
FindKey returns the key of the first element that satisfies the predicate
func FindLast ¶
func FindLast[T any](items []T, val T) T
FindLast returns the last element in the slice that satisfies the predicate items: The slice to search predicate: The predicate to test each element against
func FindLastIndex ¶
FindLastIndex returns the index of the last occurrence of a value in the slice items: The slice to search value: The value to locate in the slice
func FindLastIndexWhere ¶
FindLastIndexWhere returns the index of the last element in the slice that satisfies the predicate items: The slice to search predicate: The predicate to test each element against
func FindLastWhere ¶
FindLastWhere returns the last element in the slice that satisfies the predicate items: The slice to search predicate: The predicate to test each element against
func FindValue ¶
func FindValue[K comparable, V any](m map[K]V, predicate func(key K, value V) bool) (V, bool)
FindValue returns the value of the first element that satisfies the predicate
func First ¶
func First[T any](items []T) T
First returns the first element in an slice items: The slice to get the first element from
func Flatten ¶
func Flatten[T any](items [][]T) []T
Flatten returns a new slice with all sub-slice elements concatenated items: The slice to flatten
func ForEach ¶
func ForEach[T any](items []T, action func(T))
ForEach performs the specified action on each element of an slice items: The slice to iterate action: The action to perform on each element
func ForEachEntry ¶
func ForEachEntry[K comparable, V any](m map[K]V, f func(key K, value V))
ForEachEntry executes a provided function once for each map entry
func FromMap ¶
FromMap creates a struct from a map[string]interface{} m: The map to create the struct from s: The struct to set the values in
func Get ¶
Get returns the value of a field in a struct s: The struct to get the value from path: The path to the field
func GetFieldNames ¶
GetFieldNames returns a slice of all field names in a struct s: The struct to get the field names from
func Group ¶
func Group[T any, U comparable](items []T, path string) map[U][]T
Group returns the a Map of the slice where the key is the value of the field at the specified path and the value is an slice of all the elements that match the key items: The slice to convert to a Map path: The path to the field to use as the key. If the field is not found, the item will not be added to the Map
func GroupBy ¶
func GroupBy[K comparable, V any, G comparable](m map[K]V, keySelector func(K, V) G) map[G][]MapEntry[K, V]
GroupBy groups the map entries by a key selector function
func GroupWhere ¶
func GroupWhere[T any, U comparable](items []T, selector func(T) U) map[U][]T
GroupWhere returns the a Map of the slice where the key is the result of the selector function and the value is an slice of all the elements that match the key items: The slice to convert to a Map selector: The selector function to use
func HasField ¶
HasField checks if a struct has a specific field s: The struct to check fieldName: The name of the field to check
func IfEmpty ¶
func IfEmpty[T any](val T, def T) T
IfEmpty returns a default value if a value is empty val: The value to check def: The default value
func Intersect ¶
func Intersect[T comparable](items []T, other []T) []T
Intersect returns the elements that appear in two slices items: The slice to search other: The slice whose distinct elements that also appear in the first slice will be returned
func Invert ¶
func Invert[K comparable, V comparable](m map[K]V) map[V]K
Invert swaps the keys and values of the map
func IsEmpty ¶
IsEmpty checks if a value is considered empty. It handles various types including slices, maps, strings, channels, pointers, and interfaces.
func Key ¶
func Key[T any, U comparable](items []T, path string) map[U]T
Key returns the a Map of the slice where the key is the value of the field at the specified path items: The slice to convert to a Map path: The path to the field to use as the key. If the field is not found, the item will not be added to the Map
func KeyWhere ¶
func KeyWhere[T any, U comparable](items []T, selector func(T) U) map[U]T
KeyWhere returns the a Map of the slice where the key is the result of the selector function items: The slice to convert to a Map selector: The selector function to use
func Last ¶
func Last[T any](items []T) T
Last returns the last element in an slice items: The slice to get the last element from
func Map ¶
Map projects each element of an slice into a new form items: The slice to map selector: The selector function to use
func MapEntries ¶
func MapEntries[K comparable, V any](m map[K]V, f func(key K, value V) (K, V)) map[K]V
MapEntries returns a new map with the entries mapped by the function
func MapFromEntries ¶
func MapFromEntries[K comparable, V any](entries []MapEntry[K, V]) map[K]V
MapFromEntries Returns a map from a slice of key-value pairs
func MapKeys ¶
func MapKeys[K comparable, V any](m map[K]V, f func(K) K) map[K]V
MapKeys returns a new map with the function applied to each key
func MapValues ¶
func MapValues[K comparable, V any](m map[K]V, f func(V) V) map[K]V
MapValues returns a new map with the function applied to each value
func Merge ¶
func Merge[K comparable, V any](maps ...map[K]V) map[K]V
Merge combines two or more maps into a new map
func Omit ¶
func Omit[K comparable, V any](m map[K]V, keys ...K) map[K]V
Omit creates a new map without the specified keys
func Partition ¶
Partition splits an slice into two slices based on a predicate items: The slice to partition predicate: The predicate to test each element against
func Pick ¶
func Pick[K comparable, V any](m map[K]V, keys ...K) map[K]V
Pick creates a new map with only the specified keys
func Pop ¶
func Pop[T any](items []T) (T, []T)
Pop removes the last element from an slice and returns it items: The slice to remove the element from
func Push ¶
func Push[T any](items []T, item T) []T
Push adds an element to the end of an slice items: The slice to add the element to item: The element to add
func Randomize ¶
func Randomize[T any](items []T) []T
Randomize returns a new slice with the elements in a random order items: The slice to randomize
func Reduce ¶
Reduce applies an accumulator function over an slice items: The slice to reduce accumulator: The accumulator function to use
func ReduceEntries ¶
func ReduceEntries[K comparable, V any, R any](m map[K]V, initial R, f func(acc R, key K, value V) R) R
ReduceEntries reduces the map to a single value
func Remove ¶
func Remove[T any](items []T, value T) []T
Remove removes the first occurrence of a specific object from an slice items: The slice to remove elements from value: The value to remove from the slice
func RemoveAt ¶
RemoveAt removes an element from an slice at the specified index items: The slice to remove elements from
func RemoveWhere ¶
RemoveWhere removes the first element in the slice that satisfies the predicate items: The slice to remove elements from predicate: The predicate to test each element against
func Replace ¶
func Replace[T any](items []T, oldValue T, newValue T) []T
Replace replaces the first occurrence of a value in an slice with another value items: The slice to replace values in oldValue: The value to replace newValue: The value to replace with
func ReplaceAll ¶
func ReplaceAll[T any](items []T, oldValue T, newValue T) []T
ReplaceAll replaces all occurrences of a value in an slice with another value items: The slice to replace values in oldValue: The value to replace newValue: The value to replace with
func ReplaceAllWhere ¶
ReplaceAllWhere replaces all occurrences of a value in an slice with the result of the selector function items: The slice to replace values in value: The value to replace with predicate: The selector function to use
func ReplaceWhere ¶
ReplaceWhere replaces the first occurrence of a value in an slice with the result of the selector function items: The slice to replace values in value: The value to replace with predicate: The selector function to use
func Reverse ¶
func Reverse[T any](items []T) []T
Reverse reverses the order of the elements in the slice in-place items: The slice to reverse
func SequenceEqual ¶
SequenceEqual determines whether two slices are equal items: The first slice to compare other: The second slice to compare
func Set ¶
Set sets the value of a field in a struct s: The struct to set the value in path: The path to the field value: The value to set
func Shift ¶
func Shift[T any](items []T) (T, []T)
Shift removes the first element from an slice and returns it items: The slice to remove the element from
func Skip ¶
Skip returns a new slice with the specified number of elements removed from the start of the slice items: The slice to skip elements from count: The number of elements to skip
func SkipLast ¶
SkipLast returns a new slice with the specified number of elements removed from the end of the slice items: The slice to skip elements from count: The number of elements to skip
func SkipWhile ¶
SkipWhile returns a new slice with elements removed from the start of the slice while the predicate returns true items: The slice to skip elements from predicate: The predicate to test each element against
func Slice ¶
Slice returns a new slice with the elements from the specified start index to the specified end index items: The slice to slice start: The index to start at end: The index to end at
func SortWhere ¶
SortWhere sorts the elements of an slice in place using the specified comparer function items: The slice to sort comparer: The comparer function to use
func Take ¶
Take returns a new slice with the specified number of elements from the start of the slice items: The slice to take elements from count: The number of elements to take
func TakeLast ¶
TakeLast returns a new slice with the specified number of elements from the end of the slice items: The slice to take elements from count: The number of elements to take
func TakeWhile ¶
TakeWhile returns a new slice with elements from the start of the slice while the predicate returns true items: The slice to take elements from predicate: The predicate to test each element against
func Ternary ¶ added in v1.0.2
Ternary returns the trueVal if the condition is true, otherwise it returns the falseVal
func Union ¶
func Union[T comparable](items []T, other []T) []T
Union returns the elements that appear in either of two slices items: The first slice to search other: The second slice to search
func Unshift ¶
func Unshift[T any](items []T, item T) []T
Unshift adds an element to the start of an slice items: The slice to add the element to item: The element to add
func Values ¶
func Values[K comparable, V any](m map[K]V) []V
Returns a slice of values from the map
Types ¶
type ConcurrentDictionary ¶
type ConcurrentDictionary[T any] struct { // contains filtered or unexported fields }
ConcurrentDictionary is a thread-safe dictionary utilizes a read-write mutex to allow multiple readers or a single writer
func NewConcurrentDictionary ¶
func NewConcurrentDictionary[T any]() *ConcurrentDictionary[T]
NewConcurrentDictionary creates a new dictionary
func ToConcurrentDictionary ¶
func ToConcurrentDictionary[T any](m map[string]T) *ConcurrentDictionary[T]
ToConcurrentDictionary creates a new dictionary from a map m: The map to create the dictionary from
func (*ConcurrentDictionary[T]) Clear ¶
func (d *ConcurrentDictionary[T]) Clear()
Clear removes all values from the dictionary
func (*ConcurrentDictionary[T]) ContainsKey ¶
func (d *ConcurrentDictionary[T]) ContainsKey(key string) bool
ContainsKey returns if the dictionary contains the given key key: The key to check for
func (*ConcurrentDictionary[T]) ContainsValue ¶
func (d *ConcurrentDictionary[T]) ContainsValue(value T) bool
ContainsValue returns if the dictionary contains the given value value: The value to check for
func (*ConcurrentDictionary[T]) ContainsWhere ¶
func (d *ConcurrentDictionary[T]) ContainsWhere(fn func(string, T) bool) bool
ContainsWhere returns if the dictionary contains a value that satisfies the given predicate fn: The predicate to check for
func (*ConcurrentDictionary[T]) Count ¶
func (d *ConcurrentDictionary[T]) Count() int
Count returns the number of values in the dictionary
func (*ConcurrentDictionary[T]) Get ¶
func (d *ConcurrentDictionary[T]) Get(key string) (T, bool)
Get returns the value in the dictionary for the given key key: The key to get the value for
func (*ConcurrentDictionary[T]) Keys ¶
func (d *ConcurrentDictionary[T]) Keys() []string
Keys returns the keys in the dictionary
func (*ConcurrentDictionary[T]) Merge ¶
func (d *ConcurrentDictionary[T]) Merge(dicts ...*ConcurrentDictionary[T])
Merge merges the given dictionaries into the dictionary dicts: The dictionaries to merge
func (*ConcurrentDictionary[T]) MergeMaps ¶
func (d *ConcurrentDictionary[T]) MergeMaps(maps ...map[string]T)
MergeMaps merges the given maps into the dictionary maps: The maps to merge
func (*ConcurrentDictionary[T]) Remove ¶
func (d *ConcurrentDictionary[T]) Remove(key string)
Remove removes the value in the dictionary for the given key key: The key to remove the value for
func (*ConcurrentDictionary[T]) RemoveValue ¶
func (d *ConcurrentDictionary[T]) RemoveValue(value T)
RemoveValue removes the given value from the dictionary value: The value to remove
func (*ConcurrentDictionary[T]) RemoveWhere ¶
func (d *ConcurrentDictionary[T]) RemoveWhere(fn func(string, T) bool)
RemoveWhere removes the value in the dictionary that satisfies the given predicate fn: The predicate to check for
func (*ConcurrentDictionary[T]) Set ¶
func (d *ConcurrentDictionary[T]) Set(key string, value T)
Set sets the value in the dictionary for the given key key: The key to set the value for value: The value to set
func (*ConcurrentDictionary[T]) ToArray ¶
func (d *ConcurrentDictionary[T]) ToArray() []T
ToArray returns the values in the dictionary as an array
func (*ConcurrentDictionary[T]) ToList ¶
func (d *ConcurrentDictionary[T]) ToList() List[T]
ToList returns the values in the dictionary as a list
func (*ConcurrentDictionary[T]) ToMap ¶
func (d *ConcurrentDictionary[T]) ToMap() map[string]T
ToMap returns the dictionary as a map
type Dictionary ¶
type Dictionary[T any] struct { // contains filtered or unexported fields }
Dictionary is a wrapper around a map that provides additional functionality
func NewDictionary ¶
func NewDictionary[T any]() *Dictionary[T]
NewDictionary creates a new dictionary
func NewDictionaryWithCapacity ¶
func NewDictionaryWithCapacity[T any](capacity int) *Dictionary[T]
Add a constructor that takes an initial capacity
func ToDictionary ¶
func ToDictionary[T any](m map[string]T) *Dictionary[T]
ToDictionary creates a new dictionary from a map m: The map to create the dictionary from
func (*Dictionary[T]) ContainsKey ¶
func (d *Dictionary[T]) ContainsKey(key string) bool
ContainsKey returns if the dictionary contains the given key key: The key to check for
func (*Dictionary[T]) ContainsValue ¶
func (d *Dictionary[T]) ContainsValue(value T) bool
ContainsValue returns if the dictionary contains the given value value: The value to check for
func (*Dictionary[T]) ContainsWhere ¶
func (d *Dictionary[T]) ContainsWhere(fn func(string, T) bool) bool
ContainsWhere returns if the dictionary contains a value that satisfies the given predicate fn: The predicate to check for
func (*Dictionary[T]) Count ¶
func (d *Dictionary[T]) Count() int
Count returns the number of values in the dictionary
func (*Dictionary[T]) Get ¶
func (d *Dictionary[T]) Get(key string) (T, bool)
Get returns the value in the dictionary for the given key key: The key to get the value for
func (*Dictionary[T]) Keys ¶
func (d *Dictionary[T]) Keys() []string
Keys returns the keys in the dictionary
func (*Dictionary[T]) Merge ¶
func (d *Dictionary[T]) Merge(dicts ...Dictionary[T]) *Dictionary[T]
Modify the Merge method to return the modified dictionary
func (*Dictionary[T]) MergeMaps ¶
func (d *Dictionary[T]) MergeMaps(maps ...map[string]T)
MergeMaps merges the given maps into the dictionary maps: The maps to merge
func (*Dictionary[T]) Remove ¶
func (d *Dictionary[T]) Remove(key string)
Remove removes the value in the dictionary for the given key key: The key to remove the value for
func (*Dictionary[T]) RemoveValue ¶
func (d *Dictionary[T]) RemoveValue(value T)
RemoveValue removes the given value from the dictionary value: The value to remove
func (*Dictionary[T]) RemoveWhere ¶
func (d *Dictionary[T]) RemoveWhere(fn func(string, T) bool)
RemoveWhere removes the value in the dictionary that satisfies the given predicate fn: The predicate to check for
func (*Dictionary[T]) Set ¶
func (d *Dictionary[T]) Set(key string, value T)
Set sets the value in the dictionary for the given key key: The key to set the value for value: The value to set
func (*Dictionary[T]) ToArray ¶
func (d *Dictionary[T]) ToArray() []T
ToArray returns the values in the dictionary as an array
func (*Dictionary[T]) ToList ¶
func (d *Dictionary[T]) ToList() List[T]
ToList returns the values in the dictionary as a list
func (*Dictionary[T]) ToMap ¶
func (d *Dictionary[T]) ToMap() map[string]T
ToMap returns the dictionary as a map
type List ¶
type List[T any] []T
func (List[T]) All ¶
All determines whether all elements of an array satisfy a condition predicate: The predicate to test each element against
func (List[T]) Any ¶
Any determines whether any element of an array satisfies a condition predicate: The predicate to test each element against
func (List[T]) Chunk ¶
Chunk returns a new array with elements grouped into chunks of the specified size size: The size of each chunk
func (List[T]) Contains ¶
Contains determines whether an array contains a specific value value: The value to locate in the array
func (List[T]) Count ¶
Count returns the number of elements in an array that satisfy a condition predicate: The predicate to test each element against
func (List[T]) Except ¶
Except returns the elements of an array that do not appear in a second array other: The array whose elements that also occur in the first array will cause those elements to be removed from the returned array
func (List[T]) Filter ¶
Filter removes all elements from an array that satisfy the predicate predicate: The predicate to test each element against
func (List[T]) Find ¶
Find returns the first element in the array that satisfies the predicate predicate: The predicate to test each element against
func (List[T]) FindIndex ¶
FindIndex returns the index of the first occurrence of a value in the array value: The value to locate in the array
func (List[T]) FindIndexWhere ¶
FindIndexWhere returns the index of the first element in the array that satisfies the predicate predicate: The predicate to test each element against
func (List[T]) FindLast ¶
func (l List[T]) FindLast(val T) T
FindLast returns the last element in the array that satisfies the predicate predicate: The predicate to test each element against
func (List[T]) FindLastIndex ¶
FindLastIndex returns the index of the last occurrence of a value in the array value: The value to locate in the array
func (List[T]) FindLastIndexWhere ¶
FindLastIndexWhere returns the index of the last element in the array that satisfies the predicate predicate: The predicate to test each element against
func (List[T]) FindLastWhere ¶
FindLastWhere returns the last element in the array that satisfies the predicate predicate: The predicate to test each element against
func (List[T]) ForEach ¶
ForEach executes an action for each element in the array in parallel action: The action to perform on each element
func (List[T]) Intersect ¶
Intersect returns the elements that appear in two arrays other: The array whose distinct elements that also appear in the first array will be returned
func (List[T]) Reduce ¶
func (l List[T]) Reduce(accumulator func(T, T) T, initialValue ...T) T
Reduce applies an accumulator function over an array accumulator: The accumulator function to use
func (List[T]) Remove ¶
Remove removes the first occurrence of a specific object from an array value: The value to remove from the array
func (List[T]) RemoveAt ¶
RemoveAt removes an element from an array at the specified index index: The index to remove at
func (List[T]) RemoveWhere ¶
RemoveWhere removes the first element in the array that satisfies the predicate predicate: The predicate to test each element against
func (List[T]) Replace ¶
Replace replaces the first occurrence of a value in an array with another value oldValue: The value to replace newValue: The value to replace with
func (List[T]) ReplaceAll ¶
ReplaceAll replaces all occurrences of a value in an array with another value oldValue: The value to replace newValue: The value to replace with
func (List[T]) ReplaceAllWhere ¶
ReplaceAllWhere replaces all occurrences of a value in an array with the result of the selector function value: The value to replace with predicate: The selector function to use
func (List[T]) ReplaceWhere ¶
ReplaceWhere replaces the first occurrence of a value in an array with the result of the selector function value: The value to replace with predicate: The selector function to use
func (List[T]) SequenceEqual ¶
SequenceEqual determines whether two arrays are equal other: The second array to compare
func (List[T]) Skip ¶
Skip returns a new array with the specified number of elements removed from the start of the array count: The number of elements to skip
func (List[T]) SkipLast ¶
SkipLast returns a new array with the specified number of elements removed from the end of the array count: The number of elements to skip
func (List[T]) SkipWhile ¶
SkipWhile returns a new array with elements removed from the start of the array while the predicate returns true predicate: The predicate to test each element against
func (List[T]) Slice ¶
Slice returns a new array with the elements from the specified start index to the specified end index start: The index to start at end: The index to end at
func (List[T]) SortWhere ¶
SortWhere sorts the elements of an array in place using the specified comparer function comparer: The comparer function to use
func (List[T]) Take ¶
Take returns a new array with the specified number of elements from the start of the array count: The number of elements to take
func (List[T]) TakeLast ¶
TakeLast returns a new array with the specified number of elements from the end of the array count: The number of elements to take
func (List[T]) TakeWhile ¶
TakeWhile returns a new array with elements from the start of the array while the predicate returns true predicate: The predicate to test each element against
func (List[T]) Union ¶
Union returns the elements that appear in either of two arrays other: The second array to search
type MapEntry ¶
type MapEntry[K comparable, V any] struct { Key K Value V }
MapEntry is a key-value pair of a map
func Entries ¶
func Entries[K comparable, V any](m map[K]V) []MapEntry[K, V]
Entries Returns a slice of key-value pairs from the map
type Queue ¶
type Queue[T any] struct { // contains filtered or unexported fields }
func (*Queue[T]) Contains ¶
Contains returns if the queue contains the given item item: The item to check for
func (*Queue[T]) ContainsWhere ¶
ContainsWhere returns if the queue contains an item that satisfies the given predicate fn: The predicate to check for
func (*Queue[T]) Dequeue ¶
func (q *Queue[T]) Dequeue() T
Dequeue removes and returns the item at the beginning of the queue
func (*Queue[T]) Enqueue ¶
func (q *Queue[T]) Enqueue(item T)
Enqueue adds an item to the end of the queue item: The item to add
func (*Queue[T]) Peek ¶
func (q *Queue[T]) Peek() T
Peek returns an element that is at the beginning of the queue without removing it
type Stack ¶
type Stack[T any] struct { // contains filtered or unexported fields }
func (*Stack[T]) Contains ¶
Contains returns if the stack contains the given item item: The item to check for
func (*Stack[T]) ContainsWhere ¶
ContainsWhere returns if the stack contains an item that satisfies the given predicate fn: The predicate to check for
func (*Stack[T]) Push ¶
func (s *Stack[T]) Push(item T)
Push pushes an item onto the stack item: The item to push