हाँ, std::set
भंडार इस तरह से उसके तत्वों है कि तत्वों से अधिक पुनरावृत्ति क्रमबद्ध क्रम में किया जाएगा (और std::adjacent_find
करने के लिए कॉल कि std::set
भंडार अद्वितीय आइटम के रूप में अच्छी तरह से दिखाने के लिए है)।
#include <algorithm>
#include <iterator>
#include <ios>
#include <iostream>
#include <set>
#include <string>
int main()
{
auto const ss = std::set<std::string> { "foo", "bar", "test" };
std::cout << std::boolalpha << std::is_sorted(begin(ss), end(ss)) << "\n";
std::cout << std::boolalpha << (std::adjacent_find(begin(ss), end(ss)) == end(ss)) << "\n";
std::copy(begin(ss), end(ss), std::ostream_iterator<std::string>(std::cout, "\n"));
}
Live Example
'std :: unordered_map' के संदर्भ में 'std :: set' को लागू क्यों नहीं करें, जिसमें ओ (1) सम्मिलन/लुक-अप amortized है? स्रोत के बारे में पढ़ने के लिए –
बहुत आसान है, लिंक के लिए धन्यवाद। –