Skip to content

Commit 59c7a7b

Browse files
authored
Remove unnecessary array loop (#373)
1 parent 7788238 commit 59c7a7b

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

DataStructures/Stack/ArrayBasedStack.cs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,10 @@ public ArrayBasedStack(T item)
4242
/// Initializes a new instance of the <see cref="ArrayBasedStack{T}" /> class.
4343
/// </summary>
4444
/// <param name="items">Items to push onto the <see cref="ArrayBasedStack{T}" />.</param>
45-
public ArrayBasedStack(IEnumerable<T> items)
46-
: this()
45+
public ArrayBasedStack(T[] items)
4746
{
48-
foreach (var item in items)
49-
{
50-
Push(item);
51-
}
47+
stack = items;
48+
top = items.Length - 1;
5249
}
5350

5451
/// <summary>

0 commit comments

Comments
 (0)