Add ImmutableArrayExtensions class by rameel · Pull Request #4 · rameel/ramstack.structures · GitHub
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions Ramstack.Structures.Tests/Collections/ArrayViewTests.cs
10 changes: 5 additions & 5 deletions Ramstack.Structures/Collections/ArrayViewExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public static ArrayView<T> AsView<T>(this T[]? value) =>
/// Creates a new <see cref="ArrayView{T}"/> over a portion of the target array from a specified position to the end of the array.
/// </summary>
/// <param name="value">The target array.</param>
/// <param name="index">The index at which to begin this slice.</param>
/// <param name="index">The index at which to begin the array view.</param>
/// <returns>
/// An <see cref="ArrayView{T}"/> representing the array.
/// </returns>
Expand All @@ -34,14 +34,14 @@ public static ArrayView<T> AsView<T>(this T[]? value, int index) =>
/// Creates a new <see cref="ArrayView{T}"/> over a portion of the target array from a specified position for a specified number of elements.
/// </summary>
/// <param name="value">The target array.</param>
/// <param name="index">The index at which to begin this slice.</param>
/// <param name="length">The desired length for the slice.</param>
/// <param name="index">The index at which to begin the array view.</param>
/// <param name="count">The number of items in the array view.</param>
/// <returns>
/// An <see cref="ArrayView{T}"/> representing the array.
/// </returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static ArrayView<T> AsView<T>(this T[]? value, int index, int length) =>
new(value ?? [], index, length);
public static ArrayView<T> AsView<T>(this T[]? value, int index, int count) =>
new(value ?? [], index, count);

/// <summary>
/// Finds the index of the first occurrence of a specified value in this instance.
Expand Down
43 changes: 43 additions & 0 deletions Ramstack.Structures/Collections/ImmutableArrayExtensions.cs