#include "MemPool.h"
+#include <stack>
+
/// \ingroup MemPoolsAPI
class MemPoolMalloc : public MemImplementingAllocator
{
virtual void *allocate();
virtual void deallocate(void *, bool aggressive);
private:
- Stack<void *> freelist;
+ std::stack<void *> freelist;
};
#endif /* _MEM_POOL_MALLOC_H_ */
#if defined(__cplusplus)
-#include "Stack.h"
+#include "fatal.h"
+
+#include <stack>
template <class V>
class SplayNode
void advance();
void addLeftPath(SplayNode<V> *aNode);
void init(SplayNode<V> *);
- Stack<SplayNode<V> *> toVisit;
+ std::stack<SplayNode<V> *> toVisit;
};
template <class V>
bool
SplayConstIterator<V>::operator == (SplayConstIterator const &right) const
{
- return toVisit.top() == right.toVisit.top();
+ if (toVisit.empty() && right.toVisit.empty())
+ return true;
+ if (!toVisit.empty() && !right.toVisit.empty())
+ return toVisit.top() == right.toVisit.top();
+ // only one of the two is empty
+ return false;
}
template <class V>
void
SplayConstIterator<V>::advance()
{
- if (toVisit.size() == 0)
+ if (toVisit.empty())
return;
toVisit.pop();
- if (toVisit.size() == 0)
+ if (toVisit.empty())
return;
- SplayNode<V> *currentNode = toVisit.pop();
+ // not empty
+ SplayNode<V> *currentNode = toVisit.top();
+ toVisit.pop();
addLeftPath(currentNode->right);
- toVisit.push_back(currentNode);
+ toVisit.push(currentNode);
}
template <class V>
return;
do {
- toVisit.push_back(aNode);
+ toVisit.push(aNode);
aNode = aNode->left;
} while (aNode != NULL);
}