Logo Search packages:      
Sourcecode: kbruch version File versions  Download package

ratio task::product ( RatioArray::iterator &  ratio_pointer,
ShortArray::iterator &  op_pointer 
) [private]

this function is needed by solve()

this function is called by the solving function to compute a given product (or div) and return the solution

Definition at line 356 of file task.cpp.

References op_vector.

Referenced by solve().

{
#ifdef DEBUG
    kDebug() << "task::product()";
#endif
    /* the function's parameters are pointing to the next ratio;
     * to the starting point of the product */
    ratio product (ratio_pointer->numerator(), ratio_pointer->denominator());

    ++ratio_pointer;
    do {
        switch (*op_pointer) {
        case ADD :
            product = product + *ratio_pointer++;
            ++op_pointer;
            break;
        case SUB :
            product = product - *ratio_pointer++;
            ++op_pointer;
            break;
        case MUL :
            product = product * *ratio_pointer++;
            ++op_pointer;
            break;
        case DIV :
            product = product / *ratio_pointer++;
            ++op_pointer;
            break;
        }
    } while (op_pointer != op_vector.end());

    /* we get here if the product consists of the whole given task starting
     * at the point given by the function's parameters */
    return product;
}

Here is the caller graph for this function:


Generated by  Doxygen 1.6.0   Back to index