public interface ITwig
Non-generic interface for tree twigs. ITwig is similar to IList but it allows for meta data to be stored in parallel with regular data.

Properties

CommonMetaData

#
MetaData CommonMetaData { get; }
Gets the common meta data in this twig. This means the meta data shared amongst all non-null items. Any conflicting meta data (i.e. identical name, different values) will be omitted from this result.

Constraint

#
Type Constraint { get; }
Gets the type constraint for this twig. Since each ITwig instance is some form of Twig<T>, this property tells you what T is.

Flavour

#
TypeFlavour Flavour { get; }
Gets the type flavour of the T constraint.

ItemCount

#
int ItemCount { get; }
Gets the number of items in this twig that aren't considered null.

Items

#
IEnumerable<object> Items { get; }
Get an enumerator for all items in this twig.

LeafCount

#
int LeafCount { get; }
Gets the number of items in this twig, including nulls.

MetaCount

#
int MetaCount { get; }
Gets the number of defined meta data palettes in this twig.

NonNullItems

#
IEnumerable<object> NonNullItems { get; }
Get an enumerator for all non-null items in this twig.

NonNullPears

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

NullCount

#
int NullCount { get; }
Gets the number of items in this twig that are nulls. Note: even when a twig contains ValueTypes, it may still have nulls.

Pears

#
IEnumerable<IPear> Pears { get; }
Enumerate over all item/meta data pears.

TightConstraint

#
Type TightConstraint { get; }
Gets the type which is common to all values stored in this twig. This is potentially quite an expensive property to call and its value is not cached internally. If the twig contains no values at all, the return value is somewhat undefined but will either be object or Constraint.

Indexers

this[]

#
IPear this[int index] { get; }
Gets the item/data pear at the given index.
Pear to set. Must be of the same generic type as the underlying tree.
index (int)Index of pear.
Object at index.

Methods

Apply

#
ITwig Apply(Expression expression, Resolver resolver, out IExpressionReport report)
Apply an expression to all elements in this twig. For an expression to be successful it needs to not throw exceptions and have a return type that is compatible with the underlying type of this twig.
expression (Expression)Expression to apply.
resolver (Resolver)Variable resolver to use.
report (out IExpressionReport)Report on all expression evaluation issues.

Cast

#
ITwig Cast(Type type)
Cast this twig to a Twig<T> type. This will only work if all non-null items are of the given type.
type (Type)Type.
Twig<T> of the specified type.

Cast<TQ>

#
Twig<TQ> Cast<TQ>()
Cast this twig to a Twig<T> type. This will only work if all non-null items are of type TQ.
Twig<T> of type TQ.

ClearMetaData

#
ITwig ClearMetaData()
Create a new twig with the same items but with no meta data.

Expand

#
ITwig Expand(int targetCount, ExpandMethod method)
Expand this twig until the count is equal to the target count. This functionality is the basis for LongestList matching.
targetCount (int)Count to expand to.
method (ExpandMethod)Item insertion method.
True if twig was modified in any way.

Format

#
void Format(TwigFormatStyle style, StringBuilder builder)
Format the items and/or data in this twig.
style (TwigFormatStyle)Formatting style.
builder (StringBuilder)String builder to append to.

Format

#
void Format(TwigFormatting formatting, StringBuilder builder)
Format the items and/or data in this twig.
formatting (TwigFormatting)Formatting settings.
builder (StringBuilder)String builder to append to.

ItemAt

#
object ItemAt(int index)
Gets the item at the given index.
index (int)Index of item to retrieve.
Item at given index.

Map

#
ITwig Map(IndexMap map)
Reorder the items in this twig based on an index map.
map (Maths.IndexMap)Item index map. The length of the map must be equal to LeafCount and each index in the map must be in the range [0, LeafCount).
Modified twig.

MergeMetaData

#
ITwig MergeMetaData(ITwig source, MergeBehaviour mergeBehaviour)
Merge all meta data from another twig.
source (ITwig)Twig with meta data to merge. Must have the same length as this twig.
mergeBehaviour (MergeBehaviour)Merge behaviour for conflicts.
Twig with merged data.

MergeMetaData

#
ITwig MergeMetaData(MetaData metaData, MergeBehaviour mergeBehaviour)
Merge meta data into every item in this twig.
metaData (MetaData)Meta data to merge into every item in this twig.
mergeBehaviour (MergeBehaviour)Merge behaviour for conflicts.
Twig with merged data.

MetaAt

#
MetaData MetaAt(int index)
Gets the meta data at the given index.
index (int)Index of meta data to retrieve.
Metadata at given index.

NullAt

#
bool NullAt(int index)
Gets whether the item at the given index is considered to be a null value.
index (int)Index to inspect.
True if item at index is null.

RemoveAll

#
ITwig RemoveAll(Predicate<IPear> filter, RemovalMethod method, CancellationToken token)
Remove all items that pass a filter delegate.
filter (Predicate<IPear>)Filter delegate.
method (RemovalMethod)Removal comparison method.
token (CancellationToken)Cancelling token for aborting this operation.
Modified twig.

RemoveAll

#
ITwig RemoveAll(Predicate<object> filter, RemovalMethod method, CancellationToken token)
Remove all items that pass a filter delegate.
filter (Predicate<object>)Filter delegate.
method (RemovalMethod)Removal comparison method.
token (CancellationToken)Cancelling token for aborting this operation.
Modified twig.

RemoveAt

#
ITwig RemoveAt(int index)
Remove the item at the given index.
index (int)Index of item to remove.
Modified twig.

RemoveIndices

#
ITwig RemoveIndices(IEnumerable<int> indices)
Remove all indices from this twig.
indices (IEnumerable<int>)Collection of indices to remove.
Modified twig.

RemoveMetaData

#
ITwig RemoveMetaData(params MetaName[] names)
Remove all meta values with the given names from this twig.
names (params MetaName[])Names to remove.
Modified twig or the same twig if the name did not occur.

RemoveNulls

#
ITwig RemoveNulls()
Remove all null items from this twig.
Number of items removed.
Modified twig.

RemovePattern

#
ITwig RemovePattern(IEnumerable<bool> pattern, RemovalMethod method)
Remove all items that are represented by a boolean pattern.
pattern (IEnumerable<bool>)Pattern. If the pattern is shorter than the twig, it will be repeated.
method (RemovalMethod)Removal comparison method.
Number of items removed.
Modified twig.

RemoveRange

#
ITwig RemoveRange(int index, int length)
Remove a range of items.
index (int)Index of first item to remove.
length (int)Number of consecutive items to remove.
Modified twig.

Reverse

#
ITwig Reverse()
Reverse the order of all items in this twig.
Modified twig.

Shrink

#
ITwig Shrink(int targetCount, ShrinkMethod method)
Shrink this twig until the count is equal to the target count. This functionality is the basis for ShortestList matching.
targetCount (int)Count to shrink to.
method (ShrinkMethod)Item removal method.
True if twig was modified in any way.

Sort

#
ITwig Sort(double[] keys)
Sort all items using a key array of doubles.
keys (double[])Key array with length equal to the twig count.
Modified twig.

Sort

#
ITwig Sort(int[] keys)
Sort all items using a key array of integers.
keys (int[])Key array with length equal to the twig count.
Modified twig.

Sort

#
ITwig Sort(out IndexMap map)
Sort all items using the default comparer. This method will attempt to use the Comparison method of the relevant type assistant, and otherwise use the numeric keys provided by the type assistant.
map (out Maths.IndexMap)
Modified twig.

Sort

#
ITwig Sort(string[] keys)
Sort all items using a key array of strings.
keys (string[])Key array with length equal to the twig count.
Modified twig.

ToMetaArray

#
MetaData[] ToMetaArray(ToArrayMethod method)
Copy the meta data (if any) to an array.
method (ToArrayMethod)Array retrieval method.
Array of meta data or null depending on twig state and method.

ToNullArray

#
bool[] ToNullArray(ToArrayMethod method)
Copy the null data (if any) to an array. This method may return null if there is no null data.
method (ToArrayMethod)Array retrieval method.
Array of booleans or null depending on twig state and method.

ToPearArray

#
IPear[] ToPearArray(ToArrayMethod method)
Create an array of item/data pears.
method (ToArrayMethod)
Pear array.

TryConvert<TQ>

#
Twig<TQ> TryConvert<TQ>(CancellationToken token, ConversionRecord record)
Try and convert this twig into another using the set of centrally registered conversion delegates.
token (CancellationToken)Cancellation token.
record (ConversionRecord)If not null, conversion messages will be added to this record.
Converted twig or null.

TryConvert<TQ>

#
Twig<TQ> TryConvert<TQ>(CancellationToken token)
Try and convert this twig into another using the set of centrally registered conversion delegates.
token (CancellationToken)Cancellation token.
Converted twig or null.

TypeAt

#
Type TypeAt(int index)
Gets the type of the item at the given index.
index (int)Item index to retrieve type for.
Type.

TypeName

#
string TypeName()
Gets the user friendly type name of the twig type constraint.
User friendly type name.

TypeName

#
string TypeName(GrammarNumber number, GrammarArticle article, GrammarCasing casing)
Gets the user friendly type name of the twig type constraint.
number (Prose.GrammarNumber)Grammar number to use.
article (Prose.GrammarArticle)Article to prefix.
casing (Prose.GrammarCasing)Casing.
User friendly type name.