Skip to content

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

License

Notifications You must be signed in to change notification settings

marcsantiago/collections

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

59 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

collections

import "github.com/marcsantiago/collections"

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

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

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

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 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 struct {
    Key   Data
    Value Data
}

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

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 []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 []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 []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 []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 []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 []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 []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 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 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 []float32

FloatValues32 type alias for a slice of IntValue

func (FloatValues32) Data

func (i FloatValues32) Data() []Data
type FloatValues64 []float32

FloatValues64 type alias for a slice of IntValue

func (FloatValues64) Data

func (i FloatValues64) Data() []Data
type GenericMap map[Data]Data

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

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 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 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 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 []int

IntValues type alias for a slice of IntValue

func (IntValues) Data

func (i IntValues) Data() []Data
type IntValues32 []int32

IntValues32 type alias for a slice of IntValue

func (IntValues32) Data

func (i IntValues32) Data() []Data
type IntValues64 []int64

IntValues64 type alias for a slice of IntValue

func (IntValues64) Data

func (i IntValues64) Data() []Data
type Iterable interface {
    Iterate() <-chan Element
}

Iterable is anything that can be ranged on

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 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 []rune

RuneValues type alias for a slice of RuneValue

func (RuneValues) Data

func (s RuneValues) Data() []Data
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 []string

StringValues type alias for a slice of StringValue

func (StringValues) Data

func (s StringValues) Data() []Data
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(data Data) Type

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


Generated by godoc2md

About

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

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages