ancestor

package
v1.11.6-stella Latest Latest
Warning

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

Go to latest
Published: May 25, 2024 License: BSD-3-Clause Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Tree

type Tree interface {
	// Add a mapping from blkID to parentID.
	//
	// Invariant: blkID must not be equal to parentID
	// Invariant: a given blkID must only ever have one parentID
	Add(blkID ids.ID, parentID ids.ID)

	// Has returns if blkID's parentID is known by the tree.
	Has(blkID ids.ID) bool

	// GetAncestor returns the oldest known ancestor of blkID. If there is no
	// known parentID of blkID, blkID will be returned.
	GetAncestor(blkID ids.ID) ids.ID

	// Remove the mapping from blkID to its parentID from the tree.
	Remove(blkID ids.ID)

	// RemoveDescendants removes blkID from the tree along with all of its known
	// descendants.
	RemoveDescendants(blkID ids.ID)

	// Len returns the total number of blkID to parentID mappings that are
	// currently tracked by the tree.
	Len() int
}

Tree manages a (potentially partial) view of a tree.

For example, assume this is the full tree:

	A
  /	  \
B		D
|		|
C		E

A partial view of this tree may be:

	A
  /
B		D
|		|
C		E

Or:

B		D
|		|
C		E

This structure is designed to update and traverse these partial views.

func NewTree

func NewTree() Tree

Jump to

Keyboard shortcuts

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