85 lines
1.7 KiB
C++
85 lines
1.7 KiB
C++
#ifndef _BSPTREE_INORDERSTACK_HPP_
|
|
#define _BSPTREE_INORDERSTACK_HPP_
|
|
#ifndef _BSPTREE_TREENODE_HPP_
|
|
#include <bsptree/treenode.hpp>
|
|
#endif
|
|
#ifndef _COMMON_BLOCK_HPP_
|
|
#include <common/block.hpp>
|
|
#endif
|
|
#ifndef _COMMON_SMARTPOINTER_HPP_
|
|
#include <common/pointer.hpp>
|
|
#endif
|
|
|
|
template <class T>
|
|
class InorderStack : protected Block<SmartPointer<TreeNode<T> > >
|
|
{
|
|
public:
|
|
InorderStack(void);
|
|
virtual ~InorderStack();
|
|
void push(SmartPointer<TreeNode<T> > &ptrNode);
|
|
BOOL pop(SmartPointer<TreeNode<T> > &ptrNode);
|
|
void clear(void);
|
|
DWORD size(void)const;
|
|
private:
|
|
InorderStack(const InorderStack<T> &inorderStack);
|
|
InorderStack<T> &operator=(const InorderStack<T> &inorderStack);
|
|
};
|
|
|
|
template <class T>
|
|
inline
|
|
InorderStack<T>::InorderStack(void)
|
|
{
|
|
}
|
|
|
|
template <class T>
|
|
inline
|
|
InorderStack<T>::InorderStack(const InorderStack<T> &inorderStack)
|
|
{ // private implementation
|
|
*this=inorderStack;
|
|
}
|
|
|
|
template <class T>
|
|
inline
|
|
InorderStack<T>::~InorderStack()
|
|
{
|
|
}
|
|
|
|
template <class T>
|
|
inline
|
|
InorderStack<T> &InorderStack<T>::operator=(const InorderStack<T> &/*inorderStack*/)
|
|
{ // private implementation
|
|
return *this;
|
|
}
|
|
|
|
template <class T>
|
|
inline
|
|
void InorderStack<T>::push(SmartPointer<TreeNode<T> > &ptrNode)
|
|
{
|
|
insert(&SmartPointer<TreeNode<T> >(ptrNode));
|
|
}
|
|
|
|
template <class T>
|
|
inline
|
|
BOOL InorderStack<T>::pop(SmartPointer<TreeNode<T> > &ptrNode)
|
|
{
|
|
int items;
|
|
if(!(items=size()))return FALSE;
|
|
ptrNode=operator[](items-1);
|
|
Block<SmartPointer<TreeNode<T> > >::remove(items-1);
|
|
return TRUE;
|
|
}
|
|
|
|
template <class T>
|
|
inline
|
|
void InorderStack<T>::clear(void)
|
|
{
|
|
remove();
|
|
}
|
|
|
|
template <class T>
|
|
inline
|
|
DWORD InorderStack<T>::size(void)const
|
|
{
|
|
return Block<SmartPointer<TreeNode<T> > >::size();
|
|
}
|
|
#endif |