https://github.com/gozeloglu/iterator
Iterator package written in Go.
https://github.com/gozeloglu/iterator
go golang iterator
Last synced: over 1 year ago
JSON representation
Iterator package written in Go.
- Host: GitHub
- URL: https://github.com/gozeloglu/iterator
- Owner: gozeloglu
- License: mit
- Created: 2023-02-03T09:16:08.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2023-02-28T11:11:10.000Z (over 3 years ago)
- Last Synced: 2025-01-04T20:16:39.395Z (over 1 year ago)
- Topics: go, golang, iterator
- Language: Go
- Homepage: https://pkg.go.dev/github.com/gozeloglu/iterator
- Size: 14.6 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# iterator
## Install
You can install the package as below:
```shell
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.
```go
it := iterator.New(1,2,3,4)
```
Then, you can call the methods by using `it` object.
```go
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.
```shell
go test
go test -v # verbose output
```
You can also get code coverage with the following command.
```shell
go test -cover
go test -cover -v # verbose output
```
## LICENSE
[MIT](LICENSE)