Skip to content

Collections for Golang using generics. Currently containing Hash Set.

Notifications You must be signed in to change notification settings

ferreiravinicius/gollections

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Implementation of missing colections for Golang using Generics.
Free of dependencies.
Curently in early development phase.

Requirements

Go 1.18+

Install

$ go get -u github.com/ferreiravinicius/gollections

Set

Set is a collection that contains no duplicate elements.
All implementations follows the set.Set interface.

Hash Set

Implemention of set backed by a hash table (Go builtin Map).
Order of insertion is not guaranteed.
This implementation is not synchronized.

API

Importing

import "github.com/ferreiravinicius/goset/hashset"

Create a new empty set

set := hashset.New[int]() 

Create a new set initialized

set := hashset.From(1, 2, 3) 

items := []int{4, 5, 6}
set := hashset.From(items...) 

Create a new set with initial capacity

set := hashset.WithCapacity[int](100) 

Iterating over the set using builtin loop

set := hashset.From(1, 2, 3)
for item := range set {
  // foo(item)
}

Iterating over the set using ForEach

set := hashset.From(1, 2, 3) 
set.ForEach(func(item int) { 
 // foo(item) 
})

About

Collections for Golang using generics. Currently containing Hash Set.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages