diff --git a/src/FSharp.Core/array.fsi b/src/FSharp.Core/array.fsi index 18a4463277..2d12fc7e58 100644 --- a/src/FSharp.Core/array.fsi +++ b/src/FSharp.Core/array.fsi @@ -25,6 +25,11 @@ module Array = /// /// The resulting array of pairs. /// + /// + /// Time Complexity: O(n*m) where n is the length of array1 and m is the length of array2. + /// Space Complexity: O(n*m) for the resulting array. + /// + /// /// /// /// ([| 1; 2 |], [| 3; 4 |]) ||> Array.allPairs @@ -46,6 +51,11 @@ module Array = /// /// Thrown when either of the input arrays is null. /// + /// + /// Time Complexity: O(n+m) where n is the length of array1 and m is the length of array2. + /// Space Complexity: O(n+m) for the resulting array. + /// + /// /// /// /// Array.append [| 1; 2 |] [| 3; 4 |] @@ -64,6 +74,11 @@ module Array = /// /// The average of the elements in the array. /// + /// + /// Time Complexity: O(n) where n is the length of the array. + /// Space Complexity: O(1). + /// + /// /// /// /// [| 1.0; 2.0; 6.0 |] |> Array.average @@ -95,6 +110,11 @@ module Array = /// /// Thrown when the input array is null. /// + /// + /// Time Complexity: O(n) where n is the length of the array. + /// Space Complexity: O(1). + /// + /// /// /// /// type Foo = { Bar: float } @@ -138,6 +158,8 @@ module Array = /// let target = [| 0; 1; 2; 3; 4; 5 |] /// target[3..4] <- source[1..2] /// + /// Time Complexity: O(count) where count is the number of elements to copy. + /// Space Complexity: O(1). /// /// /// Thrown when either of the input arrays is null. @@ -165,6 +187,11 @@ module Array = /// /// Thrown when the input array is null. /// + /// + /// Time Complexity: O(n*k) where n is the length of the input array and k is the average length of the arrays returned by the mapping function. + /// Space Complexity: O(n*k) for the resulting array. + /// + /// /// /// /// type Foo = { Bar: int array } @@ -203,6 +230,11 @@ module Array = /// Thrown when either of the input arrays /// is null. /// + /// + /// Time Complexity: O(min(n,m)) where n and m are the lengths of the arrays, as comparison stops at the first non-zero result. + /// Space Complexity: O(1). + /// + /// /// /// /// let closerToNextDozen a b = @@ -278,6 +310,11 @@ module Array = /// /// Thrown when the input sequence is null. /// + /// + /// Time Complexity: O(∑|arrays[i]|) where ∑|arrays[i]| is the sum of lengths of all input arrays. + /// Space Complexity: O(∑|arrays[i]|) for the resulting array. + /// + /// /// /// /// let inputs = [ [| 1; 2 |]; [| 3 |]; [| 4; 5 |] ] @@ -298,6 +335,11 @@ module Array = /// /// Thrown when the input array is null. /// + /// + /// Time Complexity: O(n) where n is the length of the array. + /// Space Complexity: O(1). + /// + /// /// /// /// [| 1; 2 |] |> Array.contains 2 // evaluates to true @@ -315,6 +357,11 @@ module Array = /// /// Thrown when the input array is null. /// + /// + /// Time Complexity: O(n) where n is the length of the array. + /// Space Complexity: O(n) for the new array. + /// + /// /// /// /// let source = [| 12; 13; 14 |] @@ -337,6 +384,11 @@ module Array = /// /// Thrown when the input array is null. /// + /// + /// Time Complexity: O(n) where n is the length of the array. + /// Space Complexity: O(k) where k is the number of unique keys. + /// + /// /// /// /// type Foo = { Bar: string } @@ -359,6 +411,11 @@ module Array = /// /// Thrown when count is negative. /// + /// + /// Time Complexity: O(n) where n is the count. + /// Space Complexity: O(n) for the new array. + /// + /// /// /// /// Array.create 4 "a" @@ -389,6 +446,11 @@ module Array = /// /// The first element of the array or None. /// + /// + /// Time Complexity: O(1). + /// Space Complexity: O(1). + /// + /// /// /// /// let inputs = [| "banana"; "pear" |] @@ -420,6 +482,11 @@ module Array = /// /// Thrown when the input array is null. /// + /// + /// Time Complexity: O(n) where n is the length of the array. + /// Space Complexity: O(1). + /// + /// /// /// /// let input = [| 1; 2; 3 |] @@ -451,6 +518,11 @@ module Array = /// Thrown when the input array is null. /// Thrown when either targetIndex or count is negative. /// + /// + /// Time Complexity: O(count) where count is the number of elements to fill. + /// Space Complexity: O(1). + /// + /// /// /// /// let target = [| 0; 1; 2; 3; 4; 5 |] @@ -475,6 +547,11 @@ module Array = /// /// The first result. /// + /// + /// Time Complexity: O(n) where n is the length of the array. + /// Space Complexity: O(1). + /// + /// /// /// /// let input = [| 1; 2; 3 |] @@ -507,6 +584,11 @@ module Array = /// /// Thrown when the input array is null. /// + /// + /// Time Complexity: O(n) where n is the length of the array. + /// Space Complexity: O(k) where k is the number of elements for which the chooser returns Some. + /// + /// /// /// /// let input = [| Some 1; None; Some 2 |] @@ -633,6 +715,11 @@ module Array = /// Returns an empty array of the given type. /// The empty array. /// + /// + /// Time Complexity: O(1). + /// Space Complexity: O(1). + /// + /// /// /// /// Array.empty // Evaluates to [| |] @@ -744,7 +831,10 @@ module Array = /// /// The predicate is applied to the elements of the input array. 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 length of the array. + /// Space Complexity: O(1). + /// /// /// The function to test the input elements. /// The input array. @@ -822,6 +912,11 @@ module Array = /// /// Thrown when the input array is null. /// + /// + /// Time Complexity: O(n) where n is the length of the array. + /// Space Complexity: O(k) where k is the number of elements that satisfy the predicate. + /// + /// /// /// /// let inputs = [| 1; 2; 3; 4 |] @@ -1048,6 +1143,11 @@ module Array = /// /// Thrown when the input array is null. /// + /// + /// Time Complexity: O(n) where n is the length of the array. + /// Space Complexity: O(1). + /// + /// /// /// /// type Charge = @@ -1530,7 +1630,10 @@ module Array = /// /// The length of the array. /// - /// The notation array.Length is preferred. + /// The notation array.Length is preferred. + /// Time Complexity: O(1). + /// Space Complexity: O(1). + /// /// /// Thrown when the input array is null. /// @@ -1580,6 +1683,11 @@ module Array = /// /// Thrown when the input array is null. /// + /// + /// Time Complexity: O(n) where n is the length of the array. + /// Space Complexity: O(n) for the new array. + /// + /// /// /// /// let inputs = [| "a"; "bbb"; "cc" |] @@ -2268,7 +2376,10 @@ module Array = /// Sorts the elements of an array, returning a new array. Elements are compared using . /// /// This is not a stable sort, i.e. the original order of equal elements is not necessarily preserved. - /// For a stable sort, consider using . + /// For a stable sort, consider using . + /// Time Complexity: O(n log n) where n is the length of the array. + /// Space Complexity: O(n) for the new array. + /// /// /// The input array. ///