Libreria C ++ Forward_list - operator> = Function

Descrizione

La funzione C ++ std::forward_list::operator>= verifica se il primo forward_list è maggiore o uguale ad altri oppure no.

Dichiarazione

Di seguito è riportata la dichiarazione per std :: forward_list :: operator> = function form std :: forward_list header.

C ++ 11

template <class T, class Alloc>
bool operator>= (const forward_list<T,Alloc>& first, const forward_list<T,Alloc>& second);

Parametri

  • first - Primo oggetto forward_list.

  • second - Secondo oggetto forward_list dello stesso tipo.

Valore di ritorno

Restituisce vero se il primo forward_list è maggiore o uguale al secondo altrimenti falso.

Eccezioni

Questa funzione membro non genera mai eccezioni.

Complessità temporale

Lineare cioè O (n)

Esempio

L'esempio seguente mostra l'utilizzo della funzione std :: forward_list :: operator> =.

#include <iostream>
#include <forward_list>

using namespace std;

int main(void) {

   forward_list<int> fl1 = {1, 2, 3, 4, 5};
   forward_list<int> fl2 = {1, 2, 3, 4, 5};

   if (fl1 >= fl2)
      cout << "First list is greater than or equal to second." << endl;

   fl2.push_front(6);

   if (!(fl1 >= fl2))
      cout << "First list is not greater than or equal to second." << endl;

   return 0;
}

Compiliamo ed eseguiamo il programma sopra, questo produrrà il seguente risultato:

First list is greater than or equal to second.
First list is not greater than or equal to second.