Stack template. More...
#include <rstack.h>
Public Member Functions | |
RStack (size_t m, size_t i=0) | |
RStack (const RContainer< C, true, false > &src) | |
RStack (const RContainer< C, false, false > &src) | |
size_t | GetNb (void) const |
void | Clear (size_t m=0, size_t i=0) |
C * | operator() (void) |
const C * | operator() (void) const |
const C * | operator[] (size_t idx) const |
C * | operator[] (size_t idx) |
void | Pop (void) |
void | Push (C *ptr) |
Additional Inherited Members | |
Private Member Functions inherited from RContainer< C, bAlloc, false > | |
RContainer (size_t m, size_t i=0) | |
RContainer (const RContainer< C, true, bOrder > &src) | |
RContainer (const RContainer< C, false, bOrder > &src) | |
int | Compare (const RContainer< C, bAlloc, bOrder > &) const |
size_t | GetNb (void) const |
size_t | GetMaxPos (void) const |
size_t | GetMaxNb (void) const |
size_t | GetIncNb (void) const |
bool | VerifyIndex (size_t idx) const |
void | VerifyTab (size_t max=0) |
void | Clear (size_t m=0, size_t i=0, bool force=false) |
void | ReOrder (int sortOrder(const void *, const void *), size_t min, size_t max) |
void | ReOrder (int sortOrder(const void *, const void *)) |
void | ReOrder (void) |
void | Exchange (size_t pos1, size_t pos2) |
void | Shift (size_t idx, bool reverse) |
void | Transfer (RContainer< C, a, o > &src) |
RContainer & | operator= (const RContainer< C, true, bOrder > &src) |
RContainer & | operator= (const RContainer< C, false, bOrder > &src) |
void | Copy (const RContainer< C, a, bOrder > &src) |
RContainer & | operator+= (const RContainer< C, a, o > &src) |
size_t | GetIndex (const TUse &tag, bool &find, size_t min=0, size_t max=0) const |
bool | IsIn (const TUse &tag, bool sortkey, size_t min=0, size_t max=0) const |
bool | IsIn (const TUse &tag, size_t min=0, size_t max=0) const |
const C * | operator[] (size_t idx) const |
C * | operator[] (size_t idx) |
const C * | GetPtrAt (size_t idx) const |
C * | GetPtrAt (size_t idx) |
C * | GetPtr (const TUse &tag, bool sortkey, size_t min=0, size_t max=0) const |
C * | GetPtr (const TUse &tag, size_t min=0, size_t max=0) const |
C * | GetInsertPtr (const TUse &tag, bool sortkey, size_t min=0, size_t max=0) |
C * | GetInsertPtr (const TUse &tag, size_t min=0, size_t max=0) |
C * | GetInsertPtrAt (const TUse &tag, size_t pos) |
RContainer< C, false, bOrder > * | GetPtrs (const TUse &tag, size_t min=0, size_t max=0) const |
size_t | GetTab (const void **tab, size_t min=0, size_t max=0) const |
size_t | GetTab (void **tab, size_t min=0, size_t max=0) |
size_t | GetTab (const C **tab, size_t min=0, size_t max=0) const |
size_t | GetTab (C **tab, size_t min=0, size_t max=0) |
void | InsertPtrAt (C *ins, size_t pos, bool del) |
void | InsertPtrAt (C *ins, size_t pos) |
void | InsertPtr (C *ins, bool del=false, size_t min=0, size_t max=0) |
void | DeletePtrAt (size_t pos, bool shift, bool del) |
void | DeletePtrAt (size_t pos, bool shift) |
void | DeletePtrAt (size_t pos) |
void | DeletePtr (const TUse &tag, bool sortkey, bool del, size_t min=0, size_t max=0) |
void | DeletePtr (const TUse &tag, bool sortkey, size_t min=0, size_t max=0) |
void | DeletePtr (const TUse &tag, size_t min=0, size_t max=0) |
void | Inter (const iRContainer< C > &src1, const iRContainer< C > &src2) |
void | Union (const iRContainer< C > &src1, const iRContainer< C > &src2) |
virtual | ~RContainer (void) |
Private Member Functions inherited from iRContainer< C > | |
size_t | GetNb (void) const |
size_t | GetMaxPos (void) const |
size_t | GetMaxNb (void) const |
size_t | GetIncNb (void) const |
bool | VerifyIndex (size_t idx) const |
void | VerifyTab (size_t max=0) |
void | Clear (size_t m=0, size_t i=0, bool force=false) |
void | ReOrder (int sortOrder(const void *, const void *), size_t min, size_t max) |
void | ReOrder (int sortOrder(const void *, const void *)) |
void | ReOrder (void) |
void | Exchange (size_t pos1, size_t pos2) |
void | Shift (size_t idx, bool reverse) |
void | Transfer (iRContainer< C > &src) |
iRContainer & | operator= (const iRContainer< C > &src) |
void | Copy (const iRContainer< C > &src) |
iRContainer & | operator+= (const iRContainer< C > &src) |
template<class TUse > | |
size_t | GetIndex (bool order, const TUse &tag, bool &find, size_t min=0, size_t max=0) const |
template<class TUse > | |
size_t | GetIndex (const TUse &tag, bool &find, size_t min=0, size_t max=0) const |
template<class TUse > | |
bool | IsIn (const TUse &tag, bool sortkey, size_t min=0, size_t max=0) const |
template<class TUse > | |
bool | IsIn (const TUse &tag, size_t min=0, size_t max=0) const |
const C * | operator[] (size_t idx) const |
C * | operator[] (size_t idx) |
const C * | GetPtrAt (size_t idx) const |
C * | GetPtrAt (size_t idx) |
template<class TUse > | |
C * | GetPtr (const TUse &tag, bool sortkey, size_t min=0, size_t max=0) const |
template<class TUse > | |
C * | GetPtr (const TUse &tag, size_t min=0, size_t max=0) const |
template<class TUse > | |
C * | GetInsertPtr (const TUse &tag, bool sortkey, size_t min=0, size_t max=0) |
template<class TUse > | |
C * | GetInsertPtr (const TUse &tag, size_t min=0, size_t max=0) |
template<class TUse > | |
C * | GetInsertPtrAt (const TUse &tag, size_t pos) |
size_t | GetTab (const void **tab, size_t min=0, size_t max=0) const |
size_t | GetTab (void **tab, size_t min=0, size_t max=0) |
size_t | GetTab (const C **tab, size_t min=0, size_t max=0) const |
size_t | GetTab (C **tab, size_t min=0, size_t max=0) |
void | InsertPtrAt (C *ins, size_t pos, bool del) |
void | InsertPtrAt (C *ins, size_t pos) |
void | InsertPtr (C *ins, bool del=false, size_t min=0, size_t max=0) |
void | DeletePtrAt (size_t pos, bool shift, bool del) |
void | DeletePtrAt (size_t pos, bool shift) |
void | DeletePtrAt (size_t pos) |
template<class TUse > | |
void | DeletePtr (const TUse &tag, bool sortkey, bool del, size_t min=0, size_t max=0) |
template<class TUse > | |
void | DeletePtr (const TUse &tag, bool sortkey, size_t min=0, size_t max=0) |
template<class TUse > | |
void | DeletePtr (const TUse &tag, size_t min=0, size_t max=0) |
void | Inter (const iRContainer< C > &src1, const iRContainer< C > &src2) |
void | Union (const iRContainer< C > &src1, const iRContainer< C > &src2) |
virtual | ~iRContainer (void) |
void | Create (const iRContainer< C > &src) |
iRContainer & | NormalCopy (const iRContainer< C > &src) |
void | DeepCopy (const iRContainer< C > &src) |
iRContainer & | Add (const iRContainer< C > &src) |
Static Private Member Functions inherited from RContainer< C, bAlloc, false > | |
static int | SortOrder (const void *a, const void *b) |
Static Private Member Functions inherited from iRContainer< C > | |
static int | SortOrder (const void *a, const void *b) |
Private Attributes inherited from iRContainer< C > | |
C ** | Tab |
size_t | NbPtr |
size_t | MaxPtr |
size_t | LastPtr |
size_t | IncPtr |
Detailed Description
template<class C, bool bAlloc, bool bPushTop, bool bPopTop>
class R::RStack< C, bAlloc, bPushTop, bPopTop >
Stack template.
This class represent a template for a stack of elements. These elements are stored in an array of pointers which will be increase when necessary.
- Parameters
-
C The class of the elements. bAlloc Specify if the elements are destroyed when removed from the stack. bPushTop Specify if a new element is added at the top of the stack (true) or at the end (false). bPopTop Specify if the next element to remove is taken from the top of the stack (true) or at the end (false).
To make the necessary comparisons, the stack needs that a compare function must be implemented in the class C:
Here is an example:
Constructor & Destructor Documentation
|
explicit |
Constructor of a stack.
- Parameters
-
m The initial maximal size of the stack. i The value used when increasing the stack. If null value, the size is set to the half the maximal size.
RStack | ( | const RContainer< C, true, false > & | src | ) |
Copy constructor of a stack.
- Parameters
-
src Stack used as source.
RStack | ( | const RContainer< C, false, false > & | src | ) |
Copy constructor of a stack.
- Parameters
-
src Stack used as source.
Member Function Documentation
size_t GetNb | ( | void | ) | const |
Get the number of elements in the stack.
- Returns
- size_t.
void Clear | ( | size_t | m = 0 , |
size_t | i = 0 |
||
) |
Clear the stack and destruct the elements if it is responsible for the desallocation. The stack may also be extended.
- Parameters
-
m New maximal size of the array. If null, the old size remains. i New increasing value. If null, the old value remains.
C* operator() | ( | void | ) |
Get the current element to treat from the stack (the element is not removed from the stack.
- Returns
- Pointer to the element.
const C* operator() | ( | void | ) | const |
Get the current element to treat from the stack (the element is not removed from the stack.
- Returns
- Pointer to the element.
const C* operator[] | ( | size_t | idx | ) | const |
Get a pointer to the ith element in the container (Only read).
- Parameters
-
idx Index of the element to get.
- Returns
- Return the pointer.
C* operator[] | ( | size_t | idx | ) |
Get a pointer to the ith element in the container (Read/Write).
- Parameters
-
idx Index of the element to get.
- Returns
- Return the pointer.
void Pop | ( | void | ) |
Remove the next element from the stack.
void Push | ( | C * | ptr | ) |
Add an element to the stack.
- Returns
- ptr Element to push.