Documentation
¶
Index ¶
- type ComparableSlice
- type OrderedSlice
- type Slice
- func (s *Slice[T]) Append(items ...T)
- func (s Slice[T]) At(index int) T
- func (s *Slice[T]) Clear()
- func (s Slice[T]) Contains(v T) bool
- func (s Slice[T]) Copy() Slice[T]
- func (s *Slice[T]) Delete(i, j int)
- func (s Slice[T]) Elem(index int) Tdeprecated
- func (s Slice[T]) Equal(v []T) bool
- func (s Slice[T]) EqualFunc(v []T, f func(e1, e2 T) bool) bool
- func (s Slice[T]) EqualSlice(v Slice[T]) bool
- func (s Slice[T]) EqualSliceFunc(v Slice[T], f func(e1, e2 T) bool) bool
- func (s *Slice[T]) Filter(f func(T) bool)
- func (s Slice[T]) Index(v T) int
- func (s *Slice[T]) Insert(index int, items ...T)
- func (s Slice[T]) IsEmpty() bool
- func (s Slice[T]) Len() int
- func (s *Slice[T]) Pop(index int)
- func (s *Slice[T]) Range(yield func(k int, v T) bool)
- func (s *Slice[T]) Remove(v T)
- func (s *Slice[T]) RemoveDuplicates()
- func (s *Slice[T]) Reverse()
- func (s Slice[T]) S() []T
- func (s *Slice[T]) SliceP() *[]T
- func (s *Slice[T]) SortFunc(f func(a, b T) int)
- func (s Slice[T]) String() (txt string)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ComparableSlice ¶
type ComparableSlice[T comparable] struct { Slice[T] }
func NewComparableSlice ¶
func NewComparableSlice[T comparable](slice ...T) ComparableSlice[T]
Creates a new object of ComparableSlice wich only implements the comparable interface.
func (ComparableSlice[T]) Contains ¶
func (s ComparableSlice[T]) Contains(v T) bool
A shortcut to slices.Contains.
func (ComparableSlice[T]) Copy ¶
func (s ComparableSlice[T]) Copy() ComparableSlice[T]
Creates a copy of the current object, which is not the same as the current object.
implements the slices.Clone function on the internal slice to create the new structure.
func (ComparableSlice[T]) Equal ¶
func (s ComparableSlice[T]) Equal(v []T) bool
A shortcut to slices.Equal.
func (ComparableSlice[T]) Index ¶
func (s ComparableSlice[T]) Index(v T) int
A shortcut to slices.Index.
type OrderedSlice ¶
type OrderedSlice[T cmp.Ordered] struct { ComparableSlice[T] }
func NewOrderedSlice ¶
func NewOrderedSlice[T cmp.Ordered](slice ...T) OrderedSlice[T]
Create a new OrderedSlice object. Which only implements the cmp.Ordered and comparable interfaces.
func (OrderedSlice[T]) BinarySearch ¶
func (s OrderedSlice[T]) BinarySearch(v T) (int, bool)
A shortcut to slices.BinarySearch.
func (OrderedSlice[T]) Copy ¶
func (s OrderedSlice[T]) Copy() OrderedSlice[T]
Creates a copy of the current object, which is not the same as the current object.
implements the slices.Clone function on the internal slice to create the new structure.
func (OrderedSlice[T]) IsSorted ¶ added in v1.1.0
func (s OrderedSlice[T]) IsSorted() bool
A shortcut to slices.IsSorted.
type Slice ¶
type Slice[T any] struct { // contains filtered or unexported fields }
func (*Slice[T]) Append ¶
func (s *Slice[T]) Append(items ...T)
Equivalent to slice = append(slice,myElems...).
func (*Slice[T]) Clear ¶
func (s *Slice[T]) Clear()
Removes all slice elements leaving a slice with length 0 and 0 elements, but not nil.
func (Slice[T]) Contains ¶
Returns true if the slice contains the element, comparing with slices.ContainsFunc and reflect.DeepEqual.
func (Slice[T]) Copy ¶
Creates a copy of the current object, which is not the same as the current object.
implements the slices.Clone function on the internal slice to create the new structure.
func (Slice[T]) EqualSlice ¶ added in v1.6.0
func (Slice[T]) EqualSliceFunc ¶ added in v1.6.0
func (Slice[T]) Index ¶
Performs a slices.IndexFunc comparing it with reflect.DeepEqual on the internal slice, returning the result.
Returns the first occurrence of the supplied element.
func (*Slice[T]) Remove ¶
func (s *Slice[T]) Remove(v T)
Removes the first occurrence of the provided element.
func (*Slice[T]) RemoveDuplicates ¶
func (s *Slice[T]) RemoveDuplicates()
Removes duplicates from the slice making all elements unique.
func (*Slice[T]) Reverse ¶
func (s *Slice[T]) Reverse()
Call the slices.Reverse function with the internal slice.
func (*Slice[T]) SliceP ¶
func (s *Slice[T]) SliceP() *[]T
Return the pointer of the golang built-in slice.