linker

package
v0.7.1 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Link[K cmp.Ordered, V any] struct {
	// contains filtered or unexported fields
}

Link is a vertex in a graph that can be linked to other vertices. It is a named vertex that can have multiple edges to other vertices. There are two types of edges: one-to-one and one-to-many.

func NamedVertexWithVertex

func NamedVertexWithVertex[K cmp.Ordered, V any](vertex Linker[K]) *Link[K, V]

func NewNamedVertex

func NewNamedVertex[K cmp.Ordered, V any](names ...K) *Link[K, V]

func NewNamedVertexWithValue

func NewNamedVertexWithValue[K cmp.Ordered, V any](item *V, names ...K) *Link[K, V]

func (*Link[K, V]) Clone

func (nl *Link[K, V]) Clone() Linker[K]

Clone returns a copy of the vertex

func (*Link[K, V]) Each

func (nl *Link[K, V]) Each(name K, fn func(K, Linker[K]))

Each iterates over all edges

func (*Link[K, V]) Find

func (nl *Link[K, V]) Find(name K, key K) (Linker[K], bool)

func (*Link[K, V]) Get

func (nl *Link[K, V]) Get(name K) Linker[K]

func (*Link[K, V]) Item

func (nl *Link[K, V]) Item() *V

func (*Link[K, V]) Len

func (nl *Link[K, V]) Len(name K) int

func (*Link[K, V]) LinkOneMany

func (nl *Link[K, V]) LinkOneMany(name K, key K, vtx Linker[K])

LinkOneMany adds an edge from this vertex to specified vertex

func (*Link[K, V]) LinkOneOne

func (nl *Link[K, V]) LinkOneOne(name K, key K, vertex Linker[K])

LinkOneOne links a vertex to the vertex

func (*Link[K, V]) MarshalJSON

func (nl *Link[K, V]) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface

func (*Link[K, V]) SetItem

func (nl *Link[K, V]) SetItem(item *V)

func (*Link[K, V]) UnlinkAllOneMany

func (nl *Link[K, V]) UnlinkAllOneMany(name K) []Linker[K]

UnlinkAllOneMany removes all edges from the vertex and returns them

func (*Link[K, V]) UnlinkOneMany

func (nl *Link[K, V]) UnlinkOneMany(name K, key K) (Linker[K], bool)

UnlinkOneMany removes links to a vertex and returns the vertex

func (*Link[K, V]) UnlinkOneOne

func (nl *Link[K, V]) UnlinkOneOne(name K) (Linker[K], bool)

UnlinkOneOne unlinks a vertex from the vertex and returns the vertex

func (*Link[K, V]) UnlinkOneOneByKey

func (nl *Link[K, V]) UnlinkOneOneByKey(name K, key K) (Linker[K], bool)

UnlinkOneOne unlinks a vertex from the vertex and returns the vertex

func (*Link[K, V]) UnmarshalJSON

func (nl *Link[K, V]) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface

func (*Link[K, V]) Vertex

func (nl *Link[K, V]) Vertex() Linker[K]

type Linker

type Linker[K cmp.Ordered] interface {
	Vertex() Linker[K]
	Get(K) Linker[K]
	Len(K) int
	Find(K, K) (Linker[K], bool)
	Each(K, func(K, Linker[K]))
	LinkOneMany(K, K, Linker[K])
	UnlinkOneMany(K, K) (Linker[K], bool)
	UnlinkAllOneMany(K) []Linker[K]
	LinkOneOne(K, K, Linker[K])
	UnlinkOneOne(K) (Linker[K], bool)
	UnlinkOneOneByKey(K, K) (Linker[K], bool)
	Clone() Linker[K]
}

Jump to

Keyboard shortcuts

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