Documentation ¶
Index ¶
- type Navigator
- func (n *Navigator[Key, Node, Context]) IdxKey() Key
- func (n *Navigator[Key, Node, Context]) Pop() (node Node, ok bool)
- func (n *Navigator[Key, Node, Context]) Seek(create bool, ctx Context) (next Node, ok bool)
- func (n *Navigator[Key, Node, Context]) Trace(trace bool) *Navigator[Key, Node, Context]
- type Nexter
- type VoidContext
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Navigator ¶
type Navigator[Key any, Node Nexter[Key, Node, Context], Context any] struct { Cur Node Idx int Keys slice.Slice[Key] TraceNodes bool Nodes slice.Slice[Node] }
Navigator can move through graph like structures whose nodes fulfill Nexter.
func (*Navigator[Key, Node, Context]) IdxKey ¶
func (n *Navigator[Key, Node, Context]) IdxKey() Key
IdxKey is a helper to get the key at the current index
func (*Navigator[Key, Node, Context]) Pop ¶
Pop the last value in Nodes off and assign it to Cur. This requires that Nodes are populated. So in order to use this after a Seek operation, TraceNodes needs to be true prior to the seek operation.
type Nexter ¶
type Nexter[Key, Node, Context any] interface { Next(key Key, create bool, ctx Context) (Node, bool) }
Nexter represents a node structure that can get the next node based on the key. If "create" is true, the Next method should create the node if it does not exist. Context allows arbitrary additional information to be passed in that may be necessary to perform the Next operation.
type VoidContext ¶
type VoidContext struct{}
VoidContext is provided as a helper for instances where Context is not necessary.
var Void VoidContext
Void is an instance of VoidContext