Tree

[DebuggerDisplay("Tree p:{Paths.Count} i:{LeafCount}")] public sealed class Tree : ITree
A non-generic data tree.

Properties

AllItems

#
public IEnumerable<object> AllItems { get; }
Enumerate over all items in this tree.
AllItems

AllPears

#
public IEnumerable<IPear> AllPears { get; }
Enumerate over all item/meta data pears in this tree.
AllPears

AllTwigs

#
public IEnumerable<ITwig> AllTwigs { get; }
Enumerate over all twigs in this tree.
AllTwigs

CommonMetaData

#
public MetaData CommonMetaData { get; }
Gets the non-conflicting meta data inside this tree.
CommonMetaData

Description

#
public string Description { get; }
Gets a string describing the topology of this tree.
Description

ItemCount

#
public int ItemCount { get; }
Gets the total number of non-null items in this tree.
ItemCount

Items

#
public IItemAccessor Items { get; }
Access the items in this tree.
Items

LeafCount

#
public int LeafCount { get; }
Gets the number of leaf items in this tree (this includes all items and all nulls).
LeafCount

MetaCount

#
public int MetaCount { get; }
Gets the number of meta data entries.
MetaCount

NonNullItems

#
public IEnumerable<object> NonNullItems { get; }
Enumerate over all non-null items in this tree.
NonNullItems

NonNullPears

#
public IEnumerable<IPear> NonNullPears { get; }
Enumerate over all non-null item/meta data pears in this tree.
NonNullPears

NullCount

#
public int NullCount { get; }
Gets the total number of null items in this tree.
NullCount

PathCount

#
public int PathCount { get; }
Gets the number of paths (and thus twigs) in this tree.
PathCount

Paths

#
public Paths Paths { get; }
Access the paths of this tree.
Paths

Pears

#
public IPearAccessor Pears { get; }
Access the pears in this tree.
Pears

Twigs

#
public ITwigAccessor Twigs { get; }
Access the twigs in this tree.
Twigs

Type

#
public Type Type { get; }
Gets the type of the data stored in this tree.
Type

TypeAssistant

#
public ITypeAssistant TypeAssistant { get; }
Gets the type assistant (if any) associated with the type constraint. More derived types that are stored in this tree may have more specific type assistants.
TypeAssistant

TypeFlavour

#
public TypeFlavour TypeFlavour { get; }
Gets some information about the generic type parameter of this tree.
TypeFlavour

Methods

ConvertItems<Q>

#
public Tree<Q> ConvertItems<Q>(Func<object, Q> replaceItem, Pear<Q> nullReplacement = null, CancellationToken token = default(CancellationToken))
Modify all items in this tree.
replaceItem (Func<object, Q>)Replacement method for non-null items.
nullReplacement (Pear<Q> = null)Replacement pear for null values. If not provided, nulls are simply persisted.
token (CancellationToken = null)Cancellation token.
ConvertItems

ConvertPears

#
public ITree ConvertPears(Func<IPear, IPear> replacePear, IPear nullReplacement = null, CancellationToken token = default(CancellationToken))
Modify all pears in this tree.
replacePear (Func<IPear, IPear>)Replacement method for non-null pears.
nullReplacement (IPear = null)Replacement method for nulls. If not provided, nulls are simply persisted.
token (CancellationToken = null)Cancellation token.
ConvertPears

ConvertPears<Q>

#
public Tree<Q> ConvertPears<Q>(Func<IPear, Pear<Q>> replacePear, Pear<Q> nullReplacement = null, CancellationToken token = default(CancellationToken))
Modify all pears in this tree.
replacePear (Func<IPear, Pear<Q>>)Replacement method for non-null items.
nullReplacement (Pear<Q> = null)Replacement method for nulls. If not provided, nulls are simply persisted.
token (CancellationToken = null)Cancellation token.
ConvertPears

Filter

#
public ITree Filter(IEnumerable<SiteRule> rules)
Apply a collection of rules to all the twigs and all the items in this tree.
rules (IEnumerable<SiteRule>)Rules to apply.
A new tree with only the twigs and items that were valid under the given rules.
Filter

Filter

#
public ITree Filter(params SiteRule[] rules)
Apply one or more rules to all the twigs and all the items in this tree.
rules (params SiteRule[])Rules to apply.
A new tree with only the twigs and items that were valid under the given rule.
Filter

Flatten

#
public ITree Flatten()
Flatten the entire tree.
Modified tree.
Flatten

Flatten

#
public ITree Flatten(Path path)
Flatten the entire tree.
path (Path)Path to flatten into.
Modified tree.
Flatten

Flip

#
public ITree Flip(int elementIndex, IndexModifier indexing)
Flip the tree by exchanging the twig indices of all items with one of the path elements.
elementIndex (int)Path element to flip.
indexing (IndexModifier)Indexing to apply to the indices.
Flipped tree.
Flip

GetCoverage

#
public object GetCoverage(Coverage coverage)
Gets the part of a tree that is implied by a specific coverage.
coverage (Coverage)Coverage.
Part of the tree identified by the coverage, or null if the coverage doesn't intersect with the tree.
GetCoverage

Graft

#
public ITree Graft()
Perform a graft operation on the entire tree.
Modified tree.
Graft

IsCoincidentWith

#
public bool IsCoincidentWith(Coverage coverage)
Test whether a given coverage coincides with this tree.
coverage (Coverage)Coverage to test.
True if the coverage is valid.
IsCoincidentWith

IsCoincidentWith

#
public bool IsCoincidentWith(Site site)
Tests whether a given site (path+twig index) is part of this tree.
site (Site)Tree site.
True if the site exists within the tree.
IsCoincidentWith

NullAt

#
public bool NullAt(int twigIndex, int itemIndex)
Gets whether a specific item is null or not.
twigIndex (int)Index of twig.
itemIndex (int)Index of item.
True if item at the given site is null.
NullAt

NullAt

#
public bool NullAt(Path path, int itemIndex)
Gets whether a specific item is null or not.
path (Path)Path of item twig.
itemIndex (int)Index within twig.
True if item at the given site is null.
NullAt

PathExists

#
public bool PathExists(Path path)
path (Path)

PathIndex

#
public int PathIndex(Path path)
path (Path)

ReplacePath

#
public ITree ReplacePath(Path find, Path replace)
Replace one path with another. If the replace path already exists within the tree, the items will be appended to the existing twig.
find (Path)Path to find.
replace (Path)Path to replace.
Modified tree.
ReplacePath

Similarity

#
public TreeSimilarity Similarity(ITree tree)
Compares two data trees for similarity.
tree (ITree)Data tree to compare to.
A TreeSimilarity type. This method never returns the PathsAndListsAndItems value.
Similarity

Split

#
public void Split(IEnumerable<SiteRule> rules, out ITree positive, out ITree negative)
rules (IEnumerable<SiteRule>)
positive (out ITree)
negative (out ITree)
Split

Split

#
public void Split(SiteRule rule, out ITree positive, out ITree negative)
Split this tree into a positive and a negative state by applying a specific rule.
rule (SiteRule)Rule to apply.
positive (out ITree)Tree containing all the twigs and items that are valid under the given rule.
negative (out ITree)Tree containing all the twigs and items that are invalid under the given rule.
Split

ToString

#
public override string ToString()
Returns a string that represents the current object.
A string that represents the current object.
Object.ToString

ToString

#
public string ToString(TwigFormatStyle style)
Format this tree using a specific formatting template.
style (TwigFormatStyle)Formatting style.
String describing the tree.
ToString

TryConvert<TQ>

#
public Tree<TQ> TryConvert<TQ>()
Try and convert this tree into a tree of a specific type.
Tree of type TQ or null if no conversion could be found.
TryConvert

TryConvert<TQ>

#
public Tree<TQ> TryConvert<TQ>(CancellationToken token, ConversionRecord record)
Try and convert this tree into a tree of a specific type.
token (CancellationToken)Cancellation token.
record (ConversionRecord)If not null, conversion messages will be added to this record.
Tree of type TQ or null if no conversion could be found.
TryConvert

TryConvert<TQ>

#
public Tree<TQ> TryConvert<TQ>(CancellationToken token)
Try and convert this tree into a tree of a specific type.
token (CancellationToken)Cancellation token.
Tree of type TQ or null if no conversion could be found.
TryConvert

WithIncrementalPaths

#
public ITree WithIncrementalPaths()
Simplify the numbering of paths by starting at zero and incrementing by one for each element in the sequence.

WithMetaData

#
public ITree WithMetaData(ITree source, MergeBehaviour mergeBehaviour)
Merge all data from another tree.
source (ITree)Source of meta data. Source.Count must equal the local ImageCount and any twig in source which contains meta data must have the same length as the corresponding twig in this tree.
mergeBehaviour (MergeBehaviour)Custom data merge behaviour.
WithMetaData

WithMetaData

#
public ITree WithMetaData(MetaData primary, MetaData secondary)
Assign meta data to all items in this tree.
primary (MetaData)Primary data (assign no matter what). May be null.
secondary (MetaData)Secondary data (assign only if doesn't conflict). May be null.
Potentially modified tree.
WithMetaData

WithoutEmptyTwigs

#
public ITree WithoutEmptyTwigs()
Remove all twigs that contain no items from this tree.
Modified tree.
WithoutEmptyTwigs

WithoutMetaData

#
public ITree WithoutMetaData()
Clear all meta data from all twigs, but leave items intact.
WithoutMetaData

WithoutNullItems

#
public ITree WithoutNullItems()
Remove all null items from all twigs.
Modified tree.
WithoutNullItems

WithoutPaths

#
public ITree WithoutPaths(IEnumerable<Path> paths)
Remove all specified paths and corresponding twigs.
paths (IEnumerable<Path>)Paths to remove.
Modified tree.
WithoutPaths

WithoutPaths

#
public ITree WithoutPaths(params Path[] paths)
Remove the specified paths and corresponding twigs from this tree.
paths (params Path[])Paths to remove.
Modified tree.
WithoutPaths

WithoutSites

#
public ITree WithoutSites(IEnumerable<Site> sites)
Remove all specified sites from the tree.
sites (IEnumerable<Site>)Sites to remove.
Modified tree
WithoutSites

WithoutSites

#
public ITree WithoutSites(params Site[] sites)
Remove the specified sites from this tree.
sites (params Site[])Loci to remove.
Modified tree.
WithoutSites

WithPathPrefix

#
public ITree WithPathPrefix(int element)
Prepend an integer to all paths in the tree.
element (int)Element to prepend.
Modified tree.
WithPathPrefix

WithPathPrefix

#
public ITree WithPathPrefix(Path path)
Prepend an entire path to all existing paths in the tree.
path (Path)Path to prepend.
Modified tree.
WithPathPrefix

WithPaths

#
public ITree WithPaths(Paths paths)
Create a new tree with different paths but the same twigs.
paths (Paths)
Modified tree.
WithPaths

WithPathSuffix

#
public ITree WithPathSuffix(int element)
Append an integer to all paths in the tree.
element (int)Element to append.
Modified tree.
WithPathSuffix

WithPathSuffix

#
public ITree WithPathSuffix(Path path)
Append an entire path to all existing paths in the tree.
path (Path)Path to append.
Modified tree.
WithPathSuffix

WithRandomisedTwigs

#
public ITree WithRandomisedTwigs()
Randomise the items within the twigs of this tree.

WithRandomisedTwigs

#
public ITree WithRandomisedTwigs(Random random)
Randomise the items within the twigs of this tree.
random (Random)

WithRenumberedPaths

#
public ITree WithRenumberedPaths()
Renumber all paths in this tree in ascending order.
Modified tree.

WithRenumberedPaths

#
public ITree WithRenumberedPaths(int start)
Renumber all paths in this tree in ascending order.
start (int)Starting number for first path.
Modified tree.

WithRenumberedPaths

#
public ITree WithRenumberedPaths(Path path, int index)
Renumber all paths in this tree in ascending order.
path (Path)Path layout to use for renumbering.
index (int)Element integer of path to increment.
Modified tree.

WithReversedTwigs

#
public ITree WithReversedTwigs()
Reverse the order of all the items in the twigs of this tree.
Reversed tree.
WithReversedTwigs

WithSimplifiedPaths

#
public ITree WithSimplifiedPaths(PathAlignment options)
Perform a simplify operation on this tree.
options (PathAlignment)Simplify options
Modified tree.

WithSite

#
public ITree WithSite(Site site, IPear pear)
site (Site)
pear (IPear)
WithSite

WithSortedTwigs

#
public ITree WithSortedTwigs()
Sort all twigs using the default comparer.
Tree with sorted twigs.
WithSortedTwigs

WithTopology

#
public ITree WithTopology(ITree source)
Copy the topology of another tree while keeping the data from this tree. For a successful topology copy, the source and the target trees must have the same number of items.
source (ITree)Source tree to copy topology from.
modified tree.
WithTopology

WithTrimmedPaths

#
public ITree WithTrimmedPaths()
Trim the tree by removing the last element in each path and merging twigs together.
Modified tree.
WithTrimmedPaths

WithTrimmedPaths

#
public ITree WithTrimmedPaths(int count)
Trim the tree by removing the last N elements in each path and merging twigs together.
count (int)Number of elements to collapse.
Modified tree.
WithTrimmedPaths