XnStackT.h
Go to the documentation of this file.
#ifndef _XN_STACK_T_H_
#define _XN_STACK_T_H_
//---------------------------------------------------------------------------
// Includes
//---------------------------------------------------------------------------
#include "XnListT.h"
//---------------------------------------------------------------------------
// Code
//---------------------------------------------------------------------------
template<class T, class TAlloc = XnLinkedNodeDefaultAllocatorT<T> >
class XnStackT : protected XnListT<T, TAlloc>
{
public:
typedef XnListT<T, TAlloc> Base;
typedef typename Base::ConstIterator ConstIterator;
XnStackT() : Base() {}
XnStackT(const XnStackT& other) : Base()
{
*this = other;
}
XnStackT& operator=(const XnStackT& other)
{
Base::operator=(other);
// no other members
return *this;
}
~XnStackT() {}
XnBool IsEmpty() const { return Base::IsEmpty(); }
XnStatus Push(T const& value) { return Base::AddFirst(value); }
XnStatus Pop(T& value)
{
ConstIterator it = Begin();
if (it == End())
{
return XN_STATUS_IS_EMPTY;
}
value = *it;
return Base::Remove(it);
}
T const& Top() const { return *Begin(); }
T& Top() { return *Begin(); }
ConstIterator Begin() const { return Base::Begin(); }
ConstIterator End() const { return Base::End(); }
};
#endif // _XN_STACK_T_H_
XnListT.h
XnStatus
XnUInt32 XnStatus
Definition XnStatus.h:34
XnListT::XnListT
XnListT()
Definition XnListT.h:231
XnListT< T, TAlloc >::AddFirst
XnStatus AddFirst(T const &value)
Definition XnListT.h:371
XnListT< T, TAlloc >::operator=
XnListT & operator=(const XnListT &other)
Definition XnListT.h:242
XnListT< T, TAlloc >::End
Iterator End()
Definition XnListT.h:281
XnListT< T, TAlloc >::Begin
Iterator Begin()
Definition XnListT.h:265
XnListT< T, TAlloc >::Remove
XnStatus Remove(ConstIterator where)
Definition XnListT.h:426
XnListT< T, TAlloc >::IsEmpty
XnBool IsEmpty() const
Definition XnListT.h:482
XnStackT::Top
T const & Top() const
Definition XnStackT.h:51
XnStackT::XnStackT
XnStackT(const XnStackT &other)
Definition XnStackT.h:22
XnStackT< T, TAlloc >::Base
XnListT< T, TAlloc > Base
Definition XnStackT.h:16
XnStackT::operator=
XnStackT & operator=(const XnStackT &other)
Definition XnStackT.h:27
XnStackT::Pop
XnStatus Pop(T &value)
Definition XnStackT.h:40
XnStackT::Top
T & Top()
Definition XnStackT.h:52
XnStackT::~XnStackT
~XnStackT()
Definition XnStackT.h:34
XnStackT::End
ConstIterator End() const
Definition XnStackT.h:55
XnStackT::Push
XnStatus Push(T const &value)
Definition XnStackT.h:38
XnStackT::Begin
ConstIterator Begin() const
Definition XnStackT.h:54
XnStackT< T, TAlloc >::ConstIterator
Base::ConstIterator ConstIterator
Definition XnStackT.h:18
XnStackT::XnStackT
XnStackT()
Definition XnStackT.h:20
XnStackT::IsEmpty
XnBool IsEmpty() const
Definition XnStackT.h:36