Beispiel #1
0
 void pop() {
     if(left.empty()) {
         while(!right.empty()) {
             left.push(right.top());
             right.pop();
         }
     }
     left.pop();
 }
Beispiel #2
0
 int top() {
     if(left.empty()) {
         while(!right.empty()) {
             left.push(right.top());
             right.pop();
         }
     }
     return left.top();
 }
Beispiel #3
0
    int min() {
        if(left.empty())
            return right.min();
        if(right.empty())
            return left.min();

        if(left.min() < right.min())
            return left.min();
        else
            return right.min();
    }
Beispiel #4
0
    int max() {
        if(left.empty())
            return right.max();
        if(right.empty())
            return left.max();

        if(left.max() > right.max())
            return left.max();
        else
            return right.max();
    }
Beispiel #5
0
 int empty() {
     if(left.empty() && right.empty())
         return 1;
     else
         return 0;
 }