Type parameters:
| T | Type of data in twig. |
Properties
CommonMetaData
#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.
Implements: CommonMetaData
Constraint
#Gets the type constraint for this twig. Since each ITwig instance is some form of Twig<T>, this property tells you what T is.
Implements: Constraint
NullCount
#Gets the number of items in this twig that are nulls. Note: even when a twig contains ValueTypes, it may still have nulls.
Implements: NullCount
TightConstraint
#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 ITwig.Constraint.
Implements: TightConstraint
Indexers
Methods
Add
#Add an item with meta data to this twig.
Parameters:
| item (T) | Item to add. |
| data (MetaData) | Associated meta data |
AddRange
#Add a collection of item/data pears to this twig. This is the fastest AddRange method, especially if the pears argument is in fact an array of pears.
Parameters:
| pears (IEnumerable<Pear<T>>) | Pears to add. |
AddRange
#Add a collection of items and data to this twig.
Parameters:
| items (IEnumerable<T>) | Items to add. |
| metaData (IEnumerable<MetaData>) | Data to add. |
Apply
#Apply an expression to all non-null 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.
Parameters:
| expression (Expression) | Expression to apply. |
| resolver (Resolver) | Variable resolver to use. |
| report (out IExpressionReport) | Report on all expression evaluation issues. |
Apply
#Create a new twig by applying a delegate to all values.
Parameters:
| method (Func<T, T>) | Modifier delegate. |
| nullMethod (Func<T>) | Modifier for null values. If not specified, null items will be copied verbatim. |
| token (CancellationToken) | Cancellation token. |
Returns: Twig with modified values.
Cast
#Cast this twig to a Twig<T> type. This will only work if all non-null items are of the given type.
Cast<TQ>
#Cast this twig to a Twig<T> type. This will only work if all non-null items are of type TQ.
Convert<TQ>
#public Twig<TQ> Convert<TQ>(ConversionDelegate<T, TQ> converter, CancellationToken token, ConversionRecord record)
Convert this twig into another twig of a different type.
Parameters:
| converter (ConversionDelegate<T, TQ>) | Converter. |
| token (CancellationToken) | Cancellation token. |
| record (ConversionRecord) | If not null, conversion messages will be added to this record. |
Returns: Twig with converted data.
Convert<TQ>
#Convert this twig into another twig of a different type.
Parameters:
| converter (ConversionDelegate<T, TQ>) | Converter. |
| token (CancellationToken) | Cancellation token. |
Returns: Twig with converted data.
Convert<TQ>
#Convert this twig by applying a function to all non-null items.
Parameters:
| conversion (Func<T, TQ>) | Conversion function. |
| token (CancellationToken) | Cancellation token. |
Returns: Tree with new items but the same metadata.
CountItems
#Count how many items pass a predicate method. Null items are not tested and do not contribute towards the test.
Parameters:
| predicate (Predicate<T>) | Predicate delegate. |
Returns: Number of non-null items that pass the predicate.
CountPears
#Count how many item/data pears pass a predicate method. Null items will be included as pears.NullAt = true;
Expand
#Expand this twig until the count is equal to the target count. This functionality is the basis for LongestList matching.
Parameters:
| targetCount (int) | Count to expand to. |
| method (ExpandMethod) | Item insertion method. |
Returns: True if twig was modified in any way.
Format
#public void Format(TwigFormatStyle style, Func<Pear<T>, string> formatDelegate, StringBuilder builder)
Format this twig.
Parameters:
| style (TwigFormatStyle) | Formatting style. |
| formatDelegate (Func<Pear<T>, string>) | Delegate to use for formatting specific items. |
| builder (StringBuilder) | String builder to append to. |
Returns: A formatted string representing this twig.
Format
#Format this twig.
Parameters:
| style (TwigFormatStyle) | Formatting style. |
| formatDelegate (Func<T, string>) | Delegate to use for formatting specific items. |
| builder (StringBuilder) | String builder to append to. |
Returns: A formatted string representing this twig.
Format
#Format this twig.
Parameters:
| style (TwigFormatStyle) | Formatting style. |
| builder (StringBuilder) | String builder to append to. |
Returns: A formatted string representing this twig.
Format
#public void Format(TwigFormatting formatting, Func<Pear<T>, string> formatDelegate, StringBuilder builder)
Format the items and/or data in this twig.
Parameters:
| formatting (TwigFormatting) | Formatting settings. |
| formatDelegate (Func<Pear<T>, string>) | Delegate to use for formatting specific items. |
| builder (StringBuilder) | String builder to append to. |
Returns: A formatted string representing this twig.
Format
#public void Format(TwigFormatting formatting, Func<T, string> formatDelegate, StringBuilder builder)
Format the items and/or data in this twig.
Parameters:
| formatting (TwigFormatting) | Formatting settings. |
| formatDelegate (Func<T, string>) | Delegate to use for formatting specific items. |
| builder (StringBuilder) | String builder to append to. |
Returns: A formatted string representing this twig.
Parameters:
| expression (Expression) | |
| resolver (Resolver) | |
| report (out IExpressionReport) |
Implements: Apply
Parameters:
| targetCount (int) | |
| method (ExpandMethod) |
Implements: Expand
Parameters:
| style (TwigFormatStyle) | |
| builder (StringBuilder) |
Implements: Format
Parameters:
| formatting (TwigFormatting) | |
| builder (StringBuilder) |
Implements: Format
Parameters:
| sourceTwig (ITwig) | |
| mergeBehaviour (MergeBehaviour) |
Implements: MergeMetaData
Parameters:
| metaData (MetaData) | |
| mergeBehaviour (MergeBehaviour) |
Implements: MergeMetaData
Parameters:
| filter (Predicate<IPear>) | |
| method (RemovalMethod) | |
| token (CancellationToken) |
Implements: RemoveAll
Parameters:
| filter (Predicate<object>) | |
| method (RemovalMethod) | |
| token (CancellationToken) |
Implements: RemoveAll
Parameters:
| indices (IEnumerable<int>) |
Implements: RemoveIndices
Parameters:
| names (params MetaName[]) |
Implements: RemoveMetaData
Parameters:
| pattern (IEnumerable<bool>) | |
| method (RemovalMethod) |
Implements: RemovePattern
Implements: RemoveRange
Parameters:
| targetCount (int) | |
| method (ShrinkMethod) |
Implements: Shrink
Parameters:
| map (out Maths.IndexMap) |
Implements: Sort
Parameters:
| method (ToArrayMethod) |
Implements: ToPearArray
Insert
#Insert an item/data pear into this twig.
Insert
#Insert an item with data into this twig.
InsertRange
#Insert a collection of item/data pears into this twig.
Parameters:
| index (int) | Index to insert at. |
| pears (IEnumerable<Pear<T>>) | Pears to insert. |
InsertRange
#Insert a collection of items and data into this twig.
Parameters:
| index (int) | Index to insert at. |
| items (IEnumerable<T>) | Items to insert. |
| metaData (IEnumerable<MetaData>) | Data to insert. |
InsertRange
#Insert a collection of items into this twig.
Parameters:
| index (int) | Index to insert at. |
| items (IEnumerable<T>) | Items to insert. |
InsertRange
#Insert a twig into this one.
MergeMetaData
#Merge all meta data from another twig.
Parameters:
| sourceTwig (ITwig) | Twig with meta data to merge. Must have the same length as this twig. |
| mergeBehaviour (MergeBehaviour) | Merge behaviour for conflicts. |
Returns: Twig with merged data.
MergeMetaData
#Merge meta data into every item in this twig.
Parameters:
| metaData (MetaData) | Meta data to merge into every item in this twig. |
| mergeBehaviour (MergeBehaviour) | Merge behaviour for conflicts. |
Returns: Twig with merged data.
MetaAt
#Gets the meta data at the given index.
NullAt
#Gets whether the item at the given index is considered to be a null value.
RemoveAll
#public Twig<T> RemoveAll(Predicate<Pear<T>> predicate, RemovalMethod method, CancellationToken token)
Remove all item/data pears that pass a predicate method.
Parameters:
| predicate (Predicate<Pear<T>>) | Predicate delegate. |
| method (RemovalMethod) | Removal comparison method. |
| token (CancellationToken) | Cancellation token. |
Returns: Number of items removed.
RemoveAll
#Remove all items that pass a predicate method.
Parameters:
| predicate (Predicate<T>) | Predicate delegate. |
| method (RemovalMethod) | Removal comparison method. |
| token (CancellationToken) | Cancellation token. |
Returns: Number of items removed.
RemoveAt
#Remove the item at the given index.
Parameters:
| index (int) | Index of item to remove. |
Returns: Modified twig.
RemoveIndices
#Remove all indices from this twig.
Parameters:
| indices (IEnumerable<int>) | Collection of indices to remove. |
Returns: Modified twig.
RemoveMetaData
#Remove all meta values with the given names from this twig.
Parameters:
| names (params MetaName[]) | Names to remove. |
Returns: Modified twig or the same twig if the name did not occur.
RemovePattern
#Remove all items that are represented by a boolean pattern.
Parameters:
| pattern (IEnumerable<bool>) | Pattern. If the pattern is shorter than the twig, it will be repeated. |
| method (RemovalMethod) | Removal comparison method. |
Returns: Number of items removed.
Modified twig.
Modified twig.
RemoveRange
#Remove a range of items.
Shrink
#Shrink this twig until the count is equal to the target count. This functionality is the basis for ShortestList matching.
Parameters:
| targetCount (int) | Count to shrink to. |
| method (ShrinkMethod) | Item removal method. |
Returns: True if twig was modified in any way.
Sort
#Sort all items using a key array of doubles.
Parameters:
| keys (double[]) | Key array with length equal to the twig count. |
Returns: Modified twig.
Sort
#Sort all items using a custom comparer.
Parameters:
| comparer (IComparer<Pear<T>>) | |
| map (out Maths.IndexMap) |
Returns: Sorted twig.
Sort
#Sort all items using a custom comparer.
Parameters:
| comparer (IComparer<T>) | |
| map (out Maths.IndexMap) |
Returns: Sorted twig.
Sort
#Sort all items using a key array of integers.
Parameters:
| keys (int[]) | Key array with length equal to the twig count. |
Returns: Modified twig.
Sort
#Sort all items using the default comparer.
Parameters:
| map (out Maths.IndexMap) |
Returns: Modified twig.
Sort
#Sort all items using a key array of strings.
Parameters:
| keys (string[]) | Key array with length equal to the twig count. |
Returns: Modified twig.
ToItemArrayInternal
#protected abstract T[] ToItemArrayInternal()
Return a direct reference to the internal item array if it exists.
ToMetaArray
#Copy the meta data (if any) to an array.
Parameters:
| method (ToArrayMethod) | Array retrieval method. |
Returns: Array of meta data or null depending on twig state and method.
Implements: ToMetaArray
ToNullArray
#Copy the null data (if any) to an array. This method may return null if there is no null data.
Parameters:
| method (ToArrayMethod) | Array retrieval method. |
Returns: Array of booleans or null depending on twig state and method.
Implements: ToNullArray
ToPearArray
#Create an array of item/data pears.
Parameters:
| method (ToArrayMethod) |
Returns: Pear array.
TrueForItems
#Test whether a specific predicate is true for all items in this twig. Null items are not tested and do not contribute towards the test.
Parameters:
| predicate (Predicate<T>) | Predicate delegate. |
Returns: True if all non-null items in this twig pass the predicate.
TrueForPears
#Test whether a specific predicate is true for all item/data pears in this twig.
TryConvert<TQ>
#Try and convert this twig into another using the set of centrally registered conversion delegates.
Parameters:
| token (CancellationToken) | Cancellation token. |
| record (ConversionRecord) | If not null, conversion messages will be added to this record. |
Returns: Converted twig or null.
Implements: TryConvert
TryConvert<TQ>
#Try and convert this twig into another using the set of centrally registered conversion delegates.
Parameters:
| token (CancellationToken) | Cancellation token. |
Returns: Converted twig or null.
Implements: TryConvert
TypeAt
#Gets the type of the item at the given index.
TypeName
#Gets the user friendly type name of the twig type constraint.
Returns: User friendly type name.
Implements: TypeName
TypeName
#Gets the user friendly type name of the twig type constraint.
Parameters:
| number (Prose.GrammarNumber) | Grammar number to use. |
| article (Prose.GrammarArticle) | Article to prefix. |
| casing (Prose.GrammarCasing) | Casing. |
Returns: User friendly type name.
Implements: TypeName
ValidateIndex
#Throw an exception if the index + length range exceed the twig size.
ValidateIndex
#Throw an exception if the index exceeds the twig size.
Parameters:
| index (int) | Index to test. |
ValidateIndexPlusOne
#Throw an exception if the index + length range exceed the twig size plus one.