generic

package module
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 24, 2020 License: Apache-2.0 Imports: 3 Imported by: 2

README

generic

GoDoc

zero dependency library for common datastructures

Datastructures

  • stack
  • queue
  • cache

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

type Cache interface {
	// Close closes the cache's garbage collector
	Closer
	// Len returns the length of the queue
	LengthCheck
	// Get gets an item from the cache by key
	Get(key interface{}) (interface{}, bool)
	// Exists returns true if the key exists in the cache
	Exists(key interface{}) bool
	// Set sets an item in the cache for the specified duration. If duration == 0, the item will never expire
	Set(key interface{}, value interface{}, duration time.Duration)
	// Range iterates over every item in the cache
	Range(f func(key, value interface{}) bool)
	// Delete deletes an item from the cache
	Delete(key interface{})
}

Cache is a general purpose, concurrency-safe, in-memory cache data-structure

func NewCache

func NewCache(garbageCollect time.Duration) Cache

type Closer added in v0.1.0

type Closer interface {
	Close()
}

Closer closes a data-structure

type LengthCheck added in v0.1.0

type LengthCheck interface {
	Len() int
}

Len returns the length of a data-structure

type Queue

type Queue interface {
	// Enqueue adds a new node to the tail of the queue
	Enqueue(value interface{})
	// Dequeue removes the head node from the queue and returns it
	Dequeue() interface{}
	// Len returns the length of the queue
	LengthCheck
}

Queue is a general purpose, in-memory queue data-structure

func NewQueue

func NewQueue() Queue

type Stack

type Stack interface {
	Peek() interface{}
	Pop() interface{}
	Push(value interface{})
	LengthCheck
}

Stack is a general purpose, in-memory stack data-structure

func NewStack

func NewStack() Stack

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL