Tree<T>

References
[DebuggerDisplay("{DebuggerDisplay}")] public abstract class Tree<T> : ITree
Strongly typed version of the ITree interface.
TType constraint.

Properties

AllItems

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

AllPears

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

AllTwigs

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

CommonMetaData

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

DebuggerDisplay

#
public string DebuggerDisplay { get; }

Description

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

ITree.AllItems

#
AllItems
Explicit

ITree.AllPears

#
AllPears
Explicit

ITree.AllTwigs

#
AllTwigs
Explicit

ITree.Items

#
Items
Explicit

ITree.NonNullItems

#
IEnumerable<object> ITree.NonNullItems
NonNullItems
Explicit

ITree.NonNullPears

#
IEnumerable<IPear> ITree.NonNullPears
NonNullPears
Explicit

ITree.Pears

#
Pears
Explicit

ITree.Twigs

#
Twigs
Explicit

ITree.TypeAssistant

#
ITypeAssistant ITree.TypeAssistant
TypeAssistant

IsOrderable

#
protected bool IsOrderable { get; }
Gets whether this tree has orderable items. That is, whether it contains at least one twig with two or more items, not all of whom are nulls.

ItemCount

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

Items

#
public abstract IItemAccessor<T> Items { get; }
Access the items in this tree.

LeafCount

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

MetaCount

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

NonNullItems

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

NonNullPears

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

NullCount

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

PathCount

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

Paths

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

Pears

#
public abstract IPearAccessor<T> Pears { get; }
Access the pears in this tree.

Twigs

#
public abstract ITwigAccessor<T> Twigs { get; }
Access the twigs in this tree.

Type

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

TypeAssistant

#
public ITypeAssistant<T> TypeAssistant { get; }
Gets the type assistant (if any) associated with the tree type constraint.

TypeFlavour

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

Methods

Add

#
public Tree<T> Add(Path path, IEnumerable<Pear<T>> pears)
Add a collection of values to this tree.
path (Path)
pears (IEnumerable<Pear<T>>)

Add

#
public Tree<T> Add(Path path, IEnumerable<T> values)
Add a collection of values to this tree.
path (Path)
values (IEnumerable<T>)

Add

#
public Tree<T> Add(Path path, params Pear<T>[] pears)
Add a new value to this tree.
path (Path)
pears (params Pear<T>[])

Add

#
public Tree<T> Add(Path path, params T[] values)
Add values to this tree.
path (Path)
values (params T[])

Add

#
public Tree<T> Add(Path path, Twig<T> twig)
Add all the values in a twig to this tree.
path (Path)
twig (Twig<T>)

AddNull

#
public Tree<T> AddNull(Path path, int count = 1)
Add null values to this tree.
path (Path)
count (int = 1)

Convert<TQ>

#
public virtual Tree<TQ> Convert<TQ>(ConversionDelegate<T, TQ> converter, CancellationToken token, ConversionRecord record)
Convert this tree into one of a different type.
converter (ConversionDelegate<T, TQ>)
token (CancellationToken)
record (ConversionRecord)

Convert<TQ>

#
public Tree<TQ> Convert<TQ>(ConversionDelegate<T, TQ> converter, CancellationToken token)
Convert this tree into one of a different type.
converter (ConversionDelegate<T, TQ>)
token (CancellationToken)

Convert<TQ>

#
public Tree<TQ> Convert<TQ>(Func<T, TQ> converter, CancellationToken token)
Convert a tree by applying a functional mapping to all non-null items.
converter (Func<T, TQ>)Conversion method.
token (CancellationToken)Cancellation token.
Tree with converted values, but with the same topology and metadata.

ConvertItems<Q>

#
public virtual Tree<Q> ConvertItems<Q>(Func<T, Q> replaceItem, Pear<Q> nullReplacement = null, CancellationToken token = default(CancellationToken))
Modify all items in this tree.
replaceItem (Func<T, 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.

ConvertPears

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

ConvertPears<Q>

#
public virtual Tree<Q> ConvertPears<Q>(Func<Pear<T>, Pear<Q>> replacePear, Pear<Q> nullReplacement = null, CancellationToken token = default(CancellationToken))
Modify all pears in this tree.
replacePear (Func<Pear<T>, 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.

Filter

#
public virtual Tree<T> Filter(IEnumerable<SiteRule> rules)
Apply one or more 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 rule.

Filter

#
public Tree<T> 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.

Flatten

#
public Tree<T> Flatten()
Flatten the entire tree.
Modified tree.

Flatten

#
public virtual Tree<T> Flatten(Path path)
Flatten the entire tree.
path (Path)
Modified tree.

Flip

#
public Tree<T> 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.

GetCoverage

#
public object GetCoverage(Coverage coverage)
Gets the portion of the tree implied by the coverage.
coverage (Coverage)
GetCoverage

Graft

#
public virtual Tree<T> Graft()
Perform a graft operation on the entire tree.
Modified tree.
Explicit

ITree.ConvertItems<Q>

#
Tree<Q> ITree.ConvertItems<Q>(Func<object, Q> replaceItem, Pear<Q> nullReplacement, CancellationToken token)
replaceItem (Func<object, Q>)
nullReplacement (Pear<Q>)
token (CancellationToken)
ConvertItems
Explicit

ITree.ConvertPears

#
ITree ITree.ConvertPears(Func<IPear, IPear> replacePear, IPear nullReplacement, CancellationToken token)
replacePear (Func<IPear, IPear>)
nullReplacement (IPear)
token (CancellationToken)
ConvertPears
Explicit

ITree.ConvertPears<Q>

#
Tree<Q> ITree.ConvertPears<Q>(Func<IPear, Pear<Q>> replacePear, Pear<Q> nullReplacement, CancellationToken token)
replacePear (Func<IPear, Pear<Q>>)
nullReplacement (Pear<Q>)
token (CancellationToken)
ConvertPears
Explicit

ITree.Filter

#
rules (IEnumerable<SiteRule>)
Filter
Explicit

ITree.Filter

#
ITree ITree.Filter(params SiteRule[] rules)
rules (params SiteRule[])
Filter
Explicit

ITree.Flatten

#
ITree ITree.Flatten()
Flatten
Explicit

ITree.Flatten

#
ITree ITree.Flatten(Path path)
path (Path)
Flatten
Explicit

ITree.Flip

#
ITree ITree.Flip(int elementIndex, IndexModifier indexing)
elementIndex (int)
indexing (IndexModifier)
Flip
Explicit

ITree.Graft

#
ITree ITree.Graft()
Graft
Explicit

ITree.ReplacePath

#
ITree ITree.ReplacePath(Path find, Path replace)
find (Path)
replace (Path)
ReplacePath
Explicit

ITree.Split

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

ITree.Split

#
void ITree.Split(SiteRule rule, out ITree positive, out ITree negative)
rule (SiteRule)
positive (out ITree)
negative (out ITree)
Split
Explicit

ITree.WithIncrementalPaths

#
ITree ITree.WithIncrementalPaths()
Explicit

ITree.WithMetaData

#
ITree ITree.WithMetaData(ITree source, MergeBehaviour mergeBehaviour)
source (ITree)
mergeBehaviour (MergeBehaviour)
WithMetaData
Explicit

ITree.WithMetaData

#
ITree ITree.WithMetaData(MetaData primary, MetaData secondary)
primary (MetaData)
secondary (MetaData)
WithMetaData
Explicit

ITree.WithoutEmptyTwigs

#
ITree ITree.WithoutEmptyTwigs()
WithoutEmptyTwigs
Explicit

ITree.WithoutMetaData

#
ITree ITree.WithoutMetaData()
WithoutMetaData
Explicit

ITree.WithoutNullItems

#
ITree ITree.WithoutNullItems()
WithoutNullItems
Explicit

ITree.WithoutPaths

#
ITree ITree.WithoutPaths(IEnumerable<Path> paths)
paths (IEnumerable<Path>)
WithoutPaths
Explicit

ITree.WithoutPaths

#
ITree ITree.WithoutPaths(params Path[] paths)
paths (params Path[])
WithoutPaths
Explicit

ITree.WithoutSites

#
ITree ITree.WithoutSites(IEnumerable<Site> sites)
sites (IEnumerable<Site>)
WithoutSites
Explicit

ITree.WithoutSites

#
ITree ITree.WithoutSites(params Site[] sites)
sites (params Site[])
WithoutSites
Explicit

ITree.WithPathPrefix

#
ITree ITree.WithPathPrefix(int element)
element (int)
WithPathPrefix
Explicit

ITree.WithPathPrefix

#
ITree ITree.WithPathPrefix(Path path)
path (Path)
WithPathPrefix
Explicit

ITree.WithPaths

#
ITree ITree.WithPaths(Paths paths)
paths (Paths)
WithPaths
Explicit

ITree.WithPathSuffix

#
ITree ITree.WithPathSuffix(int element)
element (int)
WithPathSuffix
Explicit

ITree.WithPathSuffix

#
ITree ITree.WithPathSuffix(Path path)
path (Path)
WithPathSuffix
Explicit

ITree.WithRandomisedTwigs

#
ITree ITree.WithRandomisedTwigs()
Explicit

ITree.WithRandomisedTwigs

#
ITree ITree.WithRandomisedTwigs(Random random)
random (Random)
Explicit

ITree.WithRenumberedPaths

#
ITree ITree.WithRenumberedPaths()
Explicit

ITree.WithRenumberedPaths

#
ITree ITree.WithRenumberedPaths(int start)
start (int)
Explicit

ITree.WithRenumberedPaths

#
ITree ITree.WithRenumberedPaths(Path path, int index)
path (Path)
index (int)
Explicit

ITree.WithReversedTwigs

#
ITree ITree.WithReversedTwigs()
WithReversedTwigs
Explicit

ITree.WithSimplifiedPaths

#
ITree ITree.WithSimplifiedPaths(PathAlignment options)
options (PathAlignment)
Explicit

ITree.WithSite

#
ITree ITree.WithSite(Site site, IPear pear)
site (Site)
pear (IPear)
WithSite
Explicit

ITree.WithSortedTwigs

#
ITree ITree.WithSortedTwigs()
WithSortedTwigs
Explicit

ITree.WithTopology

#
ITree ITree.WithTopology(ITree source)
source (ITree)
WithTopology
Explicit

ITree.WithTrimmedPaths

#
ITree ITree.WithTrimmedPaths()
WithTrimmedPaths
Explicit

ITree.WithTrimmedPaths

#
ITree ITree.WithTrimmedPaths(int count)
count (int)
WithTrimmedPaths

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

ModifyItems

#
public virtual Tree<T> ModifyItems(Func<T, bool> remove = null, Func<T, bool> replace = null, Func<T, T> replaceItem = null, Func<T> replaceNull = null, CancellationToken token = default(CancellationToken))
Create a new tree by replacing all items in this tree by some other value.
remove (Func<T, bool> = null)Method which indicates an item ought to be removed from the tree.
replace (Func<T, bool> = null)Method for determining whether a replacement is required. If null, every item is traversed.
replaceItem (Func<T, T> = null)Method invoked for replacing non-null items.
replaceNull (Func<T> = null)Method invoked for null items. If not provided, null items will be retained.
token (CancellationToken = null)Optional cancellation token.
Modified tree.

ModifyPaths

#
public virtual Tree<T> ModifyPaths(Func<Path, bool> remove = null, Func<Path, Path> replace = null)
Apply a set of modifier delegates to the paths in this tree.
remove (Func<Path, bool> = null)Optional delegate for removing paths+twigs from this tree based on path value.
replace (Func<Path, Path> = null)Optional delegate for replacing paths with other paths. If this delegate returns a null the path will be removed.
Modified tree.

ModifyTwigs

#
public virtual Tree<T> ModifyTwigs(Func<Twig<T>, bool> remove = null, Func<Twig<T>, Twig<T>> replace = null)
Apply a set of modifier delegates to the twigs in this tree.
remove (Func<Twig<T>, bool> = null)Optional delegate for removing paths+twigs from this tree based on twig value.
replace (Func<Twig<T>, Twig<T>> = null)Optional delegate for replacing twigs with other twigs. If this delegate returns a null the twig will be removed.
Modified tree.

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

ReplacePath

#
public Tree<T> ReplacePath(Path find, Path replace)
Replace one path with another.
find (Path)Path to find.
replace (Path)Path to replace.
Modified tree.

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

Similarity

#
public TreeSimilarity Similarity(Tree<T> tree, Comparison<T> comparer)
Compares two data trees for similarity.
tree (Tree<T>)Data tree to compare to.
comparer (Comparison<T>)Item comparer.
A TreeSimilarity type.

Split

#
public virtual void Split(IEnumerable<SiteRule> rules, out Tree<T> positive, out Tree<T> negative)
rules (IEnumerable<SiteRule>)
positive (out Tree<T>)
negative (out Tree<T>)

Split

#
public void Split(SiteRule rule, out Tree<T> positive, out Tree<T> negative)
rule (SiteRule)
positive (out Tree<T>)
negative (out Tree<T>)

ToArrays

#
public abstract void ToArrays(out T[][] items, out MetaData[][] metas, out bool[][] nulls)
Create a nested array of all items and meta data in all twigs. If there is no meta data whatsoever, this array may be returned as null. If the type constraint is a nullable type, the nullData array will be null.
items (out T[][])
metas (out MetaData[][])
nulls (out bool[][])

ToArrays

#
public abstract void ToArrays(out T[][] items, out MetaData[][] metas)
Create a nested array of all items and meta data in all twigs. If there is no meta data whatsoever, this array may be returned as null.
items (out T[][])
metas (out MetaData[][])

ToArrays

#
public abstract void ToArrays(out T[][] items)
Create a nested array of all items in all twigs.
items (out T[][])

ToString

#
public sealed 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 virtual 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 Tree<T> WithIncrementalPaths()
Simplify the numbering of paths by starting at zero and incrementing by one for each element in the sequence.

WithMetaData

#
public Tree<T> WithMetaData(ITree source, MergeBehaviour mergeBehaviour)
Merge all data from another tree.
source (ITree)Source of meta data. The topology of the source must be identical to the topology of this tree for a meta data merge to work.
mergeBehaviour (MergeBehaviour)Custom data merge behaviour.

WithMetaData

#
public Tree<T> WithMetaData(MetaData primary, MetaData secondary)
primary (MetaData)
secondary (MetaData)

WithoutEmptyTwigs

#
public Tree<T> WithoutEmptyTwigs()
Remove all twigs that contain no items from this tree.
Modified tree.

WithoutMetaData

#
public Tree<T> WithoutMetaData()
Clear all meta data from all twigs, but leave items intact.

WithoutNullItems

#
public Tree<T> WithoutNullItems()
Remove all null items from all twigs.
Modified tree.

WithoutPaths

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

WithoutPaths

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

WithoutSites

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

WithoutSites

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

WithPathPrefix

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

WithPathPrefix

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

WithPaths

#
public Tree<T> WithPaths(Paths paths)
Copy the paths from another tree while keeping the data from this tree. For a successful path copy, the source and the target trees must have the same number of paths.
paths (Paths)Source tree to copy paths from.
Modified tree.

WithPathSuffix

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

WithPathSuffix

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

WithRandomisedTwigs

#
public Tree<T> WithRandomisedTwigs()
Randomise the items within the twigs of this tree.

WithRandomisedTwigs

#
public virtual Tree<T> WithRandomisedTwigs(Random random)
Randomise the items within the twigs of this tree.
random (Random)

WithRenumberedPaths

#
public Tree<T> WithRenumberedPaths()
Renumber all paths in this tree in ascending order.
Modified tree.

WithRenumberedPaths

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

WithRenumberedPaths

#
public Tree<T> 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 virtual Tree<T> WithReversedTwigs()
Reverse the order of all the items in the twigs of this tree.
Reversed tree.

WithSimplifiedPaths

#
public Tree<T> WithSimplifiedPaths(PathAlignment options)
Perform a simplify operation on this tree.
options (PathAlignment)Simplify options
Modified tree.

WithSite

#
public virtual Tree<T> WithSite(Site site, Pear<T> pear)
Replace a single pear in this tree.
site (Site)Site of pear.
pear (Pear<T>)New pear.
Tree with replaced pear.

WithSite

#
public virtual Tree<T> WithSite(Site site, T item)
Replace a single item in this tree.
site (Site)Site of item.
item (T)New item.
Tree with replaced item.

WithSortedTwigs

#
public Tree<T> WithSortedTwigs()
Sort all branches using the default comparer.
Tree with sorted branches.

WithSortedTwigs

#
public Tree<T> WithSortedTwigs(IComparer<T> comparer)
Sort all branches using the default comparer.
comparer (IComparer<T>)
Tree with sorted branches.

WithTopology

#
public Tree<T> 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.

WithTrimmedPaths

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

WithTrimmedPaths

#
public Tree<T> 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.