Struct Children<T>
An enumerable type representing the children of a node of type T
.
Inherited Members
Namespace: Sawmill
Assembly: Sawmill.dll
Syntax
public struct Children<T> : IEnumerable<T>, IEnumerable
Type Parameters
Name | Description |
---|---|
T | The type of the rewritable object. |
Remarks
Why not just use System.Collections.Generic.IEnumerable<T>? Children<T> is a value type, whereas System.Collections.Generic.IEnumerable<T> is a reference type. In cases where a node has a small, fixed number of children (fewer than three), it's much more efficient to pass those children around on the stack, rather than storing an enumerable on the heap which will quickly become garbage.
Properties
| Improve this Doc View SourceFirst
Gets the first element, if NumberOfChildren is One or Two.
Declaration
public T First { get; }
Property Value
Type | Description |
---|---|
T | The first element, if NumberOfChildren is One or Two. |
Exceptions
Type | Condition |
---|---|
InvalidOperationException | Thrown when NumberOfChildren is not One or Two |
Many
Gets an enumerable containing the elements, if NumberOfChildren is Many.
Declaration
public ImmutableList<T> Many { get; }
Property Value
Type | Description |
---|---|
System.Collections.Immutable.ImmutableList<T> | An enumerable containing the elements, if if NumberOfChildren is Many. |
Exceptions
Type | Condition |
---|---|
InvalidOperationException | Thrown when NumberOfChildren is not Many |
NumberOfChildren
The number of children the instance contains.
Declaration
public NumberOfChildren NumberOfChildren { get; }
Property Value
Type | Description |
---|---|
NumberOfChildren | The number of children the instance contains. |
Second
Gets the second element, if NumberOfChildren is Two.
Declaration
public T Second { get; }
Property Value
Type | Description |
---|---|
T | The second element, if NumberOfChildren is Two. |
Exceptions
Type | Condition |
---|---|
InvalidOperationException | Thrown when NumberOfChildren is not Two |
Methods
| Improve this Doc View SourceGetEnumerator()
Returns an implementation of System.Collections.Generic.IEnumerator<T> which yields the elements of the current instance.
Declaration
public Children<T>.Enumerator GetEnumerator()
Returns
Type | Description |
---|---|
Children.Enumerator<> | An implementation of System.Collections.Generic.IEnumerator<T> which yields the elements of the current instance. |
Select<U>(Func<T, U>)
Returns a new Children<T> containing the result of applying a transformation function to the elements of the current instance.
Declaration
public Children<U> Select<U>(Func<T, U> func)
Parameters
Type | Name | Description |
---|---|---|
System.Func<T, U> | func | A transformation function to apply to the elements of the current instance |
Returns
Type | Description |
---|---|
Children<U> | A new Children<T> containing the result of applying a transformation function to the elements of the current instance. |
Type Parameters
Name | Description |
---|---|
U |
Explicit Interface Implementations
| Improve this Doc View SourceIEnumerable<T>.GetEnumerator()
Declaration
IEnumerator<T> IEnumerable<T>.GetEnumerator()
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerator<T> |
IEnumerable.GetEnumerator()
Declaration
IEnumerator IEnumerable.GetEnumerator()
Returns
Type | Description |
---|---|
IEnumerator |