A RetroSearch Logo

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

Search Query:

Showing content from https://www.geeksforgeeks.org/cpp/unordered_multiset-end-function-in-c-stl/ below:

unordered_multiset end() function in C++ STL

unordered_multiset end() function in C++ STL

Last Updated : 02 Aug, 2018

The

unordered_multiset::end()

is a built-in function in C++ STL which returns an iterator pointing to the position immediately after the last element in the container or to the position immediately after the last element in one of its bucket.

Syntax:
unordered_multiset_name.end(n)
Parameters:

The function accepts one parameter. If a parameter is passed, it returns an iterator pointing to the position immediately after the last element in the bucket. If no parameter is passed, then it returns an iterator pointing to the position immediately after the last element in the unordered_multiset container.

Return Value:

It returns an iterator. Below programs illustrates the above function:

Program 1: CPP
// C++ program to illustrate the
// unordered_multiset::end() function
#include <bits/stdc++.h>
using namespace std;

int main()
{

    // declaration
    unordered_multiset<int> sample;

    // inserts element
    sample.insert(10);
    sample.insert(11);
    sample.insert(15);
    sample.insert(13);
    sample.insert(14);

    cout << "\nElements: ";

    // prints all element till the last
    for (auto it = sample.begin(); it != sample.end(); it++)
        cout << *it << " ";
    return 0;
}
Output:
Elements: 14 13 15 10 11
Program 2: CPP
// C++ program to illustrate the
// unordered_multiset::end() function
#include <bits/stdc++.h>
using namespace std;

int main()
{

    // declaration
    unordered_multiset<char> sample;

    // inserts element
    sample.insert('a');
    sample.insert('b');
    sample.insert('c');
    sample.insert('x');
    sample.insert('z');

    cout << "\nElements: ";

    // prints all element
    for (auto it = sample.begin(); it != sample.end(); it++)
        cout << *it << " ";
    return 0;
}
Output:
Elements: z x c a b
Program 3: CPP
// C++ program to illustrate the
// unordered_multiset::end() function
#include <bits/stdc++.h>
using namespace std;

int main()
{

    // declaration
    unordered_multiset<char> sample;

    // inserts element
    sample.insert('a');
    sample.insert('b');
    sample.insert('c');
    sample.insert('x');
    sample.insert('z');

    cout << "\nElements in first bucket: ";

    // prints all element
    for (auto it = sample.begin(1); it != sample.end(1); it++)
        cout << *it << " ";
    return 0;
}
Output:
Elements in first bucket: x c


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