Documentation ¶
Overview ¶
slices package
Generic Class base implementation for golang.org/x/exp/slices
Index ¶
- func CompareFunc[E1, E2 any](s1 ISlice[E1], s2 ISlice[E2], cmp func(E1, E2) int) int
- func EqualFunc[E1, E2 any](s1 ISlice[E1], s2 ISlice[E2], eq func(E1, E2) bool) bool
- type ComparableSlice
- func (s *ComparableSlice[E]) Clone() ISlice[E]
- func (s *ComparableSlice[E]) Compact()
- func (s *ComparableSlice[E]) Contains(e E) bool
- func (s *ComparableSlice[E]) Equal(o IComparableSlice[E]) bool
- func (s *ComparableSlice[E]) Index(e E) int
- func (s *ComparableSlice[E]) TryComparable() (IComparableSlice[E], bool)
- func (s *ComparableSlice[E]) TryOrdered() (IOrderedSlice[E], bool)
- type IComparableSlice
- type IOrderedSlice
- type ISlice
- type OrderedSlice
- func (s *OrderedSlice[E]) BinarySearch(target E) (int, bool)
- func (s *OrderedSlice[E]) Clone() ISlice[E]
- func (s *OrderedSlice[E]) Compare(o IOrderedSlice[E]) int
- func (s *OrderedSlice[E]) IsSorted() bool
- func (s *OrderedSlice[E]) Sort()
- func (s *OrderedSlice[E]) TryComparable() (IComparableSlice[E], bool)
- func (s *OrderedSlice[E]) TryOrdered() (IOrderedSlice[E], bool)
- type Slice
- func (s *Slice[E]) Append(elems ...E)
- func (s *Slice[E]) BinarySearchFunc(target E, cmp func(E, E) int) (int, bool)
- func (s *Slice[E]) Clip()
- func (s *Slice[E]) Clone() ISlice[E]
- func (s *Slice[E]) CompactFunc(eq func(E, E) bool)
- func (s *Slice[E]) CompareFunc(o ISlice[E], cmp func(E, E) int) int
- func (s *Slice[E]) ContainsFunc(cond func(E) bool) bool
- func (s *Slice[E]) Delete(delStart, delEnd int)
- func (s *Slice[E]) EqualFunc(o ISlice[E], eq func(E, E) bool) bool
- func (s *Slice[E]) Get(i int) E
- func (s *Slice[E]) Grow(n int)
- func (s *Slice[E]) IndexFunc(cond func(E) bool) int
- func (s *Slice[E]) Insert(i int, elems ...E)
- func (s *Slice[E]) IsSortedFunc(less func(E, E) bool) bool
- func (s *Slice[E]) Replace(start, end int, elems ...E)
- func (s *Slice[E]) Set(i int, e E)
- func (s *Slice[E]) Size() int
- func (s *Slice[E]) SortFunc(less func(E, E) bool)
- func (s *Slice[E]) SortStableFunc(less func(E, E) bool)
- func (s *Slice[E]) TryComparable() (IComparableSlice[E], bool)
- func (s *Slice[E]) TryOrdered() (IOrderedSlice[E], bool)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CompareFunc ¶
Types ¶
type ComparableSlice ¶
type ComparableSlice[E comparable] struct { Slice[E] }
func (*ComparableSlice[E]) TryComparable ¶
func (s *ComparableSlice[E]) TryComparable() (IComparableSlice[E], bool)
func (*ComparableSlice[E]) TryOrdered ¶
func (s *ComparableSlice[E]) TryOrdered() (IOrderedSlice[E], bool)
type IComparableSlice ¶
type IComparableSlice[E any] interface { ISlice[E] Compact() Contains(E) bool Equal(IComparableSlice[E]) bool Index(E) int }
func NewComparableSlice ¶
func NewComparableSlice[E comparable]() IComparableSlice[E]
func NewComparableSliceFrom ¶
func NewComparableSliceFrom[E comparable, S []E](s S) IComparableSlice[E]
type IOrderedSlice ¶
type IOrderedSlice[E any] interface { IComparableSlice[E] BinarySearch(E) (int, bool) Compare(IOrderedSlice[E]) int IsSorted() bool Sort() }
func NewOrderedSlice ¶
func NewOrderedSlice[E ordered]() IOrderedSlice[E]
func NewOrderedSliceFrom ¶
func NewOrderedSliceFrom[E ordered, S []E](s S) IOrderedSlice[E]
type ISlice ¶
type ISlice[E any] interface { // Get value at specified index // // # Arguments // * `i`: `int` - Index // // # Returns // * `E` - Internal value Get(i int) E // Set value at specified index // // # Arguments // * `i`: `int` - Index // * `e`: `E` - Value to be set Set(i int, e E) // Append element(s) // // # Arguments // `elems`: `...E` - Elements to be added Append(elems ...E) Size() int BinarySearchFunc(E, func(E, E) int) (int, bool) Clip() Clone() ISlice[E] CompactFunc(func(E, E) bool) CompareFunc(ISlice[E], func(E, E) int) int ContainsFunc(func(E) bool) bool Delete(int, int) EqualFunc(ISlice[E], func(E, E) bool) bool Grow(int) IndexFunc(func(E) bool) int Insert(int, ...E) IsSortedFunc(func(E, E) bool) bool Replace(int, int, ...E) SortFunc(func(E, E) bool) SortStableFunc(func(E, E) bool) TryComparable() (IComparableSlice[E], bool) TryOrdered() (IOrderedSlice[E], bool) }
func NewSliceFrom ¶
type OrderedSlice ¶
type OrderedSlice[E ordered] struct { ComparableSlice[E] }
func (*OrderedSlice[E]) BinarySearch ¶
func (*OrderedSlice[E]) TryComparable ¶
func (s *OrderedSlice[E]) TryComparable() (IComparableSlice[E], bool)
func (*OrderedSlice[E]) TryOrdered ¶
func (s *OrderedSlice[E]) TryOrdered() (IOrderedSlice[E], bool)
type Slice ¶
type Slice[E any] struct { // contains filtered or unexported fields }
func (*Slice[E]) BinarySearchFunc ¶
func (*Slice[E]) CompactFunc ¶
func (s *Slice[E]) CompactFunc(eq func(E, E) bool)
func (*Slice[E]) CompareFunc ¶
func (*Slice[E]) ContainsFunc ¶
func (*Slice[E]) IsSortedFunc ¶
func (*Slice[E]) SortStableFunc ¶
func (s *Slice[E]) SortStableFunc(less func(E, E) bool)
func (*Slice[E]) TryComparable ¶
func (s *Slice[E]) TryComparable() (IComparableSlice[E], bool)
func (*Slice[E]) TryOrdered ¶
func (s *Slice[E]) TryOrdered() (IOrderedSlice[E], bool)
Click to show internal directories.
Click to hide internal directories.