#include <Containers_T.h>
Collaboration diagram for ACE_Bounded_Stack:

Public Methods | |
| ACE_Bounded_Stack (size_t size) | |
| Initialize a new empty stack with the provided size.. More... | |
| ACE_Bounded_Stack (const ACE_Bounded_Stack< T > &s) | |
| Initialize the stack to be a copy of the stack provided. More... | |
| void | operator= (const ACE_Bounded_Stack< T > &s) |
| Assignment operator. More... | |
| ~ACE_Bounded_Stack (void) | |
| Perform actions needed when stack goes out of scope. More... | |
| int | push (const T &new_item) |
| Add an element to the top of the stack. More... | |
| int | pop (T &item) |
| Remove an item from the top of stack. More... | |
| int | top (T &item) const |
| Examine the contents of the top of stack. More... | |
| int | is_empty (void) const |
| Returns 1 if the container is empty, otherwise returns 0. More... | |
| int | is_full (void) const |
| Returns 1 if the container is full, otherwise returns 0. More... | |
| size_t | size (void) const |
| The number of items in the stack. More... | |
| void | dump (void) const |
| Dump the state of an object. More... | |
Public Attributes | |
| ACE_ALLOC_HOOK_DECLARE | |
| Declare the dynamic allocation hooks. More... | |
Private Attributes | |
| size_t | size_ |
| Size of the dynamically allocated data. More... | |
| size_t | top_ |
| Keeps track of the current top of stack. More... | |
| T * | stack_ |
| Holds the stack's contents. More... | |
This implementation of a Stack uses a bounded array that is allocated dynamically. The Stack interface provides the standard constant time push, pop, and top operations.
Requirements and Performance Characteristics
Definition at line 76 of file Containers_T.h.
|
||||||||||
|
Initialize a new empty stack with the provided size.. Initialize and allocate space for a new Bounded_Stack with the provided size. Definition at line 30 of file Containers_T.cpp. References ACE_NEW, ACE_TRACE, and size.
|
|
||||||||||
|
Initialize the stack to be a copy of the stack provided. Initialize the stack to be an exact copy of the Bounded_Stack provided as a parameter. Definition at line 40 of file Containers_T.cpp. References ACE_NEW, ACE_TRACE, stack_, and top_.
|
|
||||||||||
|
Perform actions needed when stack goes out of scope. Deallocate the memory used by the Bounded_Stack. Definition at line 75 of file Containers_T.cpp. References ACE_TRACE, and stack_.
|
|
||||||||||
|
Dump the state of an object.
Definition at line 24 of file Containers_T.cpp. References ACE_TRACE.
00025 {
00026 ACE_TRACE ("ACE_Bounded_Stack<T>::dump");
00027 }
|
|
||||||||||
|
Returns 1 if the container is empty, otherwise returns 0. Performs constant time check to determine if the stack is empty. Definition at line 7 of file Containers_T.i. References ACE_TRACE, and top_.
|
|
||||||||||
|
Returns 1 if the container is full, otherwise returns 0. Performs constant time check to determine if the stack is at capacity. Definition at line 14 of file Containers_T.i. References ACE_TRACE, size_, and top_. Referenced by push.
|
|
||||||||||
|
Assignment operator. Perform a deep copy operation using the Bounded_Stack parameter. If the capacity of the lhs isn't sufficient for the rhs, then the underlying data structure will be reallocated to accomadate the larger number of elements. Definition at line 54 of file Containers_T.cpp. References ACE_NEW, ACE_TRACE, size_, stack_, and top_.
00055 {
00056 ACE_TRACE ("ACE_Bounded_Stack<T>::operator=");
00057
00058 if (&s != this)
00059 {
00060 if (this->size_ < s.size_)
00061 {
00062 delete [] this->stack_;
00063 ACE_NEW (this->stack_,
00064 T[s.size_]);
00065 this->size_ = s.size_;
00066 }
00067 this->top_ = s.top_;
00068
00069 for (size_t i = 0; i < this->top_; i++)
00070 this->stack_[i] = s.stack_[i];
00071 }
00072 }
|
|
||||||||||
|
Remove an item from the top of stack. Remove and return the top stack item. Returns -1 if the stack is already empty, 0 if the stack is not already empty, and -1 if failure occurs. Definition at line 34 of file Containers_T.i. References ACE_TRACE, is_empty, stack_, and top_.
|
|
||||||||||
|
Add an element to the top of the stack. Place a new item on top of the stack. Returns -1 if the stack is already full, 0 if the stack is not already full, and -1 if failure occurs. Definition at line 21 of file Containers_T.i. References ACE_TRACE, is_full, stack_, and top_.
|
|
||||||||||
|
The number of items in the stack. Return the number of items currently in the stack. Definition at line 60 of file Containers_T.i. References size_. Referenced by ACE_Bounded_Stack.
00061 {
00062 return this->size_;
00063 }
|
|
||||||||||
|
Examine the contents of the top of stack. Return top stack item without removing it. Returns -1 if the stack is already empty, 0 if the stack is not already empty, and -1 if failure occurs. Definition at line 47 of file Containers_T.i. References ACE_TRACE, is_empty, stack_, and top_.
|
|
|||||
|
Declare the dynamic allocation hooks.
Definition at line 159 of file Containers_T.h. |
|
|||||
|
Size of the dynamically allocated data.
Definition at line 163 of file Containers_T.h. |
|
|||||
|
Holds the stack's contents.
Definition at line 169 of file Containers_T.h. Referenced by ACE_Bounded_Stack, operator=, pop, push, top, and ~ACE_Bounded_Stack. |
|
|||||
|
Keeps track of the current top of stack.
Definition at line 166 of file Containers_T.h. Referenced by ACE_Bounded_Stack, is_empty, is_full, operator=, pop, push, and top. |
1.2.14 written by Dimitri van Heesch,
© 1997-2002