iterator

package
v0.0.0-...-7dcde51 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2021 License: MIT Imports: 0 Imported by: 0

Documentation

Overview

Example (One)
vector := NewVector()
vector.Push(1)
vector.Push(2)
vector.Push(3)

for iter := vector.Begin(); iter != vector.End(); iter = iter.Next() {
	value := iter.Data().(int)
	fmt.Println(value)
}
Output:

1
2
3
Example (Two)
vector := NewVector()
vector.Push(1)
vector.Push(2)
vector.Push(3)
vector.Push(4)
vector.Pop()

for iter := vector.RightBegin(); iter != vector.RightEnd(); iter = iter.Prev() {
	value := iter.Data().(int)
	fmt.Println(value)
}
Output:

3
2
1

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BidirectionalIterator

type BidirectionalIterator interface {
	Data() interface{}
	Next() BidirectionalIterator
	Prev() BidirectionalIterator
}

type Vector

type Vector struct {
	// contains filtered or unexported fields
}

func NewVector

func NewVector() *Vector

func (*Vector) Begin

func (p *Vector) Begin() BidirectionalIterator

func (*Vector) End

func (p *Vector) End() BidirectionalIterator

func (*Vector) Pop

func (p *Vector) Pop() interface{}

func (*Vector) Push

func (p *Vector) Push(v interface{})

func (*Vector) RightBegin

func (p *Vector) RightBegin() BidirectionalIterator

func (*Vector) RightEnd

func (p *Vector) RightEnd() BidirectionalIterator

type VectorIterator

type VectorIterator struct {
	// contains filtered or unexported fields
}

func NewVectorIterator

func NewVectorIterator(vec *Vector, index int) *VectorIterator

func (*VectorIterator) Data

func (p *VectorIterator) Data() interface{}

func (*VectorIterator) Next

func (*VectorIterator) Prev

Jump to

Keyboard shortcuts

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