Documentation ¶
Overview ¶
Tree is thread protected any direction multi-child tree implementation with way cost child.
Index ¶
- Variables
- type Element
- func (e *Element[T]) Add(c *Element[T], options ...WayOptions) (*Element[T], error)
- func (e *Element[T]) Cost(c *Element[T]) (cost float64, ok bool)
- func (e *Element[T]) Del(c *Element[T]) (*Element[T], error)
- func (e *Element[T]) PathTo(dst *Element[T]) (p *PathArray[T])
- func (e *Element[T]) Remove() (*Element[T], error)
- func (e *Element[T]) String() (str string)
- func (e *Element[T]) Value() T
- func (e *Element[T]) WayAllowed(c *Element[T]) bool
- func (e *Element[T]) Ways() waysMap[T]
- type Path
- type PathArray
- type PathSortOptions
- type Tree
- type TreeData
- type WayOptions
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrChildAlreadyAdded = errors.New("child already added") ErrParentAlreadyAdded = errors.New("parent already added") )
Functions ¶
This section is empty.
Types ¶
type Element ¶
Element is the multi-chields tree element
func (*Element[T]) Add ¶
func (e *Element[T]) Add(c *Element[T], options ...WayOptions) (*Element[T], error)
Add adds way from e tree element to the c tree element
func (*Element[T]) WayAllowed ¶
WayAllowed return true if the path from e to c element is available
type PathArray ¶
type PathArray[T TreeData] struct { // contains filtered or unexported fields }
PathArray contains array of Path and mrthods to process this array
func (*PathArray[T]) Sort ¶
func (p *PathArray[T]) Sort(options ...PathSortOptions) *PathArray[T]
Sort sorts PathArray
type PathSortOptions ¶
type PathSortOptions struct { SortByCost bool // default true SortByPeers bool // default true SortByCostFirst bool // default true }
PathSortOptions is path sort options used in Sort function
type TreeData ¶
type TreeData interface {
String() string
}
TreeData interface represents TreeData required methods
type WayOptions ¶
type WayOptions struct { // Cost (weight) of this way (way to this element) Cost float64 // If true than The road available only oneway from this element to selected // element (to child), and not available back from selected element (from // child) to this element Oneway bool }
WayOptions is way options
Click to show internal directories.
Click to hide internal directories.