Stacks
A stack is a last-in, first-out (LIFO) collection, like a stack of dishes at a buffet table, or a stack of coins on your desk. The last dish added to the top of the stack is the first dish you take off the stack.
The principal methods for adding to and removing from a stack are Push
and Pop
; Stack
also offers a Peek
method, very much like Queue
. The significant methods and properties for Stack
are shown in Table 17-4.
Table 17-4. Stack methods and properties
Method or property |
Purpose |
---|---|
|
Public property that gets the number of elements in the |
|
Removes all objects from the |
|
Creates a shallow copy |
|
Determines if an element is in the |
|
Copies the |
|
Returns an enumerator for the |
|
Returns the object at the top of the |
|
Removes and returns the object at the top of the |
|
Inserts an object at the top of the |
|
Copies the elements to a new array |
Get Programming Visual Basic 2005 now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.