void siftDown(ssize_t const start, ssize_t const end) {
            ssize_t root = start;
            while (true) {
                ssize_t const left = root * 2;
                ssize_t const right = left + 1;

                if (right <= end) {
                    if (compOp(a[root], Below, a[left])) {
                        if (compOp(a[left], Below, a[right])) {
                            std::swap(a[root], a[right]);
                            root = right;
                        } else {
                            std::swap(a[root], a[left]);
                            root = left;
                        }
                    } else {
                        if (compOp(a[root], Below, a[right])) {
                            std::swap(a[root], a[right]);
                            root = right;
                        } else {
                            return;
                        }
                    }
                } else {
                    if (left == end && compOp(a[root], Below, a[left])) {
                        std::swap(a[root], a[left]);
                    }
                    return;
                }
            }
        }
        void siftDownSingleStep(ssize_t const end, ssize_t const root) {
            ssize_t const left = root * 2;
            ssize_t const right = left + 1;

            if (right <= end) {
                ssize_t const maxChild = root * 2
                        + compOp(a[left], Below, a[right]);
                if (compOp(a[root], Below, a[maxChild])) {
                    std::swap(a[root], a[maxChild]);
                    queue[queueStoreIndex] = maxChild;
                    queueStoreIndex++;
                    prefetch(a + std::min(maxChild * 2, end));
                }
            } else {
                if (left == end && compOp(a[root], Below, a[left])) {
                    std::swap(a[root], a[left]);
                }
            }
        }
Example #3
0
//Produção Expression''
ExpressionNode* expressionDuasLinhas(ExpressionNode* cmpExprE){
       printf("Expression''\n"); 
       if (lookaheadPertenceFirst(Bool_Exp) == 1){                              
             return boolExp(cmpExprE);
       }else if (lookaheadPertenceFirst(Comp_Op) == 1){ //Comp_Op
             int compOpVar = compOp();
             ExpressionNode* compExprD = expression();
             if(compExprD == NULL) return NULL; else
             return new RelOpNode(compOpVar,cmpExprE,compExprD);
       }     
       return cmpExprE;
}