52 std::array<int, 3> min_pos, min_value;
58 min_pos[1] = ((blocJ - blocI) > 1)
60 blocI + 1, blocJ - 1)]
68 min_value[1] = (min_pos[1] != INT_MAX) ?
nodeDepth_[min_pos[1]] : INT_MAX;
82 int const sizeOfArray =
static_cast<int>(
nodeDepth_.size());
83 blocSize_ =
static_cast<int>(log2(sizeOfArray) / 2.0);
84 int const numberOfBlocs
87 for(
int i = 0; i < numberOfBlocs; i++) {
88 std::pair<int, int> range;
94 std::pair<int, int> range;
95 range.first = (numberOfBlocs - 1) *
blocSize_;
96 range.second = sizeOfArray;
102 for(
int i = 0; i < numberOfBlocs; i++) {
114 int const numberOfTables = (1 << (
blocSize_ - 1));
116 for(
int i = 0; i < numberOfTables; i++) {
123 for(
int i = 0; i < numberOfTables; i++) {
125 std::vector<bool> plusOne(
blocSize_ - 1);
128 for(
int j = 0; j < (
blocSize_ - 1); j++) {
129 remain = quotient % 2;
131 plusOne[
blocSize_ - 2 - j] =
static_cast<bool>(remain);
136 std::vector<int> normalizedBloc(
blocSize_);
137 normalizedBloc[0] = 0;
138 for(
int j = 0; j < (
blocSize_ - 1); j++) {
140 normalizedBloc[j + 1] = normalizedBloc[j] + 1;
142 normalizedBloc[j + 1] = normalizedBloc[j] - 1;
160 for(
int i = 0; i < numberOfBlocs; i++) {
166 tableId += (1 << (
blocSize_ - 2 - level));
179 if(
node_[i].getAncestorId() ==
static_cast<int>(i)) {
185 this->
printErr(
"Tree root not found.");
188 this->
printMsg(
"Rout found: node id = " + std::to_string(rootId),
191 if(!(
node_[rootId].getNumberOfSuccessors() > 0)) {
192 this->
printErr(
"Tree root found with no successor.");
203 std::stack<int> nodeStack;
207 nodeStack.push(rootId);
208 while(!nodeStack.empty()) {
209 int const nodeId = nodeStack.top();
213 if(!isVisited[nodeId]) {
215 if(nodeId != rootId) {
216 nodeStack.push(
node_[nodeId].getAncestorId());
219 int const numberOfSuccessors =
node_[nodeId].getNumberOfSuccessors();
220 for(
int i = 0; i < numberOfSuccessors; i++) {
221 nodeStack.push(
node_[nodeId].getSuccessorId(i));
224 isVisited[nodeId] =
true;
227 if(!nodeStack.empty()) {
228 if(nodeStack.top() ==
node_[nodeId].getAncestorId()) {
void setDebugMsgPrefix(const std::string &prefix)
virtual int setDebugLevel(const int &debugLevel)
int printErr(const std::string &msg, const debug::LineMode &lineMode=debug::LineMode::NEW, std::ostream &stream=std::cerr) const
std::vector< int > nodeDepth_
std::vector< int > nodeOrder_
std::vector< Node > node_
int RMQuery(const int &i, const int &j) const
std::vector< int > blocMinimumValue_
std::vector< std::pair< int, int > > blocPartition_
std::vector< int > blocMinimumPosition_
std::vector< std::vector< std::vector< int > > > normalizedBlocTable_
unsigned int min_pos_3(const std::array< int, 3 > &triplet) const
RangeMinimumQuery< int > blocMinimumValueRMQ_
unsigned int getNumberOfNodes() const
Get the number of nodes in the tree.
std::vector< int > nodeFirstAppearance_
std::vector< int > blocToNormalizedBloc_
Class to answer range minimum queries in an array in constant time after a linearithmic time preproce...
int preprocess(const bool silent=false)
int query(int i, int j) const
printMsg(debug::output::BOLD+" | | | | | . \\ | | (__| | / __/| |_| / __/| (_) |"+debug::output::ENDCOLOR, debug::Priority::PERFORMANCE, debug::LineMode::NEW, stream)