rachidify / util

Bringing Collection to Golang [WIP]

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

util

Documentation Build Status Go Report Card codecov

Example

package main

import (
	"fmt"
	"github.com/rasheedhamdawi/util"
)

func main() {

	// init
	list := new(util.ArrayList)

	// add items
	list.Add("Go")
	list.Add("Python")
	list.Add("Java")
	list.Add("JavaScript")

	// get the length of the list
	list.Size() // 4

	// get item
	list.Get(1) // "Python"

	// get index of item
	list.IndexOf("Java") // 2

	// remove item
	list.Remove("JavaScript")

	// Iteration
	iterator := list.Iterator()

	for iterator.HasNext() {
		fmt.Println(iterator.Next())
	}

	// Loop
	printItem := func(_ int, item util.Element) {
		fmt.Println(item)
	}

	list.ForEach(printItem)
}

check the documentation for more

About

Bringing Collection to Golang [WIP]

License:MIT License


Languages

Language:Go 98.1%Language:AMPL 1.9%