Skip to content

Go Collections Library that provides generic data structures

License

Notifications You must be signed in to change notification settings

golanglibs/gocollections

Repository files navigation

gocollections

Basic Generic Collections Library for Golang with interfaces to provide implementation-agnostic abstractions over various collections

Installation

go get github.com/golanglibs/gocollections@latest

List of Implemented Data Structures

Provided Collection Interfaces and their implementations

  • Collectioner[T any]

  • Lister[T any]

    • Provides operations for list-like collections
    • Provides the following operations:
      • SetEqualityComparer(equals func(*T, *T) bool):
      • At(index int) *T
      • Set(index int, value T)
      • Size() int
      • Empty() bool
      • Front() *T
      • Back() *T
      • Add(element T) bool
      • RemoveBack()
      • Insert(index int, value T) bool
      • AddToFront(element T)
      • RemoveFront()
      • Remove(element T) bool
      • RemoveAt(index int)
      • IndexOf(element T) int
      • Contains(element T) bool
      • SubList(start int, end int) Lister[T]
      • Clear()
      • ForEach(do func(*T))
    • Implemented by:
  • Seter[K comparable]

    • Provides operations for set-like collections
    • Provides the following operations:
      • Size() int
      • Empty() bool
      • Add(element K) bool
      • Remove(element K) bool
      • Contains(element K) bool
      • Equals(set Seter[K]) bool
      • Intersects(set Seter[K]) bool
      • GetIntersection(set Seter[K]) Seter[K]
      • GetUnion(set Seter[K]) Seter[K]
      • IsSupersetOf(set Seter[K]) bool
      • IsSubsetOf(set Seter[K]) bool
      • Clear()
      • ForEach(do func(*K))
    • Implemented By:
  • Queuer[T any]

    • Provides operations for queue-like collections
    • Provides the following operations
      • SetEqualityComparer(equals func(*T, *T) bool)
      • Size() int
      • Empty() bool
      • Enqueue(element T)
      • Dequeue()
      • Peek() *T
      • Contains(element T) bool
      • Clear()
      • ForEach(do func(*T))
    • Implemented By:
  • Stacker[T any]

    • Provides operations for stack-like collections
    • Provides the following operations:
      • SetEqualityComparer(equals func(*T, *T) bool)
      • Size() int
      • Empty() bool
      • Push(T)
      • Pop()
      • Peek() *T
      • Contains(element T) bool
      • Clear()
      • ForEach(do func(*T))
    • Implemented By:

Possible Improvements

  • Add SortedMap (TreeMap) and SortedSet (TreeSet)
  • Add Stream APIs using Collectioner
  • Add more collection methods such as Map and Filter