Documentation
¶
Overview ¶
Package sliceof provides named slice types that carry helper methods: Any, String, Int, Float, MapOfAny, MapOfString, and the generic Object[T].
Each is a plain []T under its methods, so it ranges, indexes, and serializes like the slice it wraps. What it adds is the Getter and Setter implementations that let the schema package address elements by path, along with the GroupBy helpers that report where a sorted slice changes value in a named field, for rendering group headers.
Together with mapof, these are the carrier types a JSON-Schema-shaped document is read into when there is no Go struct to bind to. For free functions over ordinary slices, see the slice package.
Index ¶
- type Any
- func (x *Any) Append(values ...any)
- func (x Any) At(index int) any
- func (x Any) Contains(value any) bool
- func (x Any) ContainsAll(values ...any) bool
- func (x Any) ContainsAny(values ...any) bool
- func (x Any) ContainsInterface(value any) bool
- func (x Any) Equal(value []any) bool
- func (x Any) Filter(fn func(any) bool) Any
- func (x Any) Find(fn func(any) bool) (any, bool)
- func (x Any) First() any
- func (x Any) FirstN(n int) Any
- func (x Any) GetAny(key string) any
- func (x Any) GetAnyOK(key string) (any, bool)
- func (x Any) GetBool(key string) bool
- func (x Any) GetBoolOK(key string) (bool, bool)
- func (x Any) GetFloat(key string) float64
- func (x Any) GetFloatOK(key string) (float64, bool)
- func (x Any) GetIndex(index int) (any, bool)
- func (x Any) GetInt(key string) int
- func (x Any) GetInt64(key string) int64
- func (x Any) GetInt64OK(key string) (int64, bool)
- func (x Any) GetIntOK(key string) (int, bool)
- func (x *Any) GetPointer(key string) (any, bool)
- func (x Any) GetString(key string) string
- func (x Any) GetStringOK(key string) (string, bool)
- func (x Any) GroupBy(field string) AnyGrouper
- func (x Any) IsEmpty() bool
- func (x Any) IsLength(length int) bool
- func (x Any) IsZero() bool
- func (x Any) Keys() []string
- func (x Any) Last() any
- func (x Any) Length() int
- func (x Any) NotEmpty() bool
- func (x Any) Range() iter.Seq2[int, any]
- func (x *Any) Remove(key string) bool
- func (x *Any) RemoveAt(index int) bool
- func (x Any) Reverse() Any
- func (x *Any) SetAny(key string, value any) bool
- func (x *Any) SetBool(key string, value bool) bool
- func (x *Any) SetFloat(key string, value float64) bool
- func (x *Any) SetIndex(index int, value any) bool
- func (x *Any) SetInt(key string, value int) bool
- func (x *Any) SetInt64(key string, value int64) bool
- func (x *Any) SetString(key string, value string) bool
- func (x *Any) SetValue(value any) error
- func (x Any) Shuffle() Any
- type AnyGrouper
- type Float
- func (x *Float) Append(values ...float64)
- func (x Float) At(index int) float64
- func (x Float) Contains(value float64) bool
- func (x Float) ContainsAll(values ...float64) bool
- func (x Float) ContainsAny(values ...float64) bool
- func (x Float) ContainsFloaterface(value any) bool
- func (x Float) Equal(value []float64) bool
- func (x Float) Filter(fn func(float64) bool) Float
- func (x Float) Find(fn func(float64) bool) (float64, bool)
- func (x Float) First() float64
- func (x Float) FirstN(n int) Float
- func (x Float) GetAny(key string) any
- func (x Float) GetAnyOK(key string) (any, bool)
- func (x Float) GetFloat(key string) float64
- func (x Float) GetFloatOK(key string) (float64, bool)
- func (x Float) GetIndex(index int) (any, bool)
- func (x Float) IsEmpty() bool
- func (x Float) IsLength(length int) bool
- func (x Float) IsZero() bool
- func (x Float) Keys() []string
- func (x Float) Last() float64
- func (x Float) Length() int
- func (x Float) NotContains(value float64) bool
- func (x Float) NotEmpty() bool
- func (x Float) NotEqual(value []float64) bool
- func (x Float) Range() iter.Seq2[int, float64]
- func (s *Float) Remove(key string) bool
- func (x *Float) RemoveAt(index int) bool
- func (x Float) Reverse() Float
- func (s *Float) SetFloat(key string, value float64) bool
- func (s *Float) SetIndex(index int, value any) bool
- func (s *Float) SetValue(value any) error
- func (x Float) Shuffle() Float
- type Int
- func (x *Int) Append(values ...int)
- func (x Int) At(index int) int
- func (x Int) Contains(value int) bool
- func (x Int) ContainsAll(values ...int) bool
- func (x Int) ContainsAny(values ...int) bool
- func (x Int) ContainsInterface(value any) bool
- func (x Int) Equal(value []int) bool
- func (x Int) Filter(fn func(int) bool) Int
- func (x Int) Find(fn func(int) bool) (int, bool)
- func (x Int) First() int
- func (x Int) FirstN(n int) Int
- func (x Int) GetAny(key string) any
- func (x Int) GetAnyOK(key string) (any, bool)
- func (x Int) GetIndex(index int) (any, bool)
- func (x Int) GetInt(key string) int
- func (x Int) GetIntOK(key string) (int, bool)
- func (x Int) IsEmpty() bool
- func (x Int) IsLength(length int) bool
- func (x Int) IsZero() bool
- func (x Int) Keys() []string
- func (x Int) Last() int
- func (x Int) Length() int
- func (x Int) NotContains(value int) bool
- func (x Int) NotEmpty() bool
- func (x Int) NotEqual(value []int) bool
- func (x Int) Range() iter.Seq2[int, int]
- func (s *Int) Remove(key string) bool
- func (x *Int) RemoveAt(index int) bool
- func (x Int) Reverse() Int
- func (s *Int) SetIndex(index int, value any) bool
- func (s *Int) SetInt(key string, value int) bool
- func (s *Int) SetValue(value any) error
- func (x Int) Shuffle() Int
- type MapOfAny
- func (x *MapOfAny) Append(values ...mapof.Any)
- func (x MapOfAny) At(index int) mapof.Any
- func (x MapOfAny) AtOK(index int) (mapof.Any, bool)
- func (x MapOfAny) Contains(match func(mapof.Any) bool) bool
- func (x MapOfAny) Filter(fn func(mapof.Any) bool) MapOfAny
- func (x MapOfAny) Find(fn func(mapof.Any) bool) (mapof.Any, bool)
- func (x MapOfAny) First() mapof.Any
- func (x MapOfAny) FirstN(n int) MapOfAny
- func (x MapOfAny) GetAny(key string) any
- func (x MapOfAny) GetAnyOK(key string) (any, bool)
- func (x MapOfAny) GetIndex(index int) (any, bool)
- func (x *MapOfAny) GetPointer(name string) (any, bool)
- func (x MapOfAny) GroupBy(field string) MapOfAnyGrouper
- func (x MapOfAny) IsEmpty() bool
- func (x MapOfAny) IsLength(length int) bool
- func (x MapOfAny) IsZero() bool
- func (x MapOfAny) Keys() []string
- func (x MapOfAny) Last() mapof.Any
- func (x MapOfAny) Length() int
- func (x MapOfAny) NotEmpty() bool
- func (x MapOfAny) Range() iter.Seq2[int, mapof.Any]
- func (x *MapOfAny) Remove(key string) bool
- func (x *MapOfAny) RemoveAt(index int) bool
- func (x MapOfAny) Reverse() MapOfAny
- func (s *MapOfAny) SetIndex(index int, value any) bool
- func (s *MapOfAny) SetValue(value any) error
- func (x MapOfAny) Shuffle() MapOfAny
- type MapOfAnyGrouper
- type MapOfString
- func (x *MapOfString) Append(values ...mapof.String)
- func (x MapOfString) At(index int) mapof.String
- func (x MapOfString) AtOK(index int) (mapof.String, bool)
- func (x MapOfString) Contains(match func(mapof.String) bool) bool
- func (x MapOfString) Filter(fn func(mapof.String) bool) MapOfString
- func (x MapOfString) Find(fn func(mapof.String) bool) (mapof.String, bool)
- func (x MapOfString) First() mapof.String
- func (x MapOfString) FirstN(n int) MapOfString
- func (x MapOfString) GetAny(key string) any
- func (x MapOfString) GetAnyOK(key string) (any, bool)
- func (x MapOfString) GetIndex(index int) (any, bool)
- func (x *MapOfString) GetPointer(name string) (any, bool)
- func (x MapOfString) GroupBy(field string) MapOfStringGrouper
- func (x MapOfString) IsEmpty() bool
- func (x MapOfString) IsLength(length int) bool
- func (x MapOfString) IsZero() bool
- func (x MapOfString) Keys() []string
- func (x MapOfString) Last() mapof.String
- func (x MapOfString) Length() int
- func (x MapOfString) NotEmpty() bool
- func (x MapOfString) Range() iter.Seq2[int, mapof.String]
- func (x *MapOfString) Remove(key string) bool
- func (x *MapOfString) RemoveAt(index int) bool
- func (x MapOfString) Reverse() MapOfString
- func (s *MapOfString) SetIndex(index int, value any) bool
- func (s *MapOfString) SetValue(value any) error
- func (x MapOfString) Shuffle() MapOfString
- type MapOfStringGrouper
- type Object
- func (x *Object[T]) Append(values ...T)
- func (x Object[T]) At(index int) T
- func (x Object[T]) AtOK(index int) (T, bool)
- func (x Object[T]) Contains(match func(T) bool) bool
- func (x Object[T]) Filter(fn func(T) bool) Object[T]
- func (x Object[T]) Find(fn func(T) bool) (T, bool)
- func (x Object[T]) First() T
- func (x Object[T]) FirstN(n int) Object[T]
- func (x Object[T]) GetAny(key string) any
- func (x Object[T]) GetAnyOK(key string) (any, bool)
- func (x Object[T]) GetIndex(index int) (any, bool)
- func (x *Object[T]) GetPointer(name string) (any, bool)
- func (x Object[T]) GroupBy(field string) ObjectGrouper[T]
- func (x Object[T]) IsEmpty() bool
- func (x Object[T]) IsLength(length int) bool
- func (x Object[T]) IsZero() bool
- func (x Object[T]) Keys() []string
- func (x Object[T]) Last() T
- func (x Object[T]) Length() int
- func (x Object[T]) NotEmpty() bool
- func (x Object[T]) Range() iter.Seq2[int, T]
- func (x *Object[T]) Remove(key string) bool
- func (x *Object[T]) RemoveAt(index int) bool
- func (x Object[T]) Reverse() Object[T]
- func (s *Object[T]) SetIndex(index int, value any) bool
- func (s *Object[T]) SetValue(value any) error
- func (x Object[T]) Shuffle() Object[T]
- type ObjectGrouper
- type String
- func (x *String) Append(values ...string)
- func (x String) At(index int) string
- func (x String) Contains(value string) bool
- func (x String) ContainsAll(values ...string) bool
- func (x String) ContainsAny(values ...string) bool
- func (x String) ContainsInterface(value any) bool
- func (x String) Equal(value []string) bool
- func (x String) Find(fn func(string) bool) (string, bool)
- func (x String) First() string
- func (x String) FirstN(n int) String
- func (x String) GetAny(key string) any
- func (x String) GetAnyOK(key string) (any, bool)
- func (x String) GetIndex(index int) (any, bool)
- func (x String) GetString(key string) string
- func (x String) GetStringOK(key string) (string, bool)
- func (x String) IsEmpty() bool
- func (x String) IsLength(length int) bool
- func (x String) IsZero() bool
- func (x String) Join(delimiter string) string
- func (x String) Keys() []string
- func (x String) Last() string
- func (x String) Length() int
- func (x String) NotContains(value string) bool
- func (x String) NotEmpty() bool
- func (x String) NotEqual(value []string) bool
- func (x String) Range() iter.Seq2[int, string]
- func (x *String) Remove(key string) bool
- func (x *String) RemoveAt(index int) bool
- func (x String) Reverse() String
- func (x *String) SetIndex(index int, value any) bool
- func (x *String) SetString(key string, value string) bool
- func (x *String) SetValue(value any) error
- func (x String) Shuffle() String
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Any ¶
type Any []any
Any is a slice of arbitrary values with typed, coercing accessors and schema-traversal support.
func NewAny ¶ added in v0.11.0
NewAny returns an Any slice containing the provided values (or an empty slice if none are given).
func (Any) At ¶ added in v0.21.5
At returns a bound-safe element from the slice. If the index is out of bounds, then `At` returns the zero value for the slice type
func (Any) Contains ¶ added in v0.21.4
Contains returns TRUE if the slice contains the specified value
func (Any) ContainsAll ¶ added in v0.21.4
ContainsAll returns TRUE if the slice contains all of the specified values
func (Any) ContainsAny ¶ added in v0.21.4
ContainsAny returns TRUE if the slice contains any of the specified values
func (Any) ContainsInterface ¶ added in v0.25.9
ContainsInterface returns TRUE if the provided generic value is contained in the slice.
func (Any) Equal ¶ added in v0.21.4
Equal returns TRUE if the slice contains exactly the same elements as the specified value
func (Any) Filter ¶ added in v0.25.27
Filter returns all elements in the slice that satisfies the provided function.
func (Any) Find ¶ added in v0.23.0
Find returns the first element in the slice that satisfies the provided function.
func (Any) First ¶ added in v0.10.0
First returns the first element in the slice, or nil if the slice is empty
func (Any) FirstN ¶ added in v0.21.4
FirstN returns the first "n" elements in the slice, or all elements if "n" is greater than the length of the slice. A negative "n" returns an empty slice.
func (Any) GetAny ¶
GetAny returns the value for the key, or nil if absent. The key is a numeric index or "last"/"next".
func (Any) GetAnyOK ¶ added in v0.10.0
GetAnyOK returns the value for the key and TRUE if present. The key is a numeric index or "last"/"next".
func (Any) GetBool ¶
GetBool returns the value for the key coerced to bool, or FALSE if absent or not coercible.
func (Any) GetBoolOK ¶ added in v0.11.0
GetBoolOK returns the value for the key coerced to bool, with TRUE if it was present and coercible.
func (Any) GetFloat ¶
GetFloat returns the value for the key coerced to float64, or 0 if absent or not coercible.
func (Any) GetFloatOK ¶ added in v0.10.0
GetFloatOK returns the value for the key coerced to float64, with TRUE if it was present and coercible.
func (Any) GetIndex ¶ added in v0.22.0
GetIndex returns the value at the index and TRUE, or (nil, false) if out of range.
func (Any) GetInt ¶
GetInt returns the value for the key coerced to int, or 0 if absent or not coercible.
func (Any) GetInt64 ¶
GetInt64 returns the value for the key coerced to int64, or 0 if absent or not coercible.
func (Any) GetInt64OK ¶ added in v0.11.0
GetInt64OK returns the value for the key coerced to int64, with TRUE if it was present and coercible.
func (Any) GetIntOK ¶ added in v0.11.0
GetIntOK returns the value for the key coerced to int, with TRUE if it was present and coercible.
func (*Any) GetPointer ¶ added in v0.14.0
GetPointer returns a pointer to the element at the key index, growing the slice as needed (implements schema PointerGetter).
func (Any) GetString ¶
GetString returns the value for the key coerced to string, or "" if absent or not coercible.
func (Any) GetStringOK ¶ added in v0.11.0
GetStringOK returns the value for the key coerced to string, with TRUE if it was present and coercible.
func (Any) GroupBy ¶ added in v0.25.20
func (x Any) GroupBy(field string) AnyGrouper
GroupBy returns a grouper that detects boundaries in this slice using the named field.
func (Any) IsLength ¶ added in v0.10.0
IsLength returns TRUE if the slice contains exactly "length" elements
func (Any) IsZero ¶ added in v0.25.22
IsZero returns TRUE if the slice contains no elements. This is an alias for IsEmpty, and implements the `Zeroer` interface used by many packages (including go/json)
func (Any) Keys ¶ added in v0.22.0
Keys returns a slice of strings representing the indexes of this slice
func (Any) Last ¶ added in v0.10.0
Last returns the last element in the slice, or nil if the slice is empty
func (Any) NotEmpty ¶ added in v0.16.3
NotEmpty returns TRUE if the slice contains at least one element
func (Any) Range ¶ added in v0.25.11
Range returns an iterator that yields each value in this slice.
func (Any) Reverse ¶ added in v0.10.0
Reverse returns a new slice with the elements in reverse order
func (*Any) SetAny ¶
SetAny stores the value at the key index (growing the slice to fit), returning FALSE for a non-index key.
func (*Any) SetIndex ¶ added in v0.24.0
SetIndex stores the value at the index, growing the slice to fit if necessary.
type AnyGrouper ¶ added in v0.25.20
type AnyGrouper struct {
// contains filtered or unexported fields
}
AnyGrouper reports group boundaries within an Any slice, grouped by a named field.
func (AnyGrouper) IsFooter ¶ added in v0.25.20
func (grouper AnyGrouper) IsFooter(index int) bool
IsFooter returns TRUE if the element at index ends a group.
func (AnyGrouper) IsHeader ¶ added in v0.25.20
func (grouper AnyGrouper) IsHeader(index int) bool
IsHeader returns TRUE if the element at index begins a new group.
type Float ¶
type Float []float64
Float is a slice of float64 values with typed accessors and schema-traversal support.
func NewFloat ¶ added in v0.11.0
NewFloat returns a Float slice containing the provided values (or an empty slice if none are given).
func (Float) At ¶ added in v0.21.5
At returns a bound-safe element from the slice. If the index is out of bounds, then `At` returns the zero value for the slice type
func (Float) Contains ¶ added in v0.11.2
Contains returns TRUE if the slice contains the specified value
func (Float) ContainsAll ¶ added in v0.14.0
ContainsAll returns TRUE if the slice contains all of the specified values
func (Float) ContainsAny ¶ added in v0.14.0
ContainsAny returns TRUE if the slice contains any of the specified values
func (Float) ContainsFloaterface ¶ added in v0.25.21
ContainsFloaterface returns TRUE if the provided generic value is contained in the slice.
func (Float) Equal ¶ added in v0.11.2
Equal returns TRUE if the slice contains exactly the same elements as the "value" slice
func (Float) Filter ¶ added in v0.25.27
Filter returns all elements in the slice that satisfies the provided function.
func (Float) Find ¶ added in v0.25.21
Find returns the first element in the slice that satisfies the provided function.
func (Float) First ¶ added in v0.10.0
First returns the first element in the slice, or nil if the slice is empty
func (Float) FirstN ¶ added in v0.21.4
FirstN returns the first "n" elements in the slice, or all elements if "n" is greater than the length of the slice. A negative "n" returns an empty slice.
func (Float) GetAnyOK ¶ added in v0.25.21
GetAnyOK returns the requested property as an any type and a boolean TRUE/FALSE value indicating whether the value was found
func (Float) GetFloatOK ¶ added in v0.10.0
GetFloatOK returns the requested property as a float64 type and a boolean TRUE/FALSE value indicating whether the value was found
func (Float) GetIndex ¶ added in v0.26.0
GetIndex returns the value at the specified index, and a boolean indicating success
func (Float) IsLength ¶ added in v0.10.0
IsLength returns TRUE if the slice contains exactly "length" elements
func (Float) IsZero ¶ added in v0.25.22
IsZero returns TRUE if the slice contains no elements. This is an alias for IsEmpty, and implements the `Zeroer` interface used by many packages (including go/json)
func (Float) Keys ¶ added in v0.25.21
Keys returns a slice of float64s representing the indexes of this slice
func (Float) Last ¶ added in v0.10.0
Last returns the last element in the slice, or nil if the slice is empty
func (Float) NotContains ¶ added in v0.25.21
NotContains returns TRUE if the slice does not contain the provided value.
func (Float) NotEmpty ¶ added in v0.16.3
NotEmpty returns TRUE if the slice contains at least one element
func (Float) NotEqual ¶ added in v0.25.21
NotEqual returns TRUE if the slice DOES NOT contain exactly the same elements as the "value" slice
func (Float) Range ¶ added in v0.25.21
Range returns an iterator that yields each value in this slice.
func (Float) Reverse ¶ added in v0.10.0
Reverse modifies the slice with the elements in reverse order
func (*Float) SetFloat ¶
SetFloat sets the value at the specified key, growing the slice if necessary
func (*Float) SetIndex ¶ added in v0.25.21
SetIndex sets the value at the specified index, growing the slice if necessary
type Int ¶
type Int []int
Int is a slice of int values with typed accessors and schema-traversal support.
func NewInt ¶ added in v0.11.0
NewInt returns an Int slice containing the provided values (or an empty slice if none are given).
func (Int) At ¶ added in v0.21.5
At returns a bound-safe element from the slice. If the index is out of bounds, then `At` returns the zero value for the slice type
func (Int) Contains ¶ added in v0.11.2
Contains returns TRUE if the slice contains the specified value
func (Int) ContainsAll ¶ added in v0.14.0
ContainsAll returns TRUE if the slice contains all of the specified values
func (Int) ContainsAny ¶ added in v0.14.0
ContainsAny returns TRUE if the slice contains any of the specified values
func (Int) ContainsInterface ¶ added in v0.25.9
ContainsInterface returns TRUE if the provided generic value is contained in the slice.
func (Int) Equal ¶ added in v0.11.2
Equal returns TRUE if the slice contains exactly the same elements as the "value" slice
func (Int) Filter ¶ added in v0.25.27
Filter returns all elements in the slice that satisfies the provided function.
func (Int) Find ¶ added in v0.25.8
Find returns the first element in the slice that satisfies the provided function.
func (Int) First ¶ added in v0.10.0
First returns the first element in the slice, or nil if the slice is empty
func (Int) FirstN ¶ added in v0.21.4
FirstN returns the first "n" elements in the slice, or all elements if "n" is greater than the length of the slice. A negative "n" returns an empty slice.
func (Int) GetAnyOK ¶ added in v0.25.8
GetAnyOK returns the value for the key index and TRUE if present.
func (Int) GetIndex ¶ added in v0.26.0
GetIndex returns the value at the specified index, and a boolean indicating success
func (Int) GetIntOK ¶ added in v0.11.0
GetIntOK returns the value for the key index coerced to int, with TRUE if present.
func (Int) IsLength ¶ added in v0.10.0
IsLength returns TRUE if the slice contains exactly "length" elements
func (Int) IsZero ¶ added in v0.25.22
IsZero returns TRUE if the slice contains no elements. This is an alias for IsEmpty, and implements the `Zeroer` interface used by many packages (including go/json)
func (Int) Keys ¶ added in v0.25.8
Keys returns a slice of ints representing the indexes of this slice
func (Int) Last ¶ added in v0.10.0
Last returns the last element in the slice, or nil if the slice is empty
func (Int) NotContains ¶ added in v0.25.8
NotContains returns TRUE if the slice does not contain the provided value.
func (Int) NotEmpty ¶ added in v0.16.3
NotEmpty returns TRUE if the slice contains at least one element
func (Int) NotEqual ¶ added in v0.25.8
NotEqual returns TRUE if the slice DOES NOT contain exactly the same elements as the "value" slice
func (Int) Range ¶ added in v0.25.11
Range returns an iterator that yields each value in this slice.
func (*Int) SetIndex ¶ added in v0.25.8
SetIndex stores the value at the index, growing the slice to fit if necessary.
type MapOfAny ¶ added in v0.25.24
MapOfAny is a slice of mapof.Any objects with typed accessors and schema-traversal support.
func NewMapOfAny ¶ added in v0.25.24
NewMapOfAny returns a MapOfAny slice containing the provided values (or an empty slice if none are given).
func (*MapOfAny) Append ¶ added in v0.25.24
Append adds one or more elements to the end of the slice
func (MapOfAny) At ¶ added in v0.25.24
At returns a bound-safe element from the slice. If the index is out of bounds, then `At` returns the zero value for the slice type
func (MapOfAny) AtOK ¶ added in v0.25.24
AtOK returns the element at the index and TRUE, or the zero value and FALSE if out of range.
func (MapOfAny) Contains ¶ added in v0.25.24
Contains returns TRUE if the "match" function returns TRUE for any element in the slice
func (MapOfAny) Filter ¶ added in v0.25.27
Filter returns all elements in the slice that satisfies the provided function.
func (MapOfAny) Find ¶ added in v0.25.24
Find returns the first element in the slice that satisfies the provided function.
func (MapOfAny) First ¶ added in v0.25.24
First returns the first element in the slice, or nil if the slice is empty
func (MapOfAny) FirstN ¶ added in v0.25.24
FirstN returns the first "n" elements in the slice, or all elements if "n" is greater than the length of the slice. A negative "n" returns an empty slice.
func (MapOfAny) GetAny ¶ added in v0.25.24
GetAny returns the value for the key index, or nil if absent.
func (MapOfAny) GetAnyOK ¶ added in v0.25.24
GetAnyOK returns the value for the key index and TRUE if present.
func (MapOfAny) GetIndex ¶ added in v0.26.0
GetIndex returns the value at the specified index, and a boolean indicating success
func (*MapOfAny) GetPointer ¶ added in v0.25.24
GetPointer returns a pointer to the element at the key index, growing the slice as needed (implements schema PointerGetter).
func (MapOfAny) GroupBy ¶ added in v0.25.24
func (x MapOfAny) GroupBy(field string) MapOfAnyGrouper
GroupBy returns a grouper that detects boundaries in this slice using the named field.
func (MapOfAny) IsLength ¶ added in v0.25.24
IsLength returns TRUE if the slice contains exactly "length" elements
func (MapOfAny) IsZero ¶ added in v0.25.24
IsZero returns TRUE if the slice contains no elements. This is an alias for IsEmpty, and implements the `Zeroer` interface used by many packages (including go/json)
func (MapOfAny) Keys ¶ added in v0.25.24
Keys returns a slice of strings representing the indexes of this slice
func (MapOfAny) Last ¶ added in v0.25.24
Last returns the last element in the slice, or nil if the slice is empty
func (MapOfAny) NotEmpty ¶ added in v0.25.24
NotEmpty returns TRUE if the slice contains at least one element
func (MapOfAny) Range ¶ added in v0.25.24
Range returns an iterator that yields each value in this slice.
func (MapOfAny) Reverse ¶ added in v0.25.24
Reverse returns a new slice with the elements in reverse order
func (*MapOfAny) SetIndex ¶ added in v0.25.24
SetIndex stores the value at the index, growing the slice to fit if necessary.
type MapOfAnyGrouper ¶ added in v0.25.24
type MapOfAnyGrouper struct {
// contains filtered or unexported fields
}
MapOfAnyGrouper reports group boundaries within a MapOfAny slice, grouped by a named field.
func (MapOfAnyGrouper) IsFooter ¶ added in v0.25.24
func (grouper MapOfAnyGrouper) IsFooter(index int) bool
IsFooter returns TRUE if the element at index ends a group.
func (MapOfAnyGrouper) IsHeader ¶ added in v0.25.24
func (grouper MapOfAnyGrouper) IsHeader(index int) bool
IsHeader returns TRUE if the element at index begins a new group.
type MapOfString ¶ added in v0.25.24
MapOfString is a slice of mapof.String objects with typed accessors and schema-traversal support.
func NewMapOfString ¶ added in v0.25.24
func NewMapOfString(values ...mapof.String) MapOfString
NewMapOfString returns a MapOfString slice containing the provided values (or an empty slice if none are given).
func (*MapOfString) Append ¶ added in v0.25.24
func (x *MapOfString) Append(values ...mapof.String)
Append adds one or more elements to the end of the slice
func (MapOfString) At ¶ added in v0.25.24
func (x MapOfString) At(index int) mapof.String
At returns a bound-safe element from the slice. If the index is out of bounds, then `At` returns the zero value for the slice type
func (MapOfString) AtOK ¶ added in v0.25.24
func (x MapOfString) AtOK(index int) (mapof.String, bool)
AtOK returns the element at the index and TRUE, or the zero value and FALSE if out of range.
func (MapOfString) Contains ¶ added in v0.25.24
func (x MapOfString) Contains(match func(mapof.String) bool) bool
Contains returns TRUE if the "match" function returns TRUE for any element in the slice
func (MapOfString) Filter ¶ added in v0.25.27
func (x MapOfString) Filter(fn func(mapof.String) bool) MapOfString
Filter returns all elements in the slice that satisfies the provided function.
func (MapOfString) Find ¶ added in v0.25.24
Find returns the first element in the slice that satisfies the provided function.
func (MapOfString) First ¶ added in v0.25.24
func (x MapOfString) First() mapof.String
First returns the first element in the slice, or nil if the slice is empty
func (MapOfString) FirstN ¶ added in v0.25.24
func (x MapOfString) FirstN(n int) MapOfString
FirstN returns the first "n" elements in the slice, or all elements if "n" is greater than the length of the slice. A negative "n" returns an empty slice.
func (MapOfString) GetAny ¶ added in v0.25.24
func (x MapOfString) GetAny(key string) any
GetAny returns the value for the key index, or nil if absent.
func (MapOfString) GetAnyOK ¶ added in v0.25.24
func (x MapOfString) GetAnyOK(key string) (any, bool)
GetAnyOK returns the value for the key index and TRUE if present.
func (MapOfString) GetIndex ¶ added in v0.26.0
func (x MapOfString) GetIndex(index int) (any, bool)
GetIndex returns the value at the specified index, and a boolean indicating success
func (*MapOfString) GetPointer ¶ added in v0.25.24
func (x *MapOfString) GetPointer(name string) (any, bool)
GetPointer returns a pointer to the element at the key index, growing the slice as needed (implements schema PointerGetter).
func (MapOfString) GroupBy ¶ added in v0.25.24
func (x MapOfString) GroupBy(field string) MapOfStringGrouper
GroupBy returns a grouper that detects boundaries in this slice using the named field.
func (MapOfString) IsEmpty ¶ added in v0.25.24
func (x MapOfString) IsEmpty() bool
IsEmpty returns TRUE if the slice contains no elements
func (MapOfString) IsLength ¶ added in v0.25.24
func (x MapOfString) IsLength(length int) bool
IsLength returns TRUE if the slice contains exactly "length" elements
func (MapOfString) IsZero ¶ added in v0.25.24
func (x MapOfString) IsZero() bool
IsZero returns TRUE if the slice contains no elements. This is an alias for IsEmpty, and implements the `Zeroer` interface used by many packages (including go/json)
func (MapOfString) Keys ¶ added in v0.25.24
func (x MapOfString) Keys() []string
Keys returns a slice of strings representing the indexes of this slice
func (MapOfString) Last ¶ added in v0.25.24
func (x MapOfString) Last() mapof.String
Last returns the last element in the slice, or nil if the slice is empty
func (MapOfString) Length ¶ added in v0.25.24
func (x MapOfString) Length() int
Length returns the number of elements in the slice
func (MapOfString) NotEmpty ¶ added in v0.25.24
func (x MapOfString) NotEmpty() bool
NotEmpty returns TRUE if the slice contains at least one element
func (MapOfString) Range ¶ added in v0.25.24
Range returns an iterator that yields each value in this slice.
func (*MapOfString) Remove ¶ added in v0.25.24
func (x *MapOfString) Remove(key string) bool
Remove deletes the element identified by the key index.
func (*MapOfString) RemoveAt ¶ added in v0.25.24
func (x *MapOfString) RemoveAt(index int) bool
RemoveAt deletes the element at the given index.
func (MapOfString) Reverse ¶ added in v0.25.24
func (x MapOfString) Reverse() MapOfString
Reverse returns a new slice with the elements in reverse order
func (*MapOfString) SetIndex ¶ added in v0.25.24
func (s *MapOfString) SetIndex(index int, value any) bool
SetIndex stores the value at the index, growing the slice to fit if necessary.
func (*MapOfString) SetValue ¶ added in v0.25.24
func (s *MapOfString) SetValue(value any) error
SetValue replaces the entire slice with the provided value, if it can be converted.
func (MapOfString) Shuffle ¶ added in v0.25.24
func (x MapOfString) Shuffle() MapOfString
Shuffle randomizes the order of the elements in the slice
type MapOfStringGrouper ¶ added in v0.25.24
type MapOfStringGrouper struct {
// contains filtered or unexported fields
}
MapOfStringGrouper reports group boundaries within a MapOfString slice, grouped by a named field.
func (MapOfStringGrouper) IsFooter ¶ added in v0.25.24
func (grouper MapOfStringGrouper) IsFooter(index int) bool
IsFooter returns TRUE if the element at index ends a group.
func (MapOfStringGrouper) IsHeader ¶ added in v0.25.24
func (grouper MapOfStringGrouper) IsHeader(index int) bool
IsHeader returns TRUE if the element at index begins a new group.
type Object ¶ added in v0.10.0
type Object[T any] []T
Object is a slice of values of a single type T, with typed accessors and schema-traversal support.
func NewObject ¶ added in v0.11.0
NewObject returns an Object slice containing the provided values (or an empty slice if none are given).
func (*Object[T]) Append ¶ added in v0.12.0
func (x *Object[T]) Append(values ...T)
Append adds one or more elements to the end of the slice
func (Object[T]) At ¶ added in v0.21.5
At returns a bound-safe element from the slice. If the index is out of bounds, then `At` returns the zero value for the slice type
func (Object[T]) AtOK ¶ added in v0.22.0
AtOK returns the element at the index and TRUE, or the zero value and FALSE if out of range.
func (Object[T]) Contains ¶ added in v0.24.4
Contains returns TRUE if the "match" function returns TRUE for any element in the slice
func (Object[T]) Filter ¶ added in v0.25.27
Filter returns all elements in the slice that satisfies the provided function.
func (Object[T]) Find ¶ added in v0.23.0
Find returns the first element in the slice that satisfies the provided function.
func (Object[T]) First ¶ added in v0.10.0
func (x Object[T]) First() T
First returns the first element in the slice, or nil if the slice is empty
func (Object[T]) FirstN ¶ added in v0.21.4
FirstN returns the first "n" elements in the slice, or all elements if "n" is greater than the length of the slice. A negative "n" returns an empty slice.
func (Object[T]) GetAny ¶ added in v0.22.0
GetAny returns the value for the key index, or nil if absent.
func (Object[T]) GetAnyOK ¶ added in v0.22.0
GetAnyOK returns the value for the key index and TRUE if present.
func (Object[T]) GetIndex ¶ added in v0.26.0
GetIndex returns the value at the specified index, and a boolean indicating success
func (*Object[T]) GetPointer ¶ added in v0.14.0
GetPointer returns a pointer to the element at the key index, growing the slice as needed (implements schema PointerGetter).
func (Object[T]) GroupBy ¶ added in v0.25.20
func (x Object[T]) GroupBy(field string) ObjectGrouper[T]
GroupBy returns an Grouper object for this slice
func (Object[T]) IsLength ¶ added in v0.10.0
IsLength returns TRUE if the slice contains exactly "length" elements
func (Object[T]) IsZero ¶ added in v0.25.22
IsZero returns TRUE if the slice contains no elements. This is an alias for IsEmpty, and implements the `Zeroer` interface used by many packages (including go/json)
func (Object[T]) Keys ¶ added in v0.22.0
Keys returns a slice of strings representing the indexes of this slice
func (Object[T]) Last ¶ added in v0.10.0
func (x Object[T]) Last() T
Last returns the last element in the slice, or nil if the slice is empty
func (Object[T]) NotEmpty ¶ added in v0.16.3
NotEmpty returns TRUE if the slice contains at least one element
func (Object[T]) Range ¶ added in v0.25.11
Range returns an iterator that yields each value in this slice.
func (Object[T]) Reverse ¶ added in v0.10.0
Reverse returns a new slice with the elements in reverse order
func (*Object[T]) SetIndex ¶ added in v0.24.0
SetIndex stores the value at the index, growing the slice to fit if necessary.
type ObjectGrouper ¶ added in v0.25.20
type ObjectGrouper[T any] struct { // contains filtered or unexported fields }
ObjectGrouper calculates group headers and footers for a sliceof.Object
func (ObjectGrouper[T]) IsFooter ¶ added in v0.25.20
func (grouper ObjectGrouper[T]) IsFooter(index int) bool
IsFooter returns TRUE if the record at the given index is the LAST item in a group
func (ObjectGrouper[T]) IsHeader ¶ added in v0.25.20
func (grouper ObjectGrouper[T]) IsHeader(index int) bool
IsHeader returns TRUE if the record at the given index is the FIRST item in a group.
type String ¶
type String []string
String is a slice of string values with typed accessors and schema-traversal support.
func NewString ¶ added in v0.11.0
NewString returns a String slice containing the provided values (or an empty slice if none are given).
func (String) At ¶ added in v0.21.5
At returns a bound-safe element from the slice. If the index is out of bounds, then `At` returns the zero value for the slice type
func (String) Contains ¶ added in v0.11.2
Contains returns TRUE if the slice contains the specified value
func (String) ContainsAll ¶ added in v0.14.0
ContainsAll returns TRUE if the slice contains all of the specified values
func (String) ContainsAny ¶ added in v0.14.0
ContainsAny returns TRUE if the slice contains any of the specified values
func (String) ContainsInterface ¶ added in v0.25.9
ContainsInterface returns TRUE if the provided generic value is contained in the slice.
func (String) Equal ¶ added in v0.11.2
Equal returns TRUE if the slice contains exactly the same elements as the "value" slice
func (String) Find ¶ added in v0.23.0
Find returns the first element in the slice that satisfies the provided function.
func (String) First ¶ added in v0.10.0
First returns the first element in the slice, or nil if the slice is empty
func (String) FirstN ¶ added in v0.21.5
FirstN returns the first "n" elements in the slice, or all elements if "n" is greater than the length of the slice. A negative "n" returns an empty slice.
func (String) GetAny ¶ added in v0.22.0
GetAny returns the value at the specified key as an "any" type
func (String) GetAnyOK ¶ added in v0.22.0
GetAnyOK returns the value at the specified key as an "any" type, along with a boolean indicating success
func (String) GetIndex ¶ added in v0.26.0
GetIndex returns the value at the specified index, and a boolean indicating success
func (String) GetStringOK ¶ added in v0.11.0
GetStringOK returns the string value at the specified key, along with a boolean indicating success
func (String) IsLength ¶ added in v0.10.0
IsLength returns TRUE if the slice contains exactly "length" elements
func (String) IsZero ¶ added in v0.25.22
IsZero returns TRUE if the slice contains no elements. This is an alias for IsEmpty, and implements the `Zeroer` interface used by many packages (including go/json)
func (String) Join ¶ added in v0.19.1
Join concatenates all elements of the slice into a single string, separated by the specified delimiter
func (String) Keys ¶ added in v0.22.0
Keys returns a slice of strings representing the indexes of this slice
func (String) Last ¶ added in v0.10.0
Last returns the last element in the slice, or nil if the slice is empty
func (String) NotContains ¶ added in v0.25.8
NotContains returns TRUE if the slice does not contain the provided value.
func (String) NotEmpty ¶ added in v0.16.3
NotEmpty returns TRUE if the slice contains at least one element
func (String) NotEqual ¶ added in v0.24.8
NotEqual returns TRUE if the slice DOES NOT contain exactly the same elements as the "value" slice
func (String) Range ¶ added in v0.25.11
Range returns an iterator that yields each value in this slice.
func (String) Reverse ¶ added in v0.10.0
Reverse modifies the slice with the elements in reverse order