Coverage

References
public readonly struct Coverage
A coverage specifies items, twigs or even entire trees using two integers. Coverages ignore actual paths, opting instead to identify elements using indices alone.

Properties

Access

#
public Access Access { get; }
Gets the scope of coverage.

ItemIndex

#
public int ItemIndex { get; }
Gets the item index.

TwigIndex

#
public int TwigIndex { get; }
Gets the twig index.

Methods

CreateFromAccess

#
public static Coverage CreateFromAccess(Access access)
Create the initial coverage implied by an access flag.
access (Access)

CreateItemCoverage

#
public static Coverage CreateItemCoverage(int twigIndex, int itemIndex)
Create coverage for a specific item.
twigIndex (int)Index of twig within tree.
itemIndex (int)Index of item within twig.
Coverage.

CreateTreeCoverage

#
public static Coverage CreateTreeCoverage()
Create coverage for an entire tree.
Coverage.

CreateTwigCoverage

#
public static Coverage CreateTwigCoverage(int twigIndex)
Create coverage for a specific twig.
twigIndex (int)Index of twig within tree.
Coverage.

IncrementItem

#
public Coverage IncrementItem()
Move the coverage to the next item. This method can only be called if the coverage access is Access.Item.
New coverage.

IncrementTwig

#
public Coverage IncrementTwig()
Move the coverage to the next twig. This method can only be called if the coverage access is not Access.Tree.
New coverage.

IsValidCoverage

#
public static bool IsValidCoverage(Coverage coverage, ITree tree)
Test whether a specific coverage validly applies to a tree.
coverage (Coverage)
tree (ITree)

IsValidCoverage

#
public static bool IsValidCoverage(Coverage[] coverages, ITree[] trees)
Test whether the given coverages correctly identify specific elements of a an array of trees.
coverages (Coverage[])
trees (ITree[])

Slice

#
public ITree Slice(ITree tree, bool graftItem)
Create a new tree based on this coverage of an existing tree.
tree (ITree)Tree to slice.
graftItem (bool)If true, and the Access of this coverage is Access.Item, the item index will be appended to the returned tree.

ToString

#
public override string ToString()
Gets a description of this coverage.

TryIncrementItem

#
public bool TryIncrementItem(ITree tree, out Coverage incremented)
Try and increment a coverage to the next item index.
tree (ITree)Tree constraint.
incremented (out Coverage)Incremented or this coverage.

TryIncrementItems

#
public static bool TryIncrementItems(Coverage[] coverages, ITree[] trees, bool[] modified = null)
Try and increment all coverages whose Access is set to Access.Item to the next item index.
coverages (Coverage[])Coverages to increment.
trees (ITree[])Tree constraints.
modified (bool[] = null)Optional boolean array for individual coverage modifications. Must be of the same size as the coverages and trees array and should contain only false values.
True if at least one coverage in the array was successfully incremented.

TryIncrementTwig

#
public bool TryIncrementTwig(ITree tree, out Coverage incremented)
Try and increment a coverage to the next twig index.
tree (ITree)Tree constraint.
incremented (out Coverage)Incremented or this coverage.

TryIncrementTwigs

#
public static bool TryIncrementTwigs(Coverage[] coverages, ITree[] trees, bool[] modified = null)
Try and increment all coverages whose Access is set to either Access.Item or Access.Twig to the next twig index.
coverages (Coverage[])Coverages to increment.
trees (ITree[])Tree constraints.
modified (bool[] = null)Optional boolean array for individual coverage modifications. Must be of the same size as the coverages and trees array and should contain only false values.
True if at least one coverage in the array was successfully incremented.