Sequence T  ClassA Sandcastle Documented Class Library
Represents an immutable lazy sequence of elements. Elements are only evaluated when they're needed, and Sequence T  employs memoization to store the computed values and avoid re-evaluation.
Inheritance Hierarchy
System Object
  Sequences Sequence T 

Namespace: Sequences
Assembly: Sequences (in Sequences.dll) Version: 1.0.1.0 (1.0.1)
Syntax
public class Sequence<T> : ISequence<T>, 
	IEnumerable<T>, IEnumerable 
Type Parameters
T
The type of elements in the sequence.

The Sequence T  type exposes the following members.

Constructors
  NameDescription
Public methodSequence T (T, Func ISequence T  )
Initializes a new instance of Sequence T .
Protected methodSequence T (T, Lazy ISequence T  )
Initializes a new instance of Sequence T .
Top
Methods
  NameDescription
Public methodAppend
Returns a copy of this sequence with the given element appended.
Public methodCombinations
Iterate over distinct combinations of a given size of this sequence's elements.
Public methodConcat
Returns a copy of this sequence concatenated with otherSequence.
Public methodContainsSlice
Tests whether this sequence contains a given sequence as a slice. If this sequence represents an infinite set or series and doesn't contain slice, this will never return!
Public methodCopyTo( T )
Copies the entire sequence to an array, starting at the beginning of the target array. Copying will stop once either the end of this sequence is reached, or the end of the array is reached.
Public methodCopyTo( T , Int32)
Copies the entire sequence to an array, starting at the position destinationIndex of the target array. Copying will stop once either the end of this sequence is reached, or the end of the array is reached.
Public methodCopyTo(Int32,  T , Int32, Int32)
Copies a given number of elements from this sequence to an array, starting at the position index of this sequence and at the position destinationIndex of the target array. Copying will stop once either the end of this sequence is reached, or the end of the array is reached, or count elements have been copied.
Public methodEquals
Determines whether the specified Object is equal to the current Object.
(Inherited from Object.)
Protected methodFinalize
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object.)
Public methodFold
Folds the elements of this sequence using the specified accumulator function. If this sequence represents an infinite set or series, this will never return!
Public methodFoldRight
Folds the elements of this sequence using the specified accumulator function, going right to left. If this sequence represents an infinite set or series, this will never return!
Public methodForce
Forces evaluation of the whole sequence and returns it. If this sequence represents an infinite set or series, the method will never return!
Public methodForEach
Apply the given function to each element of this sequence. If this sequence represents an infinite set or series, this will never return!
Public methodGetEnumerator
Returns an enumerator that iterates through the Sequence T .
Public methodGetHashCode
Serves as a hash function for a particular type.
(Inherited from Object.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Public methodGrouped
Partitions elements in fixed size sequences.
Public methodIndexOf(T)
Finds the index of the first occurrence of some value in this sequence. If this sequence represents an infinite set or series and doesn't contain elem, this will never return!
Public methodIndexOf(T, Int32)
Finds the index of the first occurrence of some value in this sequence, after or at some start index. If this sequence represents an infinite set or series and doesn't contain elem, this will never return!
Public methodIndexOf(T, Int32, Int32)
Finds the index of the first occurrence of some value in this sequence, after or at some start index and within the range specified by count.
Public methodIndexOfSlice(IEnumerable T )
Finds the index of the first occurrence of a given sequence as a slice. If this sequence represents an infinite set or series and doesn't contain slice, this will never return!
Public methodIndexOfSlice(IEnumerable T , Int32)
Finds the index after or at a given start index of the first occurrence of a given sequence as a slice. If this sequence represents an infinite set or series and doesn't contain slice, this will never return!
Public methodIndexWhere(Func T, Boolean )
Finds the index of the first element satisfying some predicate. If this sequence represents an infinite set or series and no element satisfies the predicate, this will never return!
Public methodIndexWhere(Func T, Boolean , Int32)
Finds the index of the first element satisfying some predicate after or at some start index. If this sequence represents an infinite set or series and no element satisfies the predicate, this will never return!
Public methodIndexWhere(Func T, Boolean , Int32, Int32)
Finds the index of the first element satisfying some predicate after or at some start index and within the range specified by count.
Public methodIndices
Produces the range of all indices of this sequence.
Public methodInits
Iterates over the inits of this sequence. The first value will be this sequence, and the last value will be an empty sequence, with the intervening values the results of successive applications of Init.
Public methodLastIndexOf(T)
Finds the index of the last occurrence of some value in this sequence. If this sequence represents an infinite set or series, this will never return!
Public methodLastIndexOf(T, Int32)
Finds the index of the last occurrence of some value in this sequence, before or at some end index. If this sequence represents an infinite set or series, this will never return!
Public methodLastIndexOf(T, Int32, Int32)
Finds the index of the last occurrence of some value in this sequence, before or at some end index and within the range specified by count. If this sequence represents an infinite set or series, this will never return!
Public methodLastIndexWhere(Func T, Boolean )
Finds the index of the last element satisfying some predicate. If this sequence represents an infinite set or series, this will never return!
Public methodLastIndexWhere(Func T, Boolean , Int32)
Finds the index of the last element satisfying some predicate before or at some end index. If this sequence represents an infinite set or series, this will never return!
Public methodLastIndexWhere(Func T, Boolean , Int32, Int32)
Finds the index of the last element satisfying some predicate before or at some end index and within the range specified by count. If this sequence represents an infinite set or series, this will never return!
Public methodLengthCompare
Compares the length of this sequence with a test value. This method does not call Count directly - its running time is O(count min length) instead of O(count).
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Public methodMkString 
Returns a string with all the elements of this sequence. If this sequence represents an infinite set or series, this will never return!
Public methodMkString(String)
Returns a string with all the elements of this sequence, using a seperator string. If this sequence represents an infinite set or series, this will never return!
Public methodNonEmptyTails
Iterates over the tails of this sequence. The first value will be this sequence, and the last value will be a sequence with the last element of this sequence, with the intervening values the results of successive applications of Tail.
Public methodPadTo
Returns a new sequence in which the end is padded with elem, if this sequence has less elements than length.
Public methodPartition
Returns a pair of sequences, where the first contains all the elements of this sequence that satisfy the predicate function, and the second contains the elements that don't.
Public methodPatch
Returns a copy of this sequence where a slice of its elements is replaced by a patch sequence.
Public methodPermutations
Iterates over distinct permutations of this sequence. If this sequence represents an infinite set or series, calling GetEnumerator  on the result value will not return!
Public methodPrepend
Returns a copy of this sequence with the given element prepended.
Public methodReduce
Reduces the elements of this sequence using the specified function. If this sequence represents an infinite set or series, this will never return!
Public methodReduceRight
Reduces the elements of this sequence using the specified function, going right to left. If this sequence represents an infinite set or series, this will never return!
Public methodRemove
Returns a copy of this sequence without the first occurrence of the given element, if any is found.
Public methodScan
Crates a new sequence which contains all intermediate results of successive applications of a function op to subsequent elements left to right.
Public methodScanRight
Crates a new sequence which contains all intermediate results of successive applications of a function op to subsequent elements right to left. If this sequence represents an infinite set or series, this will never return!
Public methodSlice
Returns a subsequence starting at index from and extending up to (but not including) index until.
Public methodSliding(Int32)
Groups elements in fixed size blocks by passing a "sliding window" over them.
Public methodSliding(Int32, Int32)
Groups elements in fixed size blocks by passing a "sliding window" over them.
Public methodSpan
Splits this sequence into a prefix/suffix pair according to a predicate. The first sequence will contain the longest prefix of this sequence whose elements all satisfy predicate.
Public methodSplitAt
Splits this sequence into two at a given position.
Public methodTails
Iterates over the tails of this sequence. The first value will be this sequence, and the last value will be an empty sequence, with the intervening values the results of successive applications of Tail.
Public methodToString
Returns a string that represents this sequence.
(Overrides Object ToString .)
Public methodUpdated
Returns a copy of this sequence with one single replaced element. If index is greater than the number of elements in this sequence, nothing will be replaced.
Public methodZip TSecond 
Returns a sequence of tuples, where each tuple is formed by associating an element of this sequence with the element at the same position in the second sequence. If one of the two sequences is longer than the other, its remaining elements are ignored.
Public methodZipAll TSecond 
Returns a sequence of tuples, where each tuple is formed by associating an element of this sequence with the element at the same position in the second sequence. If one of the two sequences is shorter than the other, placeholder elements are used to extend the shorter collection to the length of the other.
Public methodZipWithIndex
Returns a sequence of tuples, where each tuple is formed by associating an element of this sequence with its index.
Top
Extension Methods
  NameDescription
Public Extension MethodAsSequence T 
Creates a sequence from a given enumerable.
(Defined by Sequence.)
Public Extension MethodDistinct T  Overloaded.
Returns distinct elements from a sequence by using the default equality comparer to compare values.
(Defined by Sequence.)
Public Extension MethodDistinct T (IEqualityComparer T )Overloaded. (Defined by Sequence.)
Public Extension MethodExcept T (IEnumerable T )Overloaded.
Produces the set difference of two sequences by using the default equality comparer to compare values. If the second sequence represents an infinite set or series, this will never return!
(Defined by Sequence.)
Public Extension MethodExcept T (IEnumerable T , IEqualityComparer T )Overloaded.
Produces the set difference of two sequences by using the specified IEqualityComparer T  to compare values. If the second sequence represents an infinite set or series, this will never return!
(Defined by Sequence.)
Public Extension MethodIntersect T (IEnumerable T )Overloaded.
Produces the set intersection of two sequences by using the default equality comparer to compare values. If the second sequence represents an infinite set or series, this will never return!
(Defined by Sequence.)
Public Extension MethodIntersect T (IEnumerable T , IEqualityComparer T )Overloaded.
Produces the set intersection of two sequences by using the specified IEqualityComparer T  to compare values. If the second sequence represents an infinite set or series, this will never return!
(Defined by Sequence.)
Public Extension MethodReverse T 
Inverts the order of the elements in a sequence. If the source sequence represents an infinite set or series, this will never return!
(Defined by Sequence.)
Public Extension MethodSelect T, TResult (Func T, TResult )Overloaded.
Projects each element of a sequence into a new sequence.
(Defined by Sequence.)
Public Extension MethodSelect T, TResult (Func T, Int32, TResult )Overloaded.
Projects each element of a sequence into a new sequence. Each element's index is used in the logic of the selector function.
(Defined by Sequence.)
Public Extension MethodSelectMany T, TResult (Func T, IEnumerable TResult  )Overloaded. (Defined by Sequence.)
Public Extension MethodSelectMany T, TResult (Func T, Int32, IEnumerable TResult  )Overloaded.
Projects each element of a sequence to an IEnumerable T  and flattens the resulting enumerables into one sequence. The index of each source element is used in the projected form of that element.
(Defined by Sequence.)
Public Extension MethodSelectMany T, TCollection, TResult (Func T, IEnumerable TCollection  , Func T, TCollection, TResult )Overloaded.
Projects each element of a sequence to an IEnumerable T , flattens the resulting enumerables into one sequence, and invokes a result selector function on each element therein.
(Defined by Sequence.)
Public Extension MethodSelectMany T, TCollection, TResult (Func T, Int32, IEnumerable TCollection  , Func T, TCollection, TResult )Overloaded.
Projects each element of a sequence to an IEnumerable T , flattens the resulting enumerables into one sequence, and invokes a result selector function on each element therein. The index of each source element is used in the intermediate projected form of that element.
(Defined by Sequence.)
Public Extension MethodSkip T 
Bypasses a specified number of elements in a sequence and then returns the remaining elements.
(Defined by Sequence.)
Public Extension MethodSkipWhile T (Func T, Boolean )Overloaded.
Bypasses elements in a sequence as long as a specified condition is true and then returns the remaining elements. If the source sequence represents an infinite set or series and all elements satisfy the given condition, this will never return!
(Defined by Sequence.)
Public Extension MethodSkipWhile T (Func T, Int32, Boolean )Overloaded.
Bypasses elements in a sequence as long as a specified condition is true and then returns the remaining elements. The element's index is used in the logic of the predicate function. If the source sequence represents an infinite set or series and all elements satisfy the given condition, this will never return!
(Defined by Sequence.)
Public Extension MethodSum T (Func T, BigInteger )Overloaded.
Computes the sum of the sequence of BigInteger values that are obtained by invoking a transform function on each element of the input sequence. If the source sequence represents an infinite set or series, this will never return!
(Defined by Sequence.)
Public Extension MethodSum T (Func T, Nullable BigInteger  )Overloaded.
Computes the sum of the sequence of Nullable T  values that are obtained by invoking a transform function on each element of the input sequence. If the source sequence represents an infinite set or series, this will never return!
(Defined by Sequence.)
Public Extension MethodTake T 
Returns a specified number of contiguous elements from the start of a sequence.
(Defined by Sequence.)
Public Extension MethodTakeWhile T (Func T, Boolean )Overloaded.
Returns elements from a sequence as long as a specified condition is true.
(Defined by Sequence.)
Public Extension MethodTakeWhile T (Func T, Int32, Boolean )Overloaded.
Returns elements from a sequence as long as a specified condition is true. The element's index is used in the logic of the predicate function.
(Defined by Sequence.)
Public Extension MethodUnion T (IEnumerable T )Overloaded.
Produces the set union of two sequences by using the default equality comparer.
(Defined by Sequence.)
Public Extension MethodUnion T (IEnumerable T , IEqualityComparer T )Overloaded. (Defined by Sequence.)
Public Extension MethodWhere T (Func T, Boolean )Overloaded.
Filters a sequence of values based on a predicate.
(Defined by Sequence.)
Public Extension MethodWhere T (Func T, Int32, Boolean )Overloaded.
Filters a sequence of values based on a predicate. Each element's index is used in the logic of the predicate function.
(Defined by Sequence.)
Public Extension MethodZip T, TSecond, TResult 
Applies a specified function to the corresponding elements of two sequences, producing a sequence of the results.
(Defined by Sequence.)
Top
Properties
  NameDescription
Public propertyCount
Returns the length of this sequence. If this sequence represents an infinite set or series, this will never return!
Public propertyHasDefiniteSize
Tests whether this sequence is known to have a finite size.
Public propertyHead
Returns the first element of this sequence.
Public propertyInit
Returns this sequence without its last element.
Public propertyIsEmpty
Tests whether the sequence is empty.
Public propertyIsTailDefined
Checks whether this sequence's tail has been evaluated.
Public propertyItem
Gets the element at the specified index.
Public propertyNonEmpty
Tests whether the sequence is not empty.
Public propertyTail
Returns a sequence of all elements except the first.
Top
See Also