slice

package
v1.3.27 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2023 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ISlice

type ISlice[T any] interface {
	Len() int
	At(position int) T
	Set(position int, val T)
}

ISlice is an interface of Slice for iterator

type SliceIterator

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

SliceIterator represents a slice iterator

func (*SliceIterator[T]) Clone

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

Clone clones the iterator into a new one

func (*SliceIterator[T]) Equal

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

Equal returns true if the iterator is equal to the passed iterator

func (*SliceIterator[T]) IsValid

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

IsValid returns trus if the iterator is valid, othterwise return false

func (*SliceIterator[T]) IteratorAt

func (iter *SliceIterator[T]) IteratorAt(position int) iterator.RandomAccessIterator[T]

IteratorAt creates an iterator with the passed position

func (*SliceIterator[T]) Next

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

Next moves the iterator's position to the next position, and returns itself

func (*SliceIterator[T]) Position

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

Position returns the position of the iterator

func (*SliceIterator[T]) Prev

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

Prev move the iterator's position to the previous position, and return itself

func (*SliceIterator[T]) SetValue

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

SetValue sets the value of the iterator point to

func (*SliceIterator[T]) Value

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

Value returns the value of the iterator point to

type SliceWrapper

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

SliceWrapper wraps a slice in order to provide functions related to iterators

func NewSliceWrapper

func NewSliceWrapper[T any](slice []T) *SliceWrapper[T]

NewSliceWrapper creates a SliceWrapper

func (*SliceWrapper[T]) At

func (s *SliceWrapper[T]) At(position int) T

At returns the value at position

func (*SliceWrapper[T]) Attach

func (s *SliceWrapper[T]) Attach(newSlice []T)

Attach update the internal slice to newSlice

func (*SliceWrapper[T]) Begin

func (s *SliceWrapper[T]) Begin() *SliceIterator[T]

Begin returns the first iterator of s

func (*SliceWrapper[T]) End

func (s *SliceWrapper[T]) End() *SliceIterator[T]

End returns the end iterator of s

func (*SliceWrapper[T]) First

func (s *SliceWrapper[T]) First() *SliceIterator[T]

First returns the first iterator of s

func (*SliceWrapper[T]) Last

func (s *SliceWrapper[T]) Last() *SliceIterator[T]

Last returns the last iterator of s

func (*SliceWrapper[T]) Len

func (s *SliceWrapper[T]) Len() int

Len returns the length of s

func (*SliceWrapper[T]) Set

func (s *SliceWrapper[T]) Set(position int, val T)

Set sets value at position

type T

type T any

Jump to

Keyboard shortcuts

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