diff --git a/src/FSharp.Core/seq.fsi b/src/FSharp.Core/seq.fsi index 24189d3730..948c539bb0 100644 --- a/src/FSharp.Core/seq.fsi +++ b/src/FSharp.Core/seq.fsi @@ -21,6 +21,11 @@ module Seq = /// /// Thrown when either of the input sequences is null. /// + /// + /// Time Complexity: O(n * m) - where n is the length of source1 and m is the length of source2 + /// Space Complexity: O(m) - for caching source2, plus O(1) for lazy evaluation + /// + /// /// /// /// ([1; 2], [3; 4]) ||> Seq.allPairs @@ -38,7 +43,11 @@ module Seq = /// /// The returned sequence may be passed between threads safely. However, /// individual IEnumerator values generated from the returned sequence should not be accessed - /// concurrently. + /// concurrently. + /// + /// Time Complexity: O(1) - for lazy sequence construction, O(n + m) for full enumeration + /// Space Complexity: O(1) - lazy evaluation with constant overhead + /// /// /// The first sequence. /// The second sequence. @@ -60,7 +69,11 @@ module Seq = /// Returns the average of the elements in the sequence. /// /// The elements are averaged using the + operator, DivideByInt method and Zero property - /// associated with the element type. + /// associated with the element type. + /// + /// Time Complexity: O(n) - where n is the length of the source sequence + /// Space Complexity: O(1) - constant space for accumulating sum and count + /// /// /// The input sequence. /// @@ -93,7 +106,11 @@ module Seq = /// of the sequence. /// /// The elements are averaged using the + operator, DivideByInt method and Zero property - /// associated with the generated type. + /// associated with the generated type. + /// + /// Time Complexity: O(n) - where n is the length of the source sequence + /// Space Complexity: O(1) - constant space for accumulating sum and count + /// /// /// A function applied to transform each element of the sequence. /// The input sequence. @@ -151,7 +168,11 @@ module Seq = /// The enumerator may be disposed and underlying cache storage released by /// converting the returned sequence object to type IDisposable, and calling the Dispose method /// on this object. The sequence object may then be re-enumerated and a fresh enumerator will - /// be used. + /// be used. + /// + /// Time Complexity: O(1) - for initial setup, O(k) for accessing k elements from cache + /// Space Complexity: O(k) - where k is the number of elements accessed from the source sequence + /// /// /// The input sequence. /// @@ -177,7 +198,11 @@ module Seq = /// The use of this function usually requires a type annotation. /// An incorrect type annotation may result in runtime type /// errors. - /// Individual IEnumerator values generated from the returned sequence should not be accessed concurrently. + /// Individual IEnumerator values generated from the returned sequence should not be accessed concurrently. + /// + /// Time Complexity: O(1) - for lazy sequence construction, O(n) for full enumeration + /// Space Complexity: O(1) - lazy evaluation with constant overhead + /// /// /// The input sequence. /// @@ -200,7 +225,11 @@ module Seq = /// /// The returned sequence may be passed between threads safely. However, /// individual IEnumerator values generated from the returned sequence should not - /// be accessed concurrently. + /// be accessed concurrently. + /// + /// Time Complexity: O(1) - for lazy sequence construction, O(n) for full enumeration + /// Space Complexity: O(1) - lazy evaluation with constant overhead + /// /// /// A function to transform items of type T into options of type U. /// The input sequence of type T. @@ -235,6 +264,11 @@ module Seq = /// Thrown when the input sequence is null. /// Thrown when chunkSize is not positive. /// + /// + /// Time Complexity: O(1) - for lazy sequence construction, O(n) for full enumeration + /// Space Complexity: O(chunkSize) - for each chunk array, plus O(1) for lazy evaluation + /// + /// /// /// /// [1; 2; 3] |> Seq.chunkBySize 2 @@ -254,7 +288,11 @@ module Seq = /// Applies the given function to each element of the sequence and concatenates all the /// results. /// - /// Remember sequence is lazy, effects are delayed until it is enumerated. + /// Remember sequence is lazy, effects are delayed until it is enumerated. + /// + /// Time Complexity: O(1) - for lazy sequence construction, O(n + Σk_i) for full enumeration where k_i is the length of each mapped subsequence + /// Space Complexity: O(1) - lazy evaluation with constant overhead + /// /// /// A function to transform elements of the input sequence into the sequences /// that will then be concatenated. @@ -300,6 +338,11 @@ module Seq = /// Thrown when either of the input sequences /// is null. /// + /// + /// Time Complexity: O(min(n, m)) - where n and m are lengths of the sequences, stops at first difference + /// Space Complexity: O(1) - constant space for comparison + /// + /// /// /// /// let closerToNextDozen a b = @@ -371,7 +414,11 @@ module Seq = /// enumeration. /// /// The returned sequence may be passed between threads safely. However, - /// individual IEnumerator values generated from the returned sequence should not be accessed concurrently. + /// individual IEnumerator values generated from the returned sequence should not be accessed concurrently. + /// + /// Time Complexity: O(1) - for lazy sequence construction, O(Σn_i) for full enumeration where n_i is the length of each subsequence + /// Space Complexity: O(1) - lazy evaluation with constant overhead + /// /// /// The input enumeration-of-enumerations. /// @@ -399,6 +446,11 @@ module Seq = /// /// Thrown when the input sequence is null. /// + /// + /// Time Complexity: O(n) - where n is the position of the element or the length of the sequence if not found + /// Space Complexity: O(1) - constant space for comparison + /// + /// /// /// /// [1; 2] |> Seq.contains 2 // evaluates to true @@ -414,7 +466,11 @@ module Seq = /// Note that this function returns a sequence that digests the whole initial sequence as soon as /// that sequence is iterated. As a result this function should not be used with /// large or infinite sequences. The function makes no assumption on the ordering of the original - /// sequence. + /// sequence. + /// + /// Time Complexity: O(n) - where n is the length of the source sequence + /// Space Complexity: O(k) - where k is the number of unique keys + /// /// /// A function transforming each item of the input sequence into a key to be /// compared against the others. @@ -441,7 +497,11 @@ module Seq = /// sequence. /// /// The input function is evaluated each time an IEnumerator for the sequence - /// is requested. + /// is requested. + /// + /// Time Complexity: O(1) - for creating the delayed sequence wrapper + /// Space Complexity: O(1) - constant overhead for the delay mechanism + /// /// /// The generating function for the sequence. /// The result sequence. @@ -466,6 +526,11 @@ module Seq = /// /// Thrown when the input sequence is null. /// + /// + /// Time Complexity: O(n) - where n is the length of the source sequence + /// Space Complexity: O(k) - where k is the number of distinct elements + /// + /// /// /// /// [1; 1; 2; 3] |> Seq.distinct @@ -486,6 +551,11 @@ module Seq = /// /// Thrown when the input sequence is null. /// + /// + /// Time Complexity: O(n) - where n is the length of the source sequence + /// Space Complexity: O(k) - where k is the number of distinct keys + /// + /// /// /// /// let inputs = [{Bar = 1 };{Bar = 1}; {Bar = 2}; {Bar = 3}] @@ -500,7 +570,11 @@ module Seq = /// Splits the input sequence into at most count chunks. /// /// This function returns a sequence that digests the whole initial sequence as soon as that - /// sequence is iterated. As a result this function should not be used with large or infinite sequences. + /// sequence is iterated. As a result this function should not be used with large or infinite sequences. + /// + /// Time Complexity: O(n) - where n is the length of the source sequence + /// Space Complexity: O(n) - for materializing the sequence and creating chunks + /// /// /// The maximum number of chunks. /// The input sequence. @@ -536,6 +610,11 @@ module Seq = /// /// An empty sequence. /// + /// + /// Time Complexity: O(1) - constant time creation + /// Space Complexity: O(1) - no memory allocation for empty sequence + /// + /// /// /// /// Seq.empty // Evaluates to seq { } @@ -551,7 +630,11 @@ module Seq = /// Note that this function returns a sequence that digests the whole of the first input sequence as soon as /// the result sequence is iterated. As a result this function should not be used with /// large or infinite sequences in the first parameter. The function makes no assumption on the ordering of the first input - /// sequence. + /// sequence. + /// + /// Time Complexity: O(n + m) - where n is the length of itemsToExclude and m is the length of source + /// Space Complexity: O(n) - for storing the exclusion set from itemsToExclude + /// /// /// A sequence whose elements that also occur in the second sequence will cause those elements to be /// removed from the returned sequence. @@ -577,7 +660,11 @@ module Seq = /// /// The predicate is applied to the elements of the input sequence. If any application /// returns true then the overall result is true and no further elements are tested. - /// Otherwise, false is returned. + /// Otherwise, false is returned. + /// + /// Time Complexity: O(n) - where n is the position of the first matching element, or length of sequence if none match + /// Space Complexity: O(1) - constant space for evaluation + /// /// /// A function to test each item of the input sequence. /// The input sequence. @@ -611,7 +698,11 @@ module Seq = /// The predicate is applied to matching elements in the two sequences up to the lesser of the /// two lengths of the collections. If any application returns true then the overall result is /// true and no further elements are tested. Otherwise, false is returned. If one sequence is shorter than - /// the other then the remaining elements of the longer sequence are ignored. + /// the other then the remaining elements of the longer sequence are ignored. + /// + /// Time Complexity: O(min(n, m)) - where n and m are the lengths of the sequences, stops at first match + /// Space Complexity: O(1) - constant space for evaluation + /// /// /// A function to test each pair of items from the input sequences. /// The first input sequence. @@ -649,7 +740,11 @@ module Seq = /// The returned sequence may be passed between threads safely. However, /// individual IEnumerator values generated from the returned sequence should not be accessed concurrently. /// - /// Remember sequence is lazy, effects are delayed until it is enumerated. + /// Remember sequence is lazy, effects are delayed until it is enumerated. + /// + /// Time Complexity: O(1) - for lazy sequence construction, O(n) for full enumeration where n is the source length + /// Space Complexity: O(1) - lazy evaluation with constant overhead + /// /// /// A function to test whether each item in the input sequence should be included in the output. /// The input sequence. @@ -677,7 +772,11 @@ module Seq = /// /// Remember sequence is lazy, effects are delayed until it is enumerated. /// - /// A synonym for Seq.filter. + /// A synonym for Seq.filter. + /// + /// Time Complexity: O(1) - for lazy sequence construction, O(n) for full enumeration where n is the source length + /// Space Complexity: O(1) - lazy evaluation with constant overhead + /// /// /// A function to test whether each item in the input sequence should be included in the output. /// The input sequence. @@ -706,6 +805,11 @@ module Seq = /// evaluated by the predicate /// Thrown when the input sequence is null /// + /// + /// Time Complexity: O(n) - where n is the position of the first matching element, or length of sequence if none match + /// Space Complexity: O(1) - constant space for evaluation + /// + /// /// /// /// let inputs = [1; 2; 3]