array

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2023 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Array

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

Array is a fixed size slice

func New

func New[T any](size int) *Array[T]

New creates a new array with passed size

func NewFromArray

func NewFromArray[T any](other *Array[T]) *Array[T]

NewFromArray creates a new array from another array, and copy its values

func (*Array[T]) At

func (a *Array[T]) At(pos int) T

At returns the value at position pos in the array

func (*Array[T]) Back

func (a *Array[T]) Back() T

Back returns the last value in the array

func (*Array[T]) Begin

func (a *Array[T]) Begin() *ArrayIterator[T]

Begin returns an iterator of the array with the first position

func (*Array[T]) Data

func (a *Array[T]) Data() []T

Data returns the internal values of the array

func (*Array[T]) Empty

func (a *Array[T]) Empty() bool

Empty returns whether the array is empty or not

func (*Array[T]) End

func (a *Array[T]) End() *ArrayIterator[T]

End returns an iterator of the array with the position a.Size()

func (*Array[T]) Fill

func (a *Array[T]) Fill(val T)

Fill fills Array a with value val

func (*Array[T]) First

func (a *Array[T]) First() *ArrayIterator[T]

First returns an iterator of the array with the first position

func (*Array[T]) Front

func (a *Array[T]) Front() T

Front returns the first value in the array

func (*Array[T]) IterAt

func (a *Array[T]) IterAt(pos int) *ArrayIterator[T]

IterAt returns an iterator of the array with position pos

func (*Array[T]) Last

func (a *Array[T]) Last() *ArrayIterator[T]

Last returns an iterator of the array with the last position

func (*Array[T]) Set

func (a *Array[T]) Set(pos int, val T)

Set sets value val to the position pos of the array

func (*Array[T]) Size

func (a *Array[T]) Size() int

Size returns number of elements within the array

func (*Array[T]) String

func (a *Array[T]) String() string

String returns a string representation of the array

func (*Array[T]) SwapArray

func (a *Array[T]) SwapArray(other *Array[T])

SwapArray swaps the values of two arrays

type ArrayIterator

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

ArrayIterator is an implementation of Array iterator

func (*ArrayIterator[T]) Clone

func (iter *ArrayIterator[T]) Clone() iterator.ConstIterator[T]

Clone clones the iterator to a new iterator

func (*ArrayIterator[T]) Equal

func (iter *ArrayIterator[T]) Equal(other iterator.ConstIterator[T]) bool

Equal returns true if the iterator is equal to the passed iterator, otherwise returns false

func (*ArrayIterator[T]) IsValid

func (iter *ArrayIterator[T]) IsValid() bool

IsValid returns true if the iterator is valid, otherwise returns false

func (*ArrayIterator[T]) IteratorAt

func (iter *ArrayIterator[T]) IteratorAt(pos int) iterator.RandomAccessIterator[T]

IteratorAt creates a new iterator with position pos

func (*ArrayIterator[T]) Next

func (iter *ArrayIterator[T]) Next() iterator.ConstIterator[T]

Next moves the position of iterator to the next position and returns itself

func (*ArrayIterator[T]) Position

func (iter *ArrayIterator[T]) Position() int

Position returns the position of the iterator

func (*ArrayIterator[T]) Prev

func (iter *ArrayIterator[T]) Prev() iterator.ConstBidIterator[T]

Prev moves the position of iterator to the previous position and returns itself

func (*ArrayIterator[T]) SetValue

func (iter *ArrayIterator[T]) SetValue(val T)

SetValue sets the value of the array at the position of the iterator point to

func (*ArrayIterator[T]) Value

func (iter *ArrayIterator[T]) Value() T

Value returns the value of array at the position of the iterator point to

type T added in v1.1.0

type T any

Jump to

Keyboard shortcuts

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