ITwig
References- Twig<T>
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
#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
#NullCount
#Gets the number of items in this twig that are nulls. Note: even when a twig contains ValueTypes, it may still have nulls.
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 Constraint.
Indexers
Methods
Apply
#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.
Parameters:
| expression (Expression) | Expression to apply. |
| resolver (Resolver) | Variable resolver to use. |
| report (out IExpressionReport) | Report on all expression evaluation issues. |
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.
Returns: Twig<T> of type TQ.
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
#Format the items and/or data in this twig.
Parameters:
| style (TwigFormatStyle) | Formatting style. |
| builder (StringBuilder) | String builder to append to. |
Format
#Format the items and/or data in this twig.
Parameters:
| formatting (TwigFormatting) | Formatting settings. |
| builder (StringBuilder) | String builder to append to. |
ItemAt
#Gets the item at the given index.
Parameters:
| index (int) | Index of item to retrieve. |
Returns: Item at given index.
Map
#Reorder the items in this twig based on an index map.
Parameters:
| 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). |
Returns: Modified twig.
MergeMetaData
#Merge all meta data from another twig.
Parameters:
| source (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.
Parameters:
| index (int) | Index of meta data to retrieve. |
Returns: Metadata at given index.
NullAt
#Gets whether the item at the given index is considered to be a null value.
Parameters:
| index (int) | Index to inspect. |
Returns: True if item at index is null.
RemoveAll
#Remove all items that pass a filter delegate.
Parameters:
| filter (Predicate<IPear>) | Filter delegate. |
| method (RemovalMethod) | Removal comparison method. |
| token (CancellationToken) | Cancelling token for aborting this operation. |
Returns: Modified twig.
RemoveAll
#Remove all items that pass a filter delegate.
Parameters:
| filter (Predicate<object>) | Filter delegate. |
| method (RemovalMethod) | Removal comparison method. |
| token (CancellationToken) | Cancelling token for aborting this operation. |
Returns: Modified twig.
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 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. 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.
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.
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.
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.
ToPearArray
#Create an array of item/data pears.
Parameters:
| method (ToArrayMethod) |
Returns: Pear array.
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.
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.
TypeAt
#Gets the type of the item at the given index.
Parameters:
| index (int) | Item index to retrieve type for. |
Returns: Type.
TypeName
#Gets the user friendly type name of the twig type constraint.
Returns: User friendly type name.
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.