ResizingArrayStackItem Class |
The ResizingArrayStack class represents a (LIFO) stack of generic items. It supports the usual Push and Pop operations, along with methods for peeking at the top item, testing if the stack is empty, and iterating through the items in LIFO order.
This implementation uses a resizing array, which double the underlying array when it is full and halves the underlying array when it is one-quarter full. The Push and Pop operations take constant amortized time, whereas he Count, Peek, and IsEmpty operations takes constant time in the worst case.
Namespace: Algs4Net
The ResizingArrayStackItem type exposes the following members.
Name | Description | |
---|---|---|
![]() | ResizingArrayStackItem |
Initializes an empty stack.
|
Name | Description | |
---|---|---|
![]() | GetEnumerator |
Returns an iterator to this stack that iterates through the items in LIFO order.
|
![]() ![]() | MainTest |
Demo test for the ResizingArrayStack data type.
|
![]() | Peek |
Returns (but does not remove) the item most recently added to this stack.
|
![]() | Pop |
Removes and returns the item most recently added to this stack.
|
![]() | Push |
Adds the item to this stack.
|
This class is a C# port from the original Java class ResizingArrayStack implementation by Robert Sedgewick and Kevin Wayne.