Documentation ¶
Index ¶
- type Option
- type Options
- type T
- type Vector
- func (v *Vector[T]) At(pos int) T
- func (v *Vector[T]) Back() T
- func (v *Vector[T]) Begin() *VectorIterator[T]
- func (v *Vector[T]) Capacity() int
- func (v *Vector[T]) Clear()
- func (v *Vector[T]) Data() []T
- func (v *Vector[T]) Empty() bool
- func (v *Vector[T]) End() *VectorIterator[T]
- func (v *Vector[T]) Erase(iter iterator.ConstIterator[T]) *VectorIterator[T]
- func (v *Vector[T]) EraseAt(pos int)
- func (v *Vector[T]) EraseIndexRange(first, last int)
- func (v *Vector[T]) EraseRange(first, last iterator.ConstIterator[T]) *VectorIterator[T]
- func (v *Vector[T]) First() *VectorIterator[T]
- func (v *Vector[T]) Front() T
- func (v *Vector[T]) Insert(iter iterator.ConstIterator[T], val T) *VectorIterator[T]
- func (v *Vector[T]) InsertAt(pos int, val T)
- func (v *Vector[T]) IterAt(pos int) *VectorIterator[T]
- func (v *Vector[T]) Last() *VectorIterator[T]
- func (v *Vector[T]) PopBack() T
- func (v *Vector[T]) PushBack(val T)
- func (v *Vector[T]) Reserve(capacity int)
- func (v *Vector[T]) Resize(size int)
- func (v *Vector[T]) SetAt(pos int, val T)
- func (v *Vector[T]) ShrinkToFit()
- func (v *Vector[T]) Size() int
- func (v *Vector[T]) String() string
- type VectorIterator
- func (iter *VectorIterator[T]) Clone() iterator.ConstIterator[T]
- func (iter *VectorIterator[T]) Equal(other iterator.ConstIterator[T]) bool
- func (iter *VectorIterator[T]) IsValid() bool
- func (iter *VectorIterator[T]) IteratorAt(position int) iterator.RandomAccessIterator[T]
- func (iter *VectorIterator[T]) Next() iterator.ConstIterator[T]
- func (iter *VectorIterator[T]) Position() int
- func (iter *VectorIterator[T]) Prev() iterator.ConstBidIterator[T]
- func (iter *VectorIterator[T]) SetValue(val T)
- func (iter *VectorIterator[T]) Value() T
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Option ¶
type Option func(option *Options)
Option is a function type used to set Options
func WithCapacity ¶
WithCapacity is used to set the capacity of a Vector
type Options ¶
type Options struct {
// contains filtered or unexported fields
}
Options holds the Vector's options
type Vector ¶
type Vector[T any] struct { // contains filtered or unexported fields }
Vector is a linear data structure, the internal is a slice
func NewFromVector ¶
NewFromVector news a Vector from other Vector
func (*Vector[T]) Back ¶
func (v *Vector[T]) Back() T
Back returns the last value in the vector, returns nil if the vector is empty.
func (*Vector[T]) Begin ¶
func (v *Vector[T]) Begin() *VectorIterator[T]
Begin returns the first iterator of the vector
func (*Vector[T]) End ¶
func (v *Vector[T]) End() *VectorIterator[T]
End returns the end iterator of the vector
func (*Vector[T]) Erase ¶
func (v *Vector[T]) Erase(iter iterator.ConstIterator[T]) *VectorIterator[T]
Erase erases the element of the iterator iter point to
func (*Vector[T]) EraseIndexRange ¶
EraseIndexRange erases values at range[first, last)
func (*Vector[T]) EraseRange ¶
func (v *Vector[T]) EraseRange(first, last iterator.ConstIterator[T]) *VectorIterator[T]
EraseRange erases all elements in the range[first, last)
func (*Vector[T]) First ¶
func (v *Vector[T]) First() *VectorIterator[T]
First returns the first iterator of the vector
func (*Vector[T]) Front ¶
func (v *Vector[T]) Front() T
Front returns the first value in the vector, returns nil if the vector is empty.
func (*Vector[T]) Insert ¶
func (v *Vector[T]) Insert(iter iterator.ConstIterator[T], val T) *VectorIterator[T]
Insert inserts a value val to the vector at the position of the iterator iter point to
func (*Vector[T]) IterAt ¶
func (v *Vector[T]) IterAt(pos int) *VectorIterator[T]
IterAt returns the iterator at position of the vector
func (*Vector[T]) Last ¶
func (v *Vector[T]) Last() *VectorIterator[T]
Last returns the last iterator of the vector
func (*Vector[T]) PopBack ¶
func (v *Vector[T]) PopBack() T
PopBack returns the last value of the vector and erase it, returns nil if the vector is empty.
func (*Vector[T]) PushBack ¶
func (v *Vector[T]) PushBack(val T)
PushBack pushes val to the back of the vector
func (*Vector[T]) ShrinkToFit ¶
func (v *Vector[T]) ShrinkToFit()
ShrinkToFit shrinks the capacity of the vector to the fit size
type VectorIterator ¶
type VectorIterator[T any] struct { // contains filtered or unexported fields }
VectorIterator represents a vector iterator
func (*VectorIterator[T]) Clone ¶
func (iter *VectorIterator[T]) Clone() iterator.ConstIterator[T]
Clone clones the iterator into a new iterator
func (*VectorIterator[T]) Equal ¶
func (iter *VectorIterator[T]) Equal(other iterator.ConstIterator[T]) bool
Equal returns true if the iterator is equal to the passed iterator
func (*VectorIterator[T]) IsValid ¶
func (iter *VectorIterator[T]) IsValid() bool
IsValid returns true if the iterator is valid, otherwise returns false
func (*VectorIterator[T]) IteratorAt ¶
func (iter *VectorIterator[T]) IteratorAt(position int) iterator.RandomAccessIterator[T]
IteratorAt creates an iterator with the passed position
func (*VectorIterator[T]) Next ¶
func (iter *VectorIterator[T]) Next() iterator.ConstIterator[T]
Next moves the position of iterator to the next position and returns itself
func (*VectorIterator[T]) Position ¶
func (iter *VectorIterator[T]) Position() int
Position return the position of the iterator point to
func (*VectorIterator[T]) Prev ¶
func (iter *VectorIterator[T]) Prev() iterator.ConstBidIterator[T]
Prev moves the position of the iterator to the previous position and returns itself
func (*VectorIterator[T]) SetValue ¶
func (iter *VectorIterator[T]) SetValue(val T)
SetValue sets the value of the iterator point to
func (*VectorIterator[T]) Value ¶
func (iter *VectorIterator[T]) Value() T
Value returns the value of the iterator point to