container

package
v0.0.0-...-d2861cf Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2018 License: MIT Imports: 8 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Applier

type Applier interface {
	// Applier interface iterates over values and applies function fun on each value.
	// Applier returns true function fun could be applied to each element, and false otherwise.
	Apply(fun func(interface{}) interface{}) bool
}

Applier interface describes for map functionality for collections.

type Interlabel

type Interlabel interface {
	Id() (id string)
}

Interlabel is an internal interface for manipulating a label.

type Intertemplate

type Intertemplate interface {
	Applier
	Length() int
	Fields() []interface{}
	GetFieldAt(i int) interface{}
	NewTuple() Tuple
}

Intertemplate an interface for manipulating templates.

type Intertuple

type Intertuple interface {
	Applier
	Tuple() Tuple
	Length() int
	Fields() []interface{}
	GetFieldAt(i int) interface{}
	SetFieldAt(i int, val interface{}) bool
}

Intertuple defines an interface for manipulating tuples.

type Label

type Label Tuple

Label is a structure used to label arbitrary data.

func NewLabel

func NewLabel(id string) (l Label)

NewLabel creates a new label with identifier id and an optional value v.

func (*Label) DeepCopy

func (l *Label) DeepCopy() (lc Label)

DeepCopy returns a deep copy of the label {

func (Label) Delimiter

func (l Label) Delimiter() string

Delimiter returns the delimiter used to seperated the values in label l. Delimiter is used in the String() method.

func (*Label) Equal

func (l *Label) Equal(m *Label) (e bool)

Equal returns true if both labels l and m are equivalent, and false otherwise.

func (*Label) ID

func (l *Label) ID() (id string)

ID returns label l's identifier id.

func (Label) ParenthesisType

func (l Label) ParenthesisType() (ls string, rs string)

ParenthesisType returns a pair of strings that encapsulates the tuple. ParenthesisType is used in the String() method.

func (Label) String

func (l Label) String() (s string)

String returns a print friendly representation of label l.

type LabelledTuple

type LabelledTuple Tuple

LabelledTuple is a labelled tuple containing a list of fields and a label set. Fields can be any data type and is used to store data. TupleLabels is a label set that is associated to the tuple itself.

func NewLabelledTuple

func NewLabelledTuple(fields ...interface{}) (lt LabelledTuple)

NewLabelledTuple creates a labelled tuple according to the labels and values present in the fields. NewLabelledTuple searches the first field for labels.

func (*LabelledTuple) Apply

func (lt *LabelledTuple) Apply(fun func(field interface{}) interface{}) (b bool)

Apply iterates through the labelled tuple t and applies the function fun to each field. Apply returns true function fun could be applied to all the fields, and false otherwise.

func (LabelledTuple) Delimiter

func (lt LabelledTuple) Delimiter() string

Delimiter returns the delimiter used to seperate a labelled tuple t's fields. Delimiter is used in the String() method.

func (*LabelledTuple) Fields

func (lt *LabelledTuple) Fields() (flds []interface{})

Fields returns the fields of the tuple.

func (*LabelledTuple) GetFieldAt

func (lt *LabelledTuple) GetFieldAt(i int) (fld interface{})

GetFieldAt returns the i'th field of the tuple.

func (*LabelledTuple) Labels

func (lt *LabelledTuple) Labels() (ls Labels)

Labels returns the label set belonging to the labelled tuple.

func (*LabelledTuple) Length

func (lt *LabelledTuple) Length() (sz int)

Length returns the amount of fields of the tuple.

func (*LabelledTuple) MatchLabels

func (lt *LabelledTuple) MatchLabels(ls Labels) (mls *Labels, b bool)

MatchLabels matches a labelled tuples t labels against labels ls.

func (*LabelledTuple) MatchTemplate

func (lt *LabelledTuple) MatchTemplate(tp Template) (b bool)

MatchTemplate pattern matches labelled tuple t against the template tp. MatchTemplate discriminates between encapsulated formal fields and actual fields. MatchTemplate returns true if the template matches the labelled tuple and false otherwise.

func (LabelledTuple) ParenthesisType

func (lt LabelledTuple) ParenthesisType() (string, string)

ParenthesisType returns a pair of strings that encapsulates labelled tuple t. ParenthesisType is used in the String() method.

func (*LabelledTuple) SetFieldAt

func (lt *LabelledTuple) SetFieldAt(i int, val interface{}) (b bool)

SetFieldAt sets the i'th field of the tuple to the value of val.

func (LabelledTuple) String

func (lt LabelledTuple) String() (s string)

String returns a print friendly representation of the tuple.

func (*LabelledTuple) Tuple

func (lt *LabelledTuple) Tuple() (t Tuple)

Tuple returns a tuple without the label.

type Labels

type Labels map[string]Label

Labels is structure used to represent a set of labels. Labels purpose is to conveniently manipulate many labels.

func NewLabels

func NewLabels(ll ...Label) (ls Labels)

NewLabels creates a new collections of labels from parameter list ll.

func (*Labels) Add

func (ls *Labels) Add(l Label) (b bool)

Add adds a label l to label set ls. Add returns true if the label has been added, and false otherwise.

func (*Labels) Delete

func (ls *Labels) Delete(id string) (b bool)

Delete deletes a label l from label set ls. Delete returns true if the label has been deleted, and false otherwise.

func (*Labels) Intersect

func (ls *Labels) Intersect(lm *Labels) (li *Labels, e bool)

Intersect returns true if both label sets ls and lm intersect, and false otherwise. Intersect returns an intersected label set li if ls and lm intersect, and nil otherwise.

func (*Labels) Labelling

func (ls *Labels) Labelling() (labelling []string)

Labelling returns the labels identifiers present in the label set ls.

func (*Labels) Retrieve

func (ls *Labels) Retrieve(id string) (l *Label)

Retrieve returns a label l in the label set ls. Retrieve returns a reference to the label if it exists and nil otherwise.

func (*Labels) Set

func (ls *Labels) Set() (set []Label)

Set returns the set of all labels in ls.

func (Labels) String

func (ls Labels) String() (s string)

String returns a print friendly representation of the labels set ls.

type Signature

type Signature interface{}

Signature represents structure for a signature of values.

func NewSignature

func NewSignature(rd uint, val interface{}) (s Signature)

NewSignature creates a hashed signature by recursively traversing the value val. NewSignature expects a recursion depth of rd if it encounters structs, maps or slices.

func NewTypeSignature

func NewTypeSignature(rd uint, val interface{}) (s Signature)

NewTypeSignature creates a hashed signature by recursively traversing the value val. NewTypeSignature expects a recursion depth of rd if it encounters structs, maps or slices.

type Template

type Template struct {
	Flds []interface{} `bson:"fields" json:"fields" xml:"fields"`
}

Template structure used for matching against tuples. Template is a tuple with type information used for pattern matching.

func NewTemplate

func NewTemplate(fields ...interface{}) (tp Template)

NewTemplate creates a template from the variadic fields provided. NewTemplate encapsulates the types of pointer values.

func (*Template) Apply

func (tp *Template) Apply(fun func(field interface{}) interface{}) (b bool)

Apply iterates through the template tp and applies the function fun to each field. Apply returns true function fun could be applied to all the fields, and false otherwise.

func (*Template) Equal

func (tp *Template) Equal(tq *Template) (e bool)

Equal returns true if both templates tp and tq are strictly equal, and false otherwise.

func (*Template) ExactMatch

func (tp *Template) ExactMatch(tq *Template) (e bool, pno, qno uint)

ExactMatch returns true if both templates tp and tq are equivalent up to their types and the maximum amount of concrete values matched w.r.t. tq given the amount of concrete values in tp.

func (*Template) Fields

func (tp *Template) Fields() (flds []interface{})

Fields returns the fields of the template.

func (Template) GetDelimiter

func (tp Template) GetDelimiter() string

GetDelimiter returns the delimiter used to seperated the template fields. GetParenthesisType is used in the String() method.

func (*Template) GetFieldAt

func (tp *Template) GetFieldAt(i int) (fld interface{})

GetFieldAt returns the i'th field of the template.

func (Template) GetParenthesisType

func (tp Template) GetParenthesisType() (string, string)

GetParenthesisType returns a pair of strings that encapsulates the template. GetParenthesisType is used in the String() method.

func (*Template) Length

func (tp *Template) Length() (sz int)

Length returns the size of the template.

func (*Template) Match

func (tp *Template) Match(tq *Template) (e bool)

Match returns true if both templates tp and tq are equivalent up to their types, and false otherwise.

func (*Template) NewTuple

func (tp *Template) NewTuple() (t Tuple)

NewTuple returns a new tuple t from the template. NewTuple initializes all tuple fields in t with empty values depending on types in the template.

func (Template) String

func (tp Template) String() string

String returns a print friendly representation of the template.

type Tuple

type Tuple struct {
	Flds []interface{} `bson:"fields" json:"fields" xml:"fields"`
}

Tuple contains a set of fields, where fields can be any primitive or type. A tuple is used to store information which is placed in a tuple space.

func CreateIntrinsicTuple

func CreateIntrinsicTuple(t ...interface{}) (tp Tuple)

CreateIntrinsicTuple creates a intrinsic tuple belonging to template t. CreateIntrinsicTuple initializes according to the template fields in tp by reading of concrete values. If CreateIntrinsicTuple finds a field containing a pointer, this field will be dereferenced and the value read.

func NewTuple

func NewTuple(fields ...interface{}) Tuple

NewTuple create a tuple according to the values in the fields.

func (*Tuple) Apply

func (t *Tuple) Apply(fun func(field interface{}) interface{}) (b bool)

Apply iterates through the tuple t and applies the function fun to each field. Apply returns true function fun could be applied to all the fields, and false otherwise.

func (*Tuple) Fields

func (t *Tuple) Fields() (flds []interface{})

Fields returns the fields of the tuple.

func (Tuple) GetDelimiter

func (t Tuple) GetDelimiter() string

GetDelimiter returns the delimiter used to seperated the tuple fields. GetParenthesisType is used in the String() method.

func (*Tuple) GetFieldAt

func (t *Tuple) GetFieldAt(i int) (fld interface{})

GetFieldAt returns the i'th field of the tuple.

func (Tuple) GetParenthesisType

func (t Tuple) GetParenthesisType() (string, string)

GetParenthesisType returns a pair of strings that encapsulates the tuple. GetParenthesisType is used in the String() method.

func (*Tuple) Length

func (t *Tuple) Length() (sz int)

Length returns the amount of fields of the tuple.

func (*Tuple) Match

func (t *Tuple) Match(tp Template) (b bool)

Match pattern matches the tuple against the template tp. Match discriminates between encapsulated formal fields and actual fields. Match returns true if the template matches the tuple, and false otherwise.

func (*Tuple) SetFieldAt

func (t *Tuple) SetFieldAt(i int, val interface{}) (b bool)

SetFieldAt sets the i'th field of the tuple to the value of val.

func (Tuple) String

func (t Tuple) String() string

String returns a print friendly representation of the tuple.

func (*Tuple) Tuple

func (t *Tuple) Tuple() (tn Tuple)

Tuple returns a new tuple.

func (*Tuple) WriteToVariables

func (t *Tuple) WriteToVariables(params ...interface{}) (b bool)

WriteToVariables will overwrite the values pointed to by pointers with the values contained in the tuple. WriteToVariables will ignore unaddressable pointers. TODO: There should be placed a lock around the variables that are being changed, to ensure that mix of two tuple are written to the variables.

type TypeField

type TypeField struct {
	TypeStr string `bson:"type" json:"type" xml:"type"`
}

TypeField encapsulate a type.

func CreateTypeField

func CreateTypeField(t interface{}) TypeField

CreateTypeField creates an encapsulation of a type.

func (TypeField) Equal

func (tf TypeField) Equal(tfo TypeField) (e bool)

Equal returns true if both type field a and b are quivalent, and false otherwise.

func (TypeField) GetType

func (tf TypeField) GetType() (t reflect.Type)

GetType returns a type associated to this Typefield.

func (TypeField) String

func (tf TypeField) String() string

String returns the type string of this TypeField.

type TypeRegistry

type TypeRegistry *sync.Map

TypeRegistry represents a registry of types.

Jump to

Keyboard shortcuts

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