A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://www.tutorialspoint.com/cpp_standard_library/cpp_deque_operator_greater_than_or_equal_to.htm below:

C++ Deque::operator>=() Function

C++ Deque::operator>=() Function

The C++ std::deque::operator>=() function is used to compare two deques lexicographically. The comparison countinues until one deque is found to be greater than the other deque. If a deque has a elements greater than or equalto the corresponding elements of the other deque, it returns true otherwise it returns false.

Syntax

Following is the syntax for std::deque::.

bool operator>= (const deque<T,Alloc>& lhs, const deque<T,Alloc>& rhs);
Parameters Return value

It returns true if the condition holds, otherwise false.

Exceptions

This function never throws exception.

Time complexity

The time complexity of this function is Linear i.e. O(n)

Example

In the following example, we are going to consider the basic usage of operator>=() function.

#include <iostream>
#include <deque>
int main()
{
    std::deque<int> a = {10,12,23};
    std::deque<int> b = {01,12,23};
    if (a >= b) {
        std::cout << "a is greater than or equal to b." << std::endl;
    } else {
        std::cout << "a is not greater than or equal to b." << std::endl;
    }
    return 0;
}
Output

Output of the above code is as follows −

a is greater than or equal to b.
Example

Consider the following example, where we are going to compare the deque of different size.

#include <iostream>
#include <deque>
int main()
{
    std::deque<int> a = {1, 2};
    std::deque<int> b = {1, 2, 4};
    if (a >= b) {
        std::cout << "a is greater than or equal to b." << std::endl;
    } else {
        std::cout << "a is not greater than or equal to b." << std::endl;
    }
    return 0;
}
Output

Following is the output of the above code −

a is not greater than or equal to b.
Example

Let's look at the following example, where we are going to fill deque with string and compare them.

#include <iostream>
#include <deque>
#include <string>
int main()
{
    std::deque<std::string> a = {"Ducati", "Cheron"};
    std::deque<std::string> b = {"Aston", "Lexus"};
    if (a >= b) {
        std::cout << "a is greater than or equal to b." << std::endl;
    } else {
        std::cout << "a is not greater than or equal to b." << std::endl;
    }
    return 0;
}
Output

If we run the above code it will generate the following output −

a is greater than or equal to b.

deque.htm


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4