structure

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2018 License: MIT Imports: 2 Imported by: 0

README

Data structure

Set

A non thread safe implementation of basic Set operations

  • Add
  • Cardinality
  • Contains
  • Equal

Tree

StringTree is manly used for printing i.e. directory layout, log entry hierarchy

Acknowledgement

Documentation

Overview

Package structure add some missing common data structures to Golang

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Set

type Set map[string]bool

Set is a map with string key and bool value It is not thread safe and modeled after https://github.com/deckarep/golang-set/blob/master/threadunsafe.go

func NewSet

func NewSet(args ...string) *Set

NewSet return a pointer of a set using arguments passed to the function

Example
s := NewSet("a", "b", "c")
fmt.Println(s.Size())
Output:

3

func (*Set) Add

func (set *Set) Add(key string)

Add add an element to set regardless of it is already in the set

func (*Set) Cardinality

func (set *Set) Cardinality() int

Cardinality return the size of the set

func (*Set) Contains

func (set *Set) Contains(key string) bool

Contains check if a key is presented in the map, it does NOT check the bool value

func (*Set) Equal

func (set *Set) Equal(other *Set) bool

Equal check if two sets have exactly same elements

func (*Set) Size

func (set *Set) Size() int

Size is an alias for Cardinality

type StringTreeNode

type StringTreeNode struct {
	Val      string
	Children []StringTreeNode
}

func (*StringTreeNode) Append

func (tree *StringTreeNode) Append(child StringTreeNode)

func (*StringTreeNode) Print

func (tree *StringTreeNode) Print()

func (*StringTreeNode) PrintTo

func (tree *StringTreeNode) PrintTo(w io.Writer)

Jump to

Keyboard shortcuts

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