primitive

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2020 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ID_KEY   = "_id"
	TYPE_KEY = "_type"
)
View Source
const AnyType = "*"
View Source
const DefaultType = "default"

Variables

This section is empty.

Functions

func UUID added in v0.11.0

func UUID() string

Types

type Edge

type Edge struct {
	// An edge implements Node because it has an Identifier and attributes
	Node `json:"node"`
	// From returns the root node of the edge
	From Node `json:"from"`
	// To returns the target node of the edge
	To Node `json:"to"`
}

Edge is a relationship between two nodes

func (*Edge) JSON

func (e *Edge) JSON() ([]byte, error)

type Export added in v0.1.1

type Export struct {
	Nodes []Node  `json:"nodes"`
	Edges []*Edge `json:"edges"`
}

type Graph

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

Graph is a concurrency safe, mutable, in-memory directed graph

func NewGraph

func NewGraph() *Graph

func (*Graph) AddEdge

func (g *Graph) AddEdge(e *Edge) error

func (*Graph) AddEdges

func (g *Graph) AddEdges(edges ...*Edge) error

func (*Graph) AddNode

func (g *Graph) AddNode(n Node)

func (*Graph) AddNodes

func (g *Graph) AddNodes(nodes ...Node)

func (*Graph) Close

func (g *Graph) Close()

func (*Graph) DelEdge

func (g *Graph) DelEdge(id TypedID)

func (*Graph) DelNode

func (g *Graph) DelNode(id TypedID)

func (*Graph) EdgeTypes

func (g *Graph) EdgeTypes() []string

func (*Graph) EdgesFrom

func (g *Graph) EdgesFrom(edgeType Type, id TypedID, fn func(e *Edge) bool)

func (*Graph) EdgesTo

func (g *Graph) EdgesTo(edgeType Type, id TypedID, fn func(e *Edge) bool)

func (*Graph) Export added in v0.1.1

func (g *Graph) Export() *Export

func (*Graph) GetEdge

func (g *Graph) GetEdge(id TypedID) (*Edge, bool)

func (*Graph) GetNode

func (g *Graph) GetNode(id TypedID) (Node, bool)

func (*Graph) HasEdge

func (g *Graph) HasEdge(id TypedID) bool

func (*Graph) HasNode

func (g *Graph) HasNode(id TypedID) bool

func (*Graph) Import added in v0.1.1

func (g *Graph) Import(exp *Export) error

func (*Graph) NodeTypes

func (g *Graph) NodeTypes() []string

func (*Graph) RangeEdgeTypes

func (g *Graph) RangeEdgeTypes(edgeType Type, fn func(e *Edge) bool)

func (*Graph) RangeEdges

func (g *Graph) RangeEdges(fn func(e *Edge) bool)

func (*Graph) RangeNodeTypes

func (g *Graph) RangeNodeTypes(typ Type, fn func(n Node) bool)

func (*Graph) RangeNodes

func (g *Graph) RangeNodes(fn func(n Node) bool)

type ID

type ID interface {
	ID() string
}

type Node

type Node map[string]interface{}

Node is a functional hash table for storing arbitrary data. It is not concurrency safe

func NewNode

func NewNode(attributes map[string]interface{}) Node

func (Node) Copy

func (m Node) Copy() Node

Copy creates a replica of the Node

func (Node) Del

func (m Node) Del(key string)

Del deletes the entry from the Node by key

func (Node) Equals

func (v Node) Equals(other Node) bool

func (Node) Exists

func (m Node) Exists(key string) bool

Exists returns true if the key exists in the Node

func (Node) Filter

func (m Node) Filter(filter func(key string, v interface{}) bool) Node

Filter returns a Node of the node that return true from the filter function

func (Node) FromJSON

func (m Node) FromJSON(data []byte) error

func (Node) Get

func (m Node) Get(key string) interface{}

Get gets an entry from the Node by key

func (Node) GetBool

func (m Node) GetBool(key string) bool

func (Node) GetInt

func (m Node) GetInt(key string) int

func (Node) GetNested

func (v Node) GetNested(key string) (Node, bool)

func (Node) GetString

func (m Node) GetString(key string) string

GetString gets an entry from the Node by key

func (Node) HasID

func (n Node) HasID() bool

func (Node) ID

func (n Node) ID() string

func (Node) Intersection

func (m Node) Intersection(other Node) Node

Intersection returns the node that exist in both Nodes ref: https://en.wikipedia.org/wiki/Intersection_(set_theory)#:~:text=In%20mathematics%2C%20the%20intersection%20of,that%20also%20belong%20to%20A).

func (Node) IsNested

func (v Node) IsNested(key string) bool

func (Node) JSON

func (v Node) JSON() ([]byte, error)

func (Node) Range

func (m Node) Range(iterator func(key string, v interface{}) bool)

Range iterates over the Node with the function. If the function returns false, the iteration exits.

func (Node) Read

func (n2 Node) Read(p []byte) (n int, err error)

func (Node) Set

func (m Node) Set(k string, v interface{})

Set set an entry in the Node

func (Node) SetAll

func (m Node) SetAll(data map[string]interface{})

SetAll set all entries in the Node

func (Node) SetID

func (n Node) SetID(id string)

func (Node) SetNested

func (v Node) SetNested(key string, node Node)

func (Node) SetType

func (n Node) SetType(nodeType string)

func (Node) Type

func (n Node) Type() string

func (Node) Union

func (m Node) Union(other Node) Node

Union returns the all node in both Nodes ref: https://en.wikipedia.org/wiki/Union_(set_theory)

func (Node) Validate

func (n Node) Validate() error

func (Node) Write

func (n2 Node) Write(p []byte) (n int, err error)

type Type

type Type interface {
	Type() string
}

type TypedID

type TypedID interface {
	ID
	Type
}

Jump to

Keyboard shortcuts

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