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.
SyntaxFollowing is the syntax for std::deque::.
bool operator>= (const deque<T,Alloc>& lhs, const deque<T,Alloc>& rhs);Parameters
It returns true if the condition holds, otherwise false.
ExceptionsThis function never throws exception.
Time complexityThe time complexity of this function is Linear i.e. O(n)
ExampleIn 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