Skip to content

Latest commit

 

History

History
66 lines (47 loc) · 944 Bytes

File metadata and controls

66 lines (47 loc) · 944 Bytes

Getting started

Install

go get github.com/fgrzl/collections

Hash set

import "github.com/fgrzl/collections/hashset"

set := hashset.NewHashSet[string](hashset.WithCapacity(64))
set.Add("alpha")
set.Add("beta")
if set.Contains("alpha") {
    // ...
}

Or via the root package:

import "github.com/fgrzl/collections"

set := collections.NewHashSetWithCapacity[string](64)

Queue (FIFO)

import "github.com/fgrzl/collections/queue"

q := queue.NewQueue[int]()
q.Enqueue(1)
q.Enqueue(2)
q.Enqueue(3)
v, ok := q.Dequeue() // 1, true

Stack (LIFO)

import "github.com/fgrzl/collections/stack"

s := stack.NewStack[string]()
s.Push("bottom")
s.Push("top")
v, ok := s.Pop() // "top", true

Concurrent hash set

import "github.com/fgrzl/collections/concurrenthashset"

set := concurrenthashset.NewConcurrentHashSet[int]()
set.Add(42)

Tests

go test ./...