/usr/include/terralib/kernel/TeViewTreeIterator.h is in libterralib-dev 4.0.0-5ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 | /* $Id: TeViewTreeIterator.h 6480 2007-10-22 17:05:59Z juan $
** ---------------------------------------------------------------
** TeViewTreeIterator -
**
*/
#ifndef TEVIEWTREEITERATOR_H
#define TEVIEWTREEITERATOR_H
/*
** ---------------------------------------------------------------
** Includes:
*/
// TerraLib includes
#include "TeException.h"
#include "TeViewNode.h"
// STL includes
#include <vector>
#include <stack>
/*
** ---------------------------------------------------------------
** Defines:
*/
/*
One stl module included by some TerraLib files define a macro named
next which conflicts whith the TeViewTreeInterator::next method. So
we choosed to undefine it.
*/
#undef next
/*
** ---------------------------------------------------------------
** Class definition:
*/
class TL_DLL TeViewTreeIterator
{
public:
TeViewTreeIterator(TeViewTree* root);
void first();
void firstLeaf();
void next();
void nextLeaf();
void skipChildren(); //!< move to the next node skipping the current node childs
// void Previous();
bool isDone();
TeViewNode* currentNode();
int currentDepth(); //!< Returns the depth of the current node. The root has depth is 0.
protected:
private:
struct StackElem{
StackElem(TeViewTree* tr, int i){ tree = tr; ind = i; }
TeViewTree* tree;
int ind; //!< index of the current child in the tree
};
std::stack<StackElem> TravStack; //!< traversal stack
};
class TL_DLL TeViewTreeRevIterator
{
public:
TeViewTreeRevIterator(TeViewTree* root);
void first();
void firstLeaf();
void next();
void nextLeaf();
void skipChildren(); //!< move to the next node skipping the current node childs
// void Previous();
bool isDone();
TeViewNode* currentNode();
int currentDepth(); //!< Returns the depth of the current node. The root has depth is 0.
protected:
private:
struct StackElem{
StackElem(TeViewTree* tr, int i){ tree = tr; ind = i; }
StackElem(TeViewTree* tr){ tree = tr; ind = tr->size(); }
TeViewTree* tree;
int ind; //!< index of the current child in the tree
};
std::stack<StackElem> TravStack; // traversal stack
};
/*
** ---------------------------------------------------------------
** Inline methods:
*/
inline TeViewTreeIterator::TeViewTreeIterator(TeViewTree* root)
{
TravStack.push(StackElem(root, -1));
}
inline TeViewTreeRevIterator::TeViewTreeRevIterator(TeViewTree* root)
{
TravStack.push(StackElem(root));
}
inline void TeViewTreeIterator::first()
{
while(TravStack.size() > 1)
TravStack.pop();
TravStack.top().ind = -1;
}
inline void TeViewTreeRevIterator::first()
{
while(TravStack.size() > 1)
TravStack.pop();
TravStack.top().ind = TravStack.top().tree->size();
}
inline void TeViewTreeIterator::firstLeaf()
{
first();
nextLeaf();
}
inline void TeViewTreeRevIterator::firstLeaf()
{
first();
nextLeaf();
}
inline bool TeViewTreeIterator::isDone()
{
if(TravStack.size() > 1) return false;
StackElem& elem = TravStack.top();
if(elem.ind < (int)(elem.tree->size())) return false;
return true;
}
inline bool TeViewTreeRevIterator::isDone()
{
if(TravStack.size() > 1) return false;
StackElem& elem = TravStack.top();
if(elem.ind >= 0) return false;
return true;
}
inline TeViewNode* TeViewTreeIterator::currentNode()
{
StackElem& elem = TravStack.top();
if(elem.ind == -1) return elem.tree;
return elem.tree->retrieve(elem.ind);
}
inline TeViewNode* TeViewTreeRevIterator::currentNode()
{
StackElem& elem = TravStack.top();
if(elem.ind == (int)(elem.tree->size())) return elem.tree;
return elem.tree->retrieve(elem.ind);
}
inline int TeViewTreeIterator::currentDepth()
{
return TravStack.size() - 1;
}
inline int TeViewTreeRevIterator::currentDepth()
{
return TravStack.size() - 1;
}
#ifdef te__next_back__
#define next te__next_back__
#undef te__next_back__ // some stl module defines a macro named next that is generating conflics with
#endif
#endif
|