PUMA Library Reference Manual
Loading...
Searching...
No Matches
Puma::BCStack< Item, BUCKET_SIZE > Class Template Reference

#include <Puma/BCStack.h>

+ Inheritance diagram for Puma::BCStack< Item, BUCKET_SIZE >:

Description

template<class Item, int BUCKET_SIZE = 32>
class Puma::BCStack< Item, BUCKET_SIZE >

Stack of fixed-size buckets.

A bucket is a fixed-size array that is filled sequentially. Each bucket is linked with the previous and next buckets forming a double linked list. Items are accessed last-in first-out. No random access supported.

Template Parameters
ItemThe stack item type.
BUCKET_SIZEOptional size of each bucket. Defaults to 32.

Public Types

typedef List::Iterator Iterator
 Iterator type for the bucket stack.
 

Public Member Functions

 BCStack ()
 Construct an empty bucket stack.
 
long length () const
 Get the length of the bucket stack.
 
void push (Item item)
 Push a new item on top of the stack.
 
Item & top () const
 Get the top item of the stack.
 
void pop ()
 Remove the top item from the stack.
 
void reset ()
 Reset the bucket stack.
 
bool empty () const
 Check if the stack is empty.
 

Member Typedef Documentation

◆ Iterator

template<class Item , int BUCKET_SIZE = 32>
typedef List::Iterator Puma::BCStack< Item, BUCKET_SIZE >::Iterator

Iterator type for the bucket stack.

Constructor & Destructor Documentation

◆ BCStack()

template<class Item , int BUCKET_SIZE = 32>
Puma::BCStack< Item, BUCKET_SIZE >::BCStack ( )
inline

Construct an empty bucket stack.

Member Function Documentation

◆ empty()

template<class Item , int BUCKET_SIZE = 32>
bool Puma::BCStack< Item, BUCKET_SIZE >::empty ( ) const
inline

Check if the stack is empty.

Returns
True if the stack is empty.

◆ length()

template<class Item , int BUCKET_SIZE = 32>
long Puma::BCStack< Item, BUCKET_SIZE >::length ( ) const
inline

Get the length of the bucket stack.

Returns
The current length.

◆ pop()

template<class Item , int BUCKET_SIZE = 32>
void Puma::BCStack< Item, BUCKET_SIZE >::pop ( )
inline

Remove the top item from the stack.

◆ push()

template<class Item , int BUCKET_SIZE = 32>
void Puma::BCStack< Item, BUCKET_SIZE >::push ( Item item)
inline

Push a new item on top of the stack.

Parameters
itemThe item to add.

◆ reset()

template<class Item , int BUCKET_SIZE = 32>
void Puma::BCStack< Item, BUCKET_SIZE >::reset ( )
inline

Reset the bucket stack.

Does not delete the stack items.

◆ top()

template<class Item , int BUCKET_SIZE = 32>
Item & Puma::BCStack< Item, BUCKET_SIZE >::top ( ) const
inline

Get the top item of the stack.

Returns
A reference to the top item.