parody of some of the basic python core features (collections package)

collections

import "github.com/marcsantiago/collections"

Overview

Index

Package files

data.go element_sorters.go generic_map.go interable.go map.go primitive_conversions.go string_encoder.go types.go

func StringEncoder

func StringEncoder(encoder *bytes.Buffer, data Data, t Type)

StringEncoder writes data into a bytes buffer, used in the String method

type CounterMap

type CounterMap interface {
    Map
    MostCommon(n int) []Element
    Subtract(value Data)
    Update(value Data)
}

CounterMap mimics the Python Counter definitions this also implements the collections.Map interface to be able to convert into a ChainMap

type Data

type Data interface {
    Int() int
    Int32() int32
    Int64() int64
    Float32() float32
    Float64() float64
    String() string
}

Data interface for casting and getting data values used to avoid reflection

type Element

type Element struct {
    Key   Data
    Value Data
}

Element represents (key, value) with backed by the Data interface

type ElementsByKeyIntAsc

type ElementsByKeyIntAsc []Element

ElementsByKeyIntAsc used to used low to high where key is of type string

func (ElementsByKeyIntAsc) Len

func (e ElementsByKeyIntAsc) Len() int

func (ElementsByKeyIntAsc) Less

func (e ElementsByKeyIntAsc) Less(i, j int) bool

func (ElementsByKeyIntAsc) Swap

func (e ElementsByKeyIntAsc) Swap(i, j int)

type ElementsByKeyIntDesc

type ElementsByKeyIntDesc []Element

ElementsByKeyIntDesc used to used high to low where key is of type string

func (ElementsByKeyIntDesc) Len

func (e ElementsByKeyIntDesc) Len() int

func (ElementsByKeyIntDesc) Less

func (e ElementsByKeyIntDesc) Less(i, j int) bool

func (ElementsByKeyIntDesc) Swap

func (e ElementsByKeyIntDesc) Swap(i, j int)

type ElementsByKeyStringAsc

type ElementsByKeyStringAsc []Element

ElementsByKeyStringAsc used to used low to high where key is of type string

func (ElementsByKeyStringAsc) Len

func (e ElementsByKeyStringAsc) Len() int

func (ElementsByKeyStringAsc) Less

func (e ElementsByKeyStringAsc) Less(i, j int) bool

func (ElementsByKeyStringAsc) Swap

func (e ElementsByKeyStringAsc) Swap(i, j int)

type ElementsByKeyStringDesc

type ElementsByKeyStringDesc []Element

ElementsByKeyStringDesc used to used high to low where key is of type string

func (ElementsByKeyStringDesc) Len

func (e ElementsByKeyStringDesc) Len() int

func (ElementsByKeyStringDesc) Less

func (e ElementsByKeyStringDesc) Less(i, j int) bool

func (ElementsByKeyStringDesc) Swap

func (e ElementsByKeyStringDesc) Swap(i, j int)

type ElementsByValueIntAsc

type ElementsByValueIntAsc []Element

ElementsByValueIntAsc used to used low to high where value is of type string

func (ElementsByValueIntAsc) Len

func (e ElementsByValueIntAsc) Len() int

func (ElementsByValueIntAsc) Less

func (e ElementsByValueIntAsc) Less(i, j int) bool

func (ElementsByValueIntAsc) Swap

func (e ElementsByValueIntAsc) Swap(i, j int)

type ElementsByValueIntDesc

type ElementsByValueIntDesc []Element

ElementsByValueIntDesc used to used high to low where value is of type string

func (ElementsByValueIntDesc) Len

func (e ElementsByValueIntDesc) Len() int

func (ElementsByValueIntDesc) Less

func (e ElementsByValueIntDesc) Less(i, j int) bool

func (ElementsByValueIntDesc) Swap

func (e ElementsByValueIntDesc) Swap(i, j int)

type ElementsByValueStringAsc

type ElementsByValueStringAsc []Element

ElementsByValueStringAsc used to used low to high where value is of type string

func (ElementsByValueStringAsc) Len

func (e ElementsByValueStringAsc) Len() int

func (ElementsByValueStringAsc) Less

func (e ElementsByValueStringAsc) Less(i, j int) bool

func (ElementsByValueStringAsc) Swap

func (e ElementsByValueStringAsc) Swap(i, j int)

type ElementsByValueStringDesc

type ElementsByValueStringDesc []Element

ElementsByValueStringDesc used to used high to low where value is of type string

func (ElementsByValueStringDesc) Len

func (e ElementsByValueStringDesc) Len() int

func (ElementsByValueStringDesc) Less

func (e ElementsByValueStringDesc) Less(i, j int) bool

func (ElementsByValueStringDesc) Swap

func (e ElementsByValueStringDesc) Swap(i, j int)

type FloatValue32

type FloatValue32 float32

FloatValue32 type alias for int

func (FloatValue32) Float32

func (i FloatValue32) Float32() float32

Float32 casts and returns Float32 value

func (FloatValue32) Float64

func (i FloatValue32) Float64() float64

Float64 casts and returns Float64 value

func (FloatValue32) Int

func (i FloatValue32) Int() int

Int casts and returns int value

func (FloatValue32) Int32

func (i FloatValue32) Int32() int32

Int32 casts and returns Int32 value

func (FloatValue32) Int64

func (i FloatValue32) Int64() int64

Int64 casts and returns Int64 value

func (FloatValue32) String

func (i FloatValue32) String() string

String casts and returns string value

type FloatValue64

type FloatValue64 float64

FloatValue64 type alias for int

func (FloatValue64) Float32

func (i FloatValue64) Float32() float32

Float32 casts and returns Float32 value

func (FloatValue64) Float64

func (i FloatValue64) Float64() float64

Float64 casts and returns Float64 value

func (FloatValue64) Int

func (i FloatValue64) Int() int

Int casts and returns int value

func (FloatValue64) Int32

func (i FloatValue64) Int32() int32

Int32 casts and returns Int32 value

func (FloatValue64) Int64

func (i FloatValue64) Int64() int64

Int64 casts and returns Int64 value

func (FloatValue64) String

func (i FloatValue64) String() string

String casts and returns string value

type FloatValues32

type FloatValues32 []float32

FloatValues32 type alias for a slice of IntValue

func (FloatValues32) Data

func (i FloatValues32) Data() []Data

type FloatValues64

type FloatValues64 []float32

FloatValues64 type alias for a slice of IntValue

func (FloatValues64) Data

func (i FloatValues64) Data() []Data

type GenericMap

type GenericMap map[Data]Data

GenericMap is the default implementation of a map using the Data interface

func NewGenericMap

func NewGenericMap() GenericMap

func (GenericMap) Delete

func (i GenericMap) Delete(key Data)

Delete removes the element from the internal map

func (GenericMap) Get

func (i GenericMap) Get(key Data) (Data, bool)

Get retrieves a data value from the internal map if it exists

func (GenericMap) Items

func (i GenericMap) Items() []Element

Items returns the internal map as a set of elements

func (GenericMap) Iterate

func (i GenericMap) Iterate() <-chan Element

Iterate creates a channel to create an iterator for he Go range statement

func (GenericMap) Len

func (i GenericMap) Len() int

Len returns the number of stored keys

func (GenericMap) Set

func (i GenericMap) Set(key Data, value Data)

Set adds a key value pairing to the internal map

func (GenericMap) String

func (i GenericMap) String() string

String returns the JSON string representation of the map data

type IntValue

type IntValue int

IntValue type alias for int

func (IntValue) Float32

func (i IntValue) Float32() float32

Float32 casts and returns Float32 value

func (IntValue) Float64

func (i IntValue) Float64() float64

Float64 casts and returns Float64 value

func (IntValue) Int

func (i IntValue) Int() int

Int casts and returns int value

func (IntValue) Int32

func (i IntValue) Int32() int32

Int32 casts and returns Int32 value

func (IntValue) Int64

func (i IntValue) Int64() int64

Int64 casts and returns Int64 value

func (IntValue) String

func (i IntValue) String() string

String casts and returns string value

type IntValue32

type IntValue32 int32

IntValue32 type alias for int

func (IntValue32) Float32

func (i IntValue32) Float32() float32

Float32 casts and returns Float32 value

func (IntValue32) Float64

func (i IntValue32) Float64() float64

Float64 casts and returns Float64 value

func (IntValue32) Int

func (i IntValue32) Int() int

Int casts and returns int value

func (IntValue32) Int32

func (i IntValue32) Int32() int32

Int32 casts and returns Int32 value

func (IntValue32) Int64

func (i IntValue32) Int64() int64

Int64 casts and returns Int64 value

func (IntValue32) String

func (i IntValue32) String() string

String casts and returns string value

type IntValue64

type IntValue64 int64

IntValue64 type alias for int

func (IntValue64) Float32

func (i IntValue64) Float32() float32

Float32 casts and returns Float32 value

func (IntValue64) Float64

func (i IntValue64) Float64() float64

Float64 casts and returns Float64 value

func (IntValue64) Int

func (i IntValue64) Int() int

Int casts and returns int value

func (IntValue64) Int32

func (i IntValue64) Int32() int32

Int32 casts and returns Int32 value

func (IntValue64) Int64

func (i IntValue64) Int64() int64

Int64 casts and returns Int64 value

func (IntValue64) String

func (i IntValue64) String() string

String casts and returns string value

type IntValues

type IntValues []int

IntValues type alias for a slice of IntValue

func (IntValues) Data

func (i IntValues) Data() []Data

type IntValues32

type IntValues32 []int32

IntValues32 type alias for a slice of IntValue

func (IntValues32) Data

func (i IntValues32) Data() []Data

type IntValues64

type IntValues64 []int64

IntValues64 type alias for a slice of IntValue

func (IntValues64) Data

func (i IntValues64) Data() []Data

type Iterable

type Iterable interface {
    Iterate() <-chan Element
}

Iterable is anything that can be ranged on

type Map

type Map interface {
    Iterable
    Delete(key Data)
    Get(key Data) (Data, bool)
    Len() int
    Set(key Data, value Data)
    String() string
    Items() []Element
}

Map is a genetic map

type RuneValue

type RuneValue rune

RuneValue type alias for rune

func (RuneValue) Float32

func (s RuneValue) Float32() float32

Float32 casts and returns Float32 value

func (RuneValue) Float64

func (s RuneValue) Float64() float64

Float64 casts and returns Float64 value

func (RuneValue) Int

func (s RuneValue) Int() int

Int casts and returns int value

func (RuneValue) Int32

func (s RuneValue) Int32() int32

Int32 casts and returns Int32 value

func (RuneValue) Int64

func (s RuneValue) Int64() int64

Int64 casts and returns Int64 value

func (RuneValue) String

func (s RuneValue) String() string

String casts and returns string value

type RuneValues

type RuneValues []rune

RuneValues type alias for a slice of RuneValue

func (RuneValues) Data

func (s RuneValues) Data() []Data

type StringValue

type StringValue string

StringValue type alias for string

func (StringValue) Float32

func (s StringValue) Float32() float32

Float32 casts and returns Float32 value

func (StringValue) Float64

func (s StringValue) Float64() float64

Float64 casts and returns Float64 value

func (StringValue) Int

func (s StringValue) Int() int

Int casts and returns int value

func (StringValue) Int32

func (s StringValue) Int32() int32

Int32 casts and returns Int32 value

func (StringValue) Int64

func (s StringValue) Int64() int64

Int64 casts and returns Int64 value

func (StringValue) String

func (s StringValue) String() string

String casts and returns string value

type StringValues

type StringValues []string

StringValues type alias for a slice of StringValue

func (StringValues) Data

func (s StringValues) Data() []Data

type Type

type Type int

Type is a type alias for an int used for the "ENUM" definition below

const (
    UnknownType Type = iota
    IntType
    Int32Type
    Int64Type
    Float32Type
    Float64Type
    StringType

    IntSliceType
    Int32SliceType
    Int64SliceType
    Float32SliceType
    Float64SliceType
    StringSliceType
)

Collection supported types

func DetermineDataType

func DetermineDataType(data Data) Type

DetermineDataType gets the internal data type converts it to a supported collections type note this does use reflection


Generated by godoc2md

Similar Resources

This repo is where I'll be attempting to capture some generic algorithms written in Go

Go Generic Algorithms Welcome friends! 👋 This repo is where I'll be attempting

Apr 13, 2022

Basic Implementation of Data-structures in Go

Data structures in Go v1.15.6 This repo consists the implementation of the following: Stacks Queues Linked Lists (Singly) Binary Search Trees Heaps (M

May 24, 2021

Tutorial code for my video Learn to Use Basic Data Structures - Slices, Structs and Maps in Golang

Learn to Use Basic Data Structures - Slices, Structs and Maps in Golang Read text from a file and split into words. Introduction to slices / lists. Co

Jan 26, 2022

Package set is a small wrapper around the official reflect package that facilitates loose type conversion and assignment into native Go types.

Package set is a small wrapper around the official reflect package that facilitates loose type conversion and assignment into native Go types. Read th

Dec 27, 2022

Go package implementing bitsets

bitset Go language library to map between non-negative integers and boolean values Description Package bitset implements bitsets, a mapping between no

Jan 1, 2023

Go package for mapping values to and from space-filling curves, such as Hilbert and Peano curves.

Go package for mapping values to and from space-filling curves, such as Hilbert and Peano curves.

Hilbert Go package for mapping values to and from space-filling curves, such as Hilbert and Peano curves. Documentation available here This is not an

Dec 23, 2022

Package ring provides a high performance and thread safe Go implementation of a bloom filter.

ring - high performance bloom filter Package ring provides a high performance and thread safe Go implementation of a bloom filter. Usage Please see th

Nov 20, 2022

Go package implementing Bloom filters

Bloom filters A Bloom filter is a representation of a set of n items, where the main requirement is to make membership queries; i.e., whether an item

Dec 30, 2022

Go package implementing an indexable ordered multimap

PACKAGE package skiplist import "github.com/glenn-brown/skiplist" Package skiplist implements fast indexable ordered multimaps. This sk

Jul 2, 2022
Type-agnostic partitioning for Go's indexable collections and strings.

Go Type-Agnostic Collection Partitioning Type-agnostic partitioning for anything that can be indexed in Go - slices, arrays,strings. Inspired by Guava

Aug 11, 2021
Collections for Golang using generics. Currently containing Hash Set.
Collections for Golang using generics. Currently containing Hash Set.

Implementation of missing colections for Golang using Generics. Free of dependencies. Curently in early development phase. Requirements Go 1.18+ Insta

Dec 30, 2021
Python-like dictionaries for Go

Dict Python dictionary data type (dict) in Go Package dict is a Go implementation of Python dict, which are hashable object maps. Dictionaries complem

Nov 1, 2022
Solutions to AlgoExpert Problems in Six Programming Languages: Python, Java, Go, C++, C#, JavaScript/TypeScript
Solutions to AlgoExpert Problems in Six Programming Languages: Python, Java, Go, C++, C#, JavaScript/TypeScript

Solutions to AlgoExpert Problems in Six Programming Languages: Python, Java, Go, C++, C#, JavaScript/TypeScript Discover solutions to AlgoExpert probl

Dec 11, 2022
A Go implementation of the core algorithm in paper

Boolean Expression Indexer Go library A Go implementation of the core algorithm in paper <Indexing Boolean Expression>, which already supports the fol

Dec 26, 2022
AVL tree with some useful extensions written in Go

gocover An AVL tree (Adel'son-Vel'skii & Landis) is a binary search tree in which the heights of the left and right subtrees of the root differ by at

Mar 23, 2022
Some algorithms in go: maxflow(min-cuts or graph-cuts), edit-distance.

Algorithms In this repository, some algorithms are implemented in go language. GoDoc link: ed maxflow About Max-flow problem: A flow network is repres

Sep 8, 2022
fim is a collection of some popular frequent itemset mining algorithms implemented in Go.

fim fim is a collection of some popular frequent itemset mining algorithms implemented in Go. fim contains the implementations of the following algori

Jul 14, 2022
A Connected Graph Generator tool that construct graphs of some given size

graph graph is a Connected Graph Generator tool that construct graphs of some given size. Notice that it generates all possible connected, undirected

Nov 5, 2021
Some data structures and algorithms using golang

Some data structures and algorithms using golang

Aug 13, 2022