mn::container::basic_stack< TType > Class Template Reference

#include <mn_stack.hpp>

Public Types

using basic_type_t = TType
 

Public Member Functions

 basic_stack (size_t nSize)
 
 basic_stack (size_t nSize, basic_type_t *addr)
 
 basic_stack (size_t nSize, basic_type_t *addr, int offset)
 
int push (basic_type_t item)
 
int pop (basic_type_t *item)
 
int peek (basic_type_t *item)
 
void reset ()
 
int count ()
 
int size ()
 
bool is_empty ()
 
bool is_full ()
 
int get_left ()
 

Private Member Functions

void internal_create (size_t nSize, basic_type_t *addr, int offset)
 
void internal_reset ()
 

Private Attributes

basic_type_tm_ulAdrr
 
size_t m_ulSize
 
size_t m_iFirst
 
size_t m_iLast
 
size_t m_iCurrent
 

Detailed Description

template<typename TType>
class mn::container::basic_stack< TType >

A simple template for a Stack

Member Typedef Documentation

◆ basic_type_t

template<typename TType >
using mn::container::basic_stack< TType >::basic_type_t = TType

Constructor & Destructor Documentation

◆ basic_stack() [1/3]

template<typename TType >
mn::container::basic_stack< TType >::basic_stack ( size_t  nSize)
inlineexplicit

This constructor use malloc to create the buffer

Parameters
nSizeThe size of the stack

◆ basic_stack() [2/3]

template<typename TType >
mn::container::basic_stack< TType >::basic_stack ( size_t  nSize,
basic_type_t addr 
)
inline

This constructor use a given address as buffer

Parameters
nSizeThe size of the stack (The last position [addr+(nSize)] )
addrThe first buffer or adress to use as stack

◆ basic_stack() [3/3]

template<typename TType >
mn::container::basic_stack< TType >::basic_stack ( size_t  nSize,
basic_type_t addr,
int  offset 
)
inline

This constructor use a given address as buffer

Parameters
nSizeThe size of the stack (The last position [addr+(nSize)] )
addrThe first buffer or adress to use as stack
offsetThe offset, when start position in the buffer not address 0 is

Member Function Documentation

◆ count()

template<typename TType >
int mn::container::basic_stack< TType >::count ( )
inline

Get the count of the stack

Returns
The count of the stack

◆ get_left()

template<typename TType >
int mn::container::basic_stack< TType >::get_left ( )
inline

How many empty spaves are currently left in the stack.

◆ internal_create()

template<typename TType >
void mn::container::basic_stack< TType >::internal_create ( size_t  nSize,
basic_type_t addr,
int  offset 
)
inlineprivate

the internal creating function for the stack

Parameters
nSizeThe size of the stack (The last position [addr+(nSize)] )
addrThe first buffer or adress to use as stack
offsetThe offset, when start position in the buffer not address 0 is

◆ internal_reset()

template<typename TType >
void mn::container::basic_stack< TType >::internal_reset ( )
inlineprivate

The internal reset function

◆ is_empty()

template<typename TType >
bool mn::container::basic_stack< TType >::is_empty ( )
inline

Is the stack empty?

Returns
true the stack is empty and false when not

◆ is_full()

template<typename TType >
bool mn::container::basic_stack< TType >::is_full ( )
inline

Is the stack full?

Returns
true the stack is full and false when not

◆ peek()

template<typename TType >
int mn::container::basic_stack< TType >::peek ( basic_type_t item)
inline

get the current obj from the stack, this will not remove it

Parameters
itemWhere the item you are getting will be returned to.
Returns
- NO_ERROR the item was removed
  • ERR_NULL the given item was null
  • ERR_MNTHREAD_UNKN the stack is empty

◆ pop()

template<typename TType >
int mn::container::basic_stack< TType >::pop ( basic_type_t item)
inline

Pop an item from the stack

Parameters
itemWhere the item you are removing will be returned to.
Returns
- NO_ERROR the item was removed
  • ERR_NULL the given item was null
  • ERR_MNTHREAD_UNKN the stack is empty

◆ push()

template<typename TType >
int mn::container::basic_stack< TType >::push ( basic_type_t  item)
inline

Add an item to the stack

Parameters
itemThe item you are adding.
Returns
- NO_ERROR the item was added
  • ERR_MNTHREAD_UNKN the stack is full

◆ reset()

template<typename TType >
void mn::container::basic_stack< TType >::reset ( )
inline

Reset the stack, will remove all objects in the stack

◆ size()

template<typename TType >
int mn::container::basic_stack< TType >::size ( )
inline

Get the size of the stack

Returns
The size of the stack.

Member Data Documentation

◆ m_iCurrent

template<typename TType >
size_t mn::container::basic_stack< TType >::m_iCurrent
private

◆ m_iFirst

template<typename TType >
size_t mn::container::basic_stack< TType >::m_iFirst
private

◆ m_iLast

template<typename TType >
size_t mn::container::basic_stack< TType >::m_iLast
private

◆ m_ulAdrr

template<typename TType >
basic_type_t* mn::container::basic_stack< TType >::m_ulAdrr
private

◆ m_ulSize

template<typename TType >
size_t mn::container::basic_stack< TType >::m_ulSize
private

The documentation for this class was generated from the following file: