vector

package
v0.0.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 2, 2022 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Copy added in v0.0.4

func Copy[T any](dst *Vector[T], src Vector[T]) int

func CopyAt added in v0.0.4

func CopyAt[T any](dst *Vector[T], src Vector[T], at int) int

func Fold added in v0.0.4

func Fold[T any](vec Vector[T], init T, f func(acc T, elem T) T) T

func Sort added in v0.0.4

func Sort[T constraints.Ordered](vec *Vector[T])

Types

type Vector

type Vector[T any] struct {
	// contains filtered or unexported fields
}

func Chunks added in v0.0.4

func Chunks[T any](vec Vector[T], size int) (Vector[*Vector[T]], error)

func Concat added in v0.0.4

func Concat[T any](head Vector[T], tails ...Vector[T]) Vector[T]

func Cycle added in v0.0.4

func Cycle[T any](vec Vector[T], num int) Vector[T]

func FromSlice

func FromSlice[T any](xs []T) Vector[T]

func FromValues

func FromValues[T any](xs ...T) Vector[T]

func Map

func Map[T any, R any](vec Vector[T], f func(T) R) Vector[R]

func MapFilter

func MapFilter[T any, R any](vec Vector[T], f func(T) option.Option[R]) Vector[R]

func Repeat added in v0.0.4

func Repeat[T any](init T, num int) Vector[T]

func Window added in v0.0.4

func Window[T any](vec Vector[T], size int) (Vector[*Vector[T]], error)

func WithCapacity

func WithCapacity[T any](cap int) Vector[T]

func (*Vector[T]) Capacity

func (vec *Vector[T]) Capacity() int

func (*Vector[T]) Empty

func (vec *Vector[T]) Empty() bool

func (*Vector[T]) Extend added in v0.0.4

func (vec *Vector[T]) Extend(other Vector[T])

func (*Vector[T]) ExtendBy added in v0.0.4

func (vec *Vector[T]) ExtendBy(elem T, num int)

func (*Vector[T]) ForEach

func (vec *Vector[T]) ForEach(f func(T))

func (*Vector[T]) Get added in v0.0.4

func (vec *Vector[T]) Get(i int) T

Get does not perform boundary check

func (*Vector[T]) Partition added in v0.0.4

func (vec *Vector[T]) Partition(f func(elem T) bool) int

Partition changes the positions of the elements in the given vector: those that pass f are moved to the head positions; those that fail to the tail positions. Partition is NOT stable - it doesn't maintain the element order in each partition. Returns the partition cursor: the index of the first element of the second partition, (it contains all the elements failing f)

func (*Vector[T]) Push

func (vec *Vector[T]) Push(x T)

func (*Vector[T]) Reserve

func (vec *Vector[T]) Reserve(additional int)

func (*Vector[T]) ShrinkToFit

func (vec *Vector[T]) ShrinkToFit()

func (*Vector[T]) Size

func (vec *Vector[T]) Size() int

func (*Vector[T]) Swap added in v0.0.4

func (vec *Vector[T]) Swap(i int, j int)

Swap does not perform boundary check

func (Vector[T]) ToSlice

func (vec Vector[T]) ToSlice() []T

func (*Vector[T]) TryPop

func (vec *Vector[T]) TryPop() option.Option[T]

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL