gozeloglu / iterator

Iterator package written in Go.

Home Page:https://pkg.go.dev/github.com/gozeloglu/iterator

Repository from Github https://github.comgozeloglu/iteratorRepository from Github https://github.comgozeloglu/iterator

iterator

Install

You can install the package as below:

go get github.com/gozeloglu/iterator

Usage

Firstly, you need to create an iter object with New function. You can pass elements to that function.

it := iterator.New(1,2,3,4)

Then, you can call the methods by using it object.

package main

import "github.com/gozeloglu/iterator"

func main() {
	it := iterator.New(1,2,3,4)
	it.Next()   // Check whether there is element in next
	it.Value()  // Retrieve next element if exists
	it.Prev()   // Check whether there is element in prev
	it.ToSlice()    // Retrieve all elements in slice
	it.First()  // Updates the cursor by moving first index
	it.Last()   // Updates the cursor by moving last index
}

Running tests

You can run the test with following command.

go test
go test -v  # verbose output

You can also get code coverage with the following command.

go test -cover
go test -cover -v # verbose output

LICENSE

MIT

About

Iterator package written in Go.

https://pkg.go.dev/github.com/gozeloglu/iterator

License:MIT License


Languages

Language:Go 100.0%