Add time and space complexity XML documentation to collection operators in FSharp.Core #18795
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds comprehensive time and space complexity documentation to collection operators in FSharp.Core .fsi files, improving developer understanding of performance characteristics.
Changes Made
Added
<remarks>
sections with time and space complexity information to key collection operators across multiple modules:Core List Operators (prim-types.fsi)
::
(cons): O(1) time, O(1) space@
(append): O(n) time, O(n) space where n is the length of the first listList Module (list.fsi)
List.append
: O(n) time, O(n) spaceList.concat
: O(n) time, O(n) space where n is total elementsList.head
: O(1) time, O(1) spaceList.tail
: O(1) time, O(1) spaceList.length
: O(n) time, O(1) spaceArray Module (array.fsi)
Array.append
: O(n+m) time, O(n+m) spaceArray.concat
: O(n) time, O(n) space where n is total elementsArray.head
: O(1) time, O(1) spaceArray.tail
: O(n) time, O(n) space (creates new array)Array.length
: O(1) time, O(1) spaceSet Module (set.fsi)
Set.add
: O(log n) time, O(log n) space due to balanced tree structureSet.remove
: O(log n) time, O(log n) spaceSet.union
: O(n+m) time, O(n+m) spaceSet.intersect
: O(n+m) time, O(min(n,m)) spaceMap Module (map.fsi)
Map.add
: O(log n) time, O(log n) space due to balanced tree structureMap.remove
: O(log n) time, O(log n) spaceSeq Module (seq.fsi)
Seq.append
: O(1) time, O(1) space (lazy evaluation)Implementation Details
The complexity documentation follows existing XML documentation patterns and is placed in
<remarks>
sections to maintain consistency with the codebase. Generic operators like hashing and equality were intentionally excluded per the requirements.All changes have been validated with successful builds to ensure XML documentation validity.
Benefits
This pull request was created as a result of the following prompt from Copilot chat.
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.