lib

package
v0.0.0-...-6206b6d Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2021 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CMap

type CMap struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

CMap is concurrent map with generic key and value as interface{}

func NewCMap

func NewCMap() *CMap

NewCMap make new CMap

func (*CMap) Contains

func (c *CMap) Contains(key interface{}) bool

func (*CMap) Get

func (c *CMap) Get(key interface{}) interface{}

func (*CMap) Keys

func (c *CMap) Keys() []interface{}

func (*CMap) Put

func (c *CMap) Put(key, value interface{})

func (*CMap) Size

func (c *CMap) Size() int

type CSet

type CSet struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

CSet is concurrent set with generic data as interface{}

func NewCSet

func NewCSet() *CSet

func (*CSet) Array

func (s *CSet) Array() []interface{}

func (*CSet) Contains

func (s *CSet) Contains(e interface{}) bool

func (*CSet) Get

func (s *CSet) Get() interface{}

Get returns random element from set

func (*CSet) Put

func (s *CSet) Put(e interface{})

func (*CSet) Remove

func (s *CSet) Remove(e interface{})

func (*CSet) Size

func (s *CSet) Size() int

type Graph

type Graph struct {
	// contains filtered or unexported fields
}

func NewGraph

func NewGraph() *Graph

func (*Graph) Add

func (g *Graph) Add(v interface{})

func (*Graph) AddEdge

func (g *Graph) AddEdge(from, to interface{})

func (*Graph) BFS

func (g *Graph) BFS(v interface{}) []interface{}

BFS returns breadth first search vertices from a given source

func (*Graph) BFSReverse

func (g *Graph) BFSReverse(v interface{}) []interface{}

func (*Graph) Cycle

func (g *Graph) Cycle() []interface{}

Cycle returns the first cycle with vertices

func (*Graph) Cyclic

func (g *Graph) Cyclic() bool

Cyclic returns true if the graph contains a cycle

func (*Graph) DFS

func (g *Graph) DFS(v interface{}) []interface{}

DFS returns depth first search vertices from a given source

func (*Graph) From

func (g *Graph) From(v interface{}) Set

From returns all vertices in graph that can be reached directly from v

func (*Graph) Has

func (g *Graph) Has(v interface{}) bool

func (*Graph) Remove

func (g *Graph) Remove(v interface{})

func (*Graph) RemoveEdge

func (g *Graph) RemoveEdge(from, to interface{})

func (*Graph) SCC

func (g *Graph) SCC() [][]interface{}

SCC find SCCs using Tarjan's algorithm

func (*Graph) Size

func (g *Graph) Size() int

func (*Graph) To

func (g *Graph) To(v interface{}) Set

To returns all vertices that can reach to v

func (*Graph) Transpose

func (g *Graph) Transpose() *Graph

Transpose return transpose graph

func (*Graph) Vertices

func (g *Graph) Vertices() Set

type HashRing

type HashRing struct {
	// contains filtered or unexported fields
}

HashRing implements a hash ring like Chord using md5

func (*HashRing) Get

func (h *HashRing) Get(k []byte) interface{}

Get returns the node value that given k belongs to

func (*HashRing) Insert

func (h *HashRing) Insert(v interface{}, b []byte)

Insert inserts the value and its byte into ring as a node

func (*HashRing) Next

func (h *HashRing) Next(v interface{}) interface{}

Next returns the next value in the ring; nil if v does not exists

func (HashRing) String

func (h HashRing) String() string

type MMap

type MMap struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewMMap

func NewMMap() *MMap

func (*MMap) Get

func (m *MMap) Get(key interface{}, version interface{}) interface{}

func (*MMap) Keys

func (m *MMap) Keys() []interface{}

func (*MMap) Put

func (m *MMap) Put(key interface{}, key2 interface{}, value interface{})

func (*MMap) SecondaryKeys

func (m *MMap) SecondaryKeys(key interface{}) []interface{}

type Queue

type Queue struct {
	// contains filtered or unexported fields
}

func NewQueue

func NewQueue() *Queue

func (*Queue) Pop

func (q *Queue) Pop() interface{}

func (*Queue) Push

func (q *Queue) Push(e interface{})

func (*Queue) Size

func (q *Queue) Size() int

type Set

type Set map[interface{}]struct{}

func NewSet

func NewSet() Set

func (Set) Add

func (s Set) Add(e interface{})

func (Set) Clear

func (s Set) Clear()

func (Set) Clone

func (s Set) Clone() Set

func (Set) Has

func (s Set) Has(e interface{}) bool

func (Set) Remove

func (s Set) Remove(e interface{})

func (Set) Slice

func (s Set) Slice() []interface{}

type Stack

type Stack struct {
	// contains filtered or unexported fields
}

Stack implements the stack data structure backed by single linked list

func NewStack

func NewStack() *Stack

NewStack creates a new Stack

func (*Stack) Empty

func (s *Stack) Empty() bool

func (*Stack) Len

func (s *Stack) Len() int

Len returns the number of items in the stack

func (*Stack) Peek

func (s *Stack) Peek() interface{}

Peek views the top item on the stack

func (*Stack) Pop

func (s *Stack) Pop() interface{}

Pop the top item of the stack and return it

func (*Stack) Push

func (s *Stack) Push(value interface{})

Push a value onto the top of the stack

Jump to

Keyboard shortcuts

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