Computer >> कंप्यूटर ट्यूटोरियल >  >> प्रोग्रामिंग >> C++

C++ STL में unordered_multimap rehash() फ़ंक्शन


C++ STL में unordered_multimap rehash(N) फ़ंक्शन कंटेनर में बकेट्स की संख्या को n या अधिक पर सेट करता है। यदि n कंटेनर में वर्तमान बकेट्स की संख्या से अधिक है तो एक रीहैश बाध्य होता है। नई बकेट काउंट n के बराबर या उससे अधिक हो सकती है। यदि n कंटेनर में वर्तमान बकेट्स की संख्या से कम है तो फ़ंक्शन का बकेट काउंट पर कोई प्रभाव नहीं हो सकता है और रीहैश बाध्य नहीं हो सकता है। Rehash () कुछ भी वापस नहीं करता है और n को पैरामीटर के रूप में लेता है जो कंटेनर हैश टेबल के लिए न्यूनतम बकेट्स की संख्या निर्दिष्ट करता है।

एल्गोरिथम

Begin    Declaring an empty map container m.    Force the reahash() function to restrict number of bucket in a    container to a minimum amount.    Insert the key value pairs in the container atleast same as the    minimum number of buckets.    Print the elements in the map container. End.

उदाहरण कोड

#include<iostream> #include <bits/stdc++.h> using namespace std; int main() {    unordered_map<char, int> m;    m.rehash(1);    m.insert (pair<char, int>('b', 10));    m.insert (pair<char, int>('a', 20));    cout << "The size is: " << m.size();    cout << "\nKey and values are: ";    for (auto it = m.begin(); it != m.end(); it++) {       cout << "{" << it->first << ", " << it->second << "} ";    }    return 0; }

आउटपुट

The size is: 2 Key and values are: {a, 20} {b, 10}

  1. - C++ STL में atanh() फ़ंक्शन

    atanh() फ़ंक्शन atanh() फ़ंक्शन आर्क हाइपरबोलिक टैंजेंट (व्युत्क्रम हाइपरबोलिक टैंजेंट) लौटाता है। <cmath> हेडर में परिभाषित (C++11 से)। सिंटैक्स atanh(var) पैरामीटर: var - float, double, या long double। मान -1 और 1 के बीच होना चाहिए (अनन्य)। वापसी मान आर्क हाइपरबोलिक टैंजेंट मान (रेडियन मे

  1. - C++ STL में cosh() फ़ंक्शन

    cosh() फ़ंक्शन cosh() फ़ंक्शन दिए गए कोण (रेडियन में) का हाइपरबोलिक कोसाइन लौटाता है। <cmath> हेडर में परिभाषित। सिंटैक्स cosh(var) पैरामीटर: var - float, double, या long double। वापसी मान हाइपरबोलिक कोसाइन मान, सीमा: [1, ∞)। उदाहरण 1: रेडियन इनपुट #include <iostream> #include <cm

  1. - C++ STL में sinh() फ़ंक्शन

    sinh() फ़ंक्शन sinh() फ़ंक्शन दिए गए कोण (रेडियन में) का हाइपरबोलिक साइन लौटाता है। <cmath> हेडर में परिभाषित। सिंटैक्स sinh(var) पैरामीटर: var - float, double, या long double। वापसी मान हाइपरबोलिक साइन मान, सीमा: (-∞, ∞)। उदाहरण 1: रेडियन इनपुट #include <iostream> #include <cmath