vector

package
v0.2.12 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2021 License: MIT Imports: 0 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Vector

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

func NewVector

func NewVector[T any]() *Vector[T]

func (*Vector[T]) At

func (v *Vector[T]) At(pos int) T

At returns a reference to the element at specified location pos, with bounds checking. If pos is not within the range of the container, a panic is thrown. Complexity - O(1).

func (*Vector[T]) Back

func (v *Vector[T]) Back() T

Back returns a reference to the last element in the container. Calling Back on an empty container causes undefined behavior. Complexity - O(1).

func (*Vector[T]) Capacity

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

Capacity returns the number of elements that the container has currently allocated space for. Complexity - O(1).

func (*Vector[T]) Empty

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

Empty checks if the container has no elements. Complexity - O(1).

func (*Vector[T]) Front

func (v *Vector[T]) Front() T

Front returns a reference to the first element in the container. Calling Front on an empty container is undefined. Complexity - O(1).

func (*Vector[T]) PopBack

func (v *Vector[T]) PopBack() T

func (*Vector[T]) PushBack

func (v *Vector[T]) PushBack(item T)

PushBack appends the given element value to the end of the container. Complexity - amortized constant e.g. O(1).

func (*Vector[T]) Size

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

Size returns the number of elements in the container. Complexity - O(1).

Jump to

Keyboard shortcuts

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