11#ifndef INCLUDED_BSLSTL_UNORDEREDSET_CPP03
12#define INCLUDED_BSLSTL_UNORDEREDSET_CPP03
63#ifdef COMPILING_BSLSTL_UNORDEREDSET_H
99 typedef KEY ValueType;
104 typedef ::BloombergLP::bslstl::UnorderedSetKeyConfiguration<ValueType>
109 typedef ::BloombergLP::bslstl::HashTable<ListConfiguration,
112 ALLOCATOR> HashTable;
116 typedef ::BloombergLP::bslalg::BidirectionalLink HashTableLink;
120 typedef BloombergLP::bslmf::MovableRefUtil MoveUtil;
123 template <
class KEY2,
128 const unordered_set<KEY2, HASH2, EQUAL2, ALLOCATOR2>&,
129 const unordered_set<KEY2, HASH2, EQUAL2, ALLOCATOR2>&);
145 typedef ::BloombergLP::bslstl::HashTableIterator<
147 typedef ::BloombergLP::bslstl::HashTableBucketIterator<
157 ::BloombergLP::bslmf::IsBitwiseMoveable,
158 ::BloombergLP::bslmf::IsBitwiseMoveable<HashTable>::value);
188 const HASH& hashFunction = HASH(),
189 const EQUAL& keyEqual = EQUAL(),
190 const ALLOCATOR& basicAllocator = ALLOCATOR());
192 const HASH& hashFunction,
193 const ALLOCATOR& basicAllocator);
195 const ALLOCATOR& basicAllocator);
217 unordered_set(BloombergLP::bslmf::MovableRef<unordered_set> original);
232 const typename type_identity<ALLOCATOR>::type& basicAllocator);
249 BloombergLP::bslmf::MovableRef<unordered_set> original,
250 const typename type_identity<ALLOCATOR>::type& basicAllocator);
283 template <
class INPUT_ITERATOR>
287 const HASH& hashFunction = HASH(),
288 const EQUAL& keyEqual = EQUAL(),
289 const ALLOCATOR& basicAllocator = ALLOCATOR());
290 template <
class INPUT_ITERATOR>
294 const HASH& hashFunction,
295 const ALLOCATOR& basicAllocator);
296 template <
class INPUT_ITERATOR>
300 const ALLOCATOR& basicAllocator);
301 template <
class INPUT_ITERATOR>
304 const ALLOCATOR& basicAllocator);
306#if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
307# ifdef BSLS_COMPILERFEATURES_SUPPORT_CTAD
309 class = bsl::enable_if_t<std::is_invocable_v<HASH, const KEY &>>,
310 class = bsl::enable_if_t<
311 std::is_invocable_v<EQUAL, const KEY &, const KEY &>>,
312 class = bsl::enable_if_t< bsl::IsStdAllocator_v<ALLOCATOR>>
316 size_type initialNumBuckets = 0,
317 const HASH& hashFunction = HASH(),
318 const EQUAL& keyEqual = EQUAL(),
319 const ALLOCATOR& basicAllocator = ALLOCATOR());
320# ifdef BSLS_COMPILERFEATURES_SUPPORT_CTAD
322 class = bsl::enable_if_t<std::is_invocable_v<HASH, const KEY &>>,
323 class = bsl::enable_if_t<bsl::IsStdAllocator<ALLOCATOR>::value>
327 size_type initialNumBuckets,
328 const HASH& hashFunction,
329 const ALLOCATOR& basicAllocator);
330# ifdef BSLS_COMPILERFEATURES_SUPPORT_CTAD
331 template <class = bsl::enable_if_t<bsl::IsStdAllocator<ALLOCATOR>::value>>
334 size_type initialNumBuckets,
335 const ALLOCATOR& basicAllocator);
336# ifdef BSLS_COMPILERFEATURES_SUPPORT_CTAD
360 template <class = bsl::enable_if_t<bsl::IsStdAllocator<ALLOCATOR>::value>>
363 const ALLOCATOR& basicAllocator);
391 template <class RANGE>
395 BSLS_COMPILERFEATURES_FORWARD_REF(RANGE) range,
396 size_type initialNumBuckets = 0,
397 const HASH& hashFunction = HASH(),
398 const EQUAL& keyEqual = EQUAL(),
399 const ALLOCATOR& basicAllocator = ALLOCATOR())
400 : d_impl(hashFunction,
408#if defined(BSLS_LIBRARYFEATURES_HAS_CPP20_CONCEPTS) \
409 && defined(BSLS_LIBRARYFEATURES_HAS_CPP20_RANGES)
410 if constexpr (ranges::sized_range<RANGE>) {
411 constructFromRange(bsl::ranges::begin(range),
412 bsl::ranges::end (range),
413 bsl::ranges::size (range));
417 constructFromRange(bsl::ranges::begin(range),
418 bsl::ranges::end (range));
422 template <
class RANGE>
427 const HASH& hashFunction,
428 const ALLOCATOR& basicAllocator)
429 : d_impl(hashFunction, EQUAL(), initialNumBuckets, 1.0f, basicAllocator)
442 template <
class RANGE>
447 const ALLOCATOR& basicAllocator)
448 : d_impl(HASH(), EQUAL(), initialNumBuckets, 1.0f, basicAllocator)
461 template <
class RANGE>
465 const ALLOCATOR& basicAllocator)
466 : d_impl(HASH(), EQUAL(), 0, 1.0f, basicAllocator)
510 operator=(BloombergLP::bslmf::MovableRef<unordered_set>
rhs)
512 AllocatorTraits::is_always_equal::value
513 && std::is_nothrow_move_assignable<HASH>::value
514 && std::is_nothrow_move_assignable<EQUAL>::value);
516#if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
576 template <class LOOKUP_KEY>
578 BloombergLP::
bslmf::IsTransparentPredicate<HASH, LOOKUP_KEY>::value
579 && BloombergLP::
bslmf::IsTransparentPredicate<EQUAL,LOOKUP_KEY>::value,
584 bool isInsertedFlag =
false;
585 HashTableLink *result =
586 d_impl.insertIfMissingTransparent(
589 return ResultType(
iterator(result), isInsertedFlag);
625 BloombergLP::bslmf::MovableRef<value_type> value);
630 template <
class LOOKUP_KEY>
632 BloombergLP::bslmf::IsTransparentPredicate<HASH, LOOKUP_KEY>::value
633 && BloombergLP::bslmf::IsTransparentPredicate<EQUAL,LOOKUP_KEY>::value
659 template <
class INPUT_ITERATOR>
660 void insert(INPUT_ITERATOR first, INPUT_ITERATOR last);
662#if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
668 void insert(std::initializer_list<KEY> values);
681 template <
class RANGE>
687#if defined(BSLS_LIBRARYFEATURES_HAS_CPP20_CONCEPTS) \
688&& defined(BSLS_LIBRARYFEATURES_HAS_CPP20_RANGES)
689 if constexpr (ranges::sized_range<RANGE>) {
690 insertFromRange(bsl::ranges::begin(range),
691 bsl::ranges::end (range),
692 bsl::ranges::size (range));
696 insertFromRange(bsl::ranges::begin(range),
697 bsl::ranges::end (range));
701#if BSLS_COMPILERFEATURES_SIMULATE_VARIADIC_TEMPLATES
704#ifndef BSLSTL_UNORDEREDSET_VARIADIC_LIMIT
705#define BSLSTL_UNORDEREDSET_VARIADIC_LIMIT 10
707#ifndef BSLSTL_UNORDEREDSET_VARIADIC_LIMIT_C
708#define BSLSTL_UNORDEREDSET_VARIADIC_LIMIT_C BSLSTL_UNORDEREDSET_VARIADIC_LIMIT
710#if BSLSTL_UNORDEREDSET_VARIADIC_LIMIT_C >= 0
715#if BSLSTL_UNORDEREDSET_VARIADIC_LIMIT_C >= 1
716 template <
class Args_01>
721#if BSLSTL_UNORDEREDSET_VARIADIC_LIMIT_C >= 2
722 template <
class Args_01,
729#if BSLSTL_UNORDEREDSET_VARIADIC_LIMIT_C >= 3
730 template <
class Args_01,
739#if BSLSTL_UNORDEREDSET_VARIADIC_LIMIT_C >= 4
740 template <
class Args_01,
751#if BSLSTL_UNORDEREDSET_VARIADIC_LIMIT_C >= 5
752 template <
class Args_01,
765#if BSLSTL_UNORDEREDSET_VARIADIC_LIMIT_C >= 6
766 template <
class Args_01,
781#if BSLSTL_UNORDEREDSET_VARIADIC_LIMIT_C >= 7
782 template <
class Args_01,
799#if BSLSTL_UNORDEREDSET_VARIADIC_LIMIT_C >= 8
800 template <
class Args_01,
819#if BSLSTL_UNORDEREDSET_VARIADIC_LIMIT_C >= 9
820 template <
class Args_01,
841#if BSLSTL_UNORDEREDSET_VARIADIC_LIMIT_C >= 10
842 template <
class Args_01,
866#if BSLSTL_UNORDEREDSET_VARIADIC_LIMIT_C >= 0
870#if BSLSTL_UNORDEREDSET_VARIADIC_LIMIT_C >= 1
871 template <
class Args_01>
876#if BSLSTL_UNORDEREDSET_VARIADIC_LIMIT_C >= 2
877 template <
class Args_01,
884#if BSLSTL_UNORDEREDSET_VARIADIC_LIMIT_C >= 3
885 template <
class Args_01,
894#if BSLSTL_UNORDEREDSET_VARIADIC_LIMIT_C >= 4
895 template <
class Args_01,
906#if BSLSTL_UNORDEREDSET_VARIADIC_LIMIT_C >= 5
907 template <
class Args_01,
920#if BSLSTL_UNORDEREDSET_VARIADIC_LIMIT_C >= 6
921 template <
class Args_01,
936#if BSLSTL_UNORDEREDSET_VARIADIC_LIMIT_C >= 7
937 template <
class Args_01,
954#if BSLSTL_UNORDEREDSET_VARIADIC_LIMIT_C >= 8
955 template <
class Args_01,
974#if BSLSTL_UNORDEREDSET_VARIADIC_LIMIT_C >= 9
975 template <
class Args_01,
996#if BSLSTL_UNORDEREDSET_VARIADIC_LIMIT_C >= 10
997 template <
class Args_01,
1023 template <
class... Args>
1027 template <
class... Args>
1055 template <
class t_KEY>
1057 BloombergLP::bslmf::IsTransparentPredicate<HASH, t_KEY>::value &&
1058 BloombergLP::bslmf::IsTransparentPredicate<EQUAL,t_KEY>::value &&
1101 AllocatorTraits::is_always_equal::value
1102 && bsl::is_nothrow_swappable<HASH>::value
1103 && bsl::is_nothrow_swappable<EQUAL>::value);
1119 template <class LOOKUP_KEY>
1121 BloombergLP::
bslmf::IsTransparentPredicate<HASH, LOOKUP_KEY>::value
1122 && BloombergLP::
bslmf::IsTransparentPredicate<EQUAL,LOOKUP_KEY>::value,
1124 find(const LOOKUP_KEY& key)
1149 template <
class LOOKUP_KEY>
1151 BloombergLP::bslmf::IsTransparentPredicate<HASH, LOOKUP_KEY>::value
1152 && BloombergLP::bslmf::IsTransparentPredicate<EQUAL,LOOKUP_KEY>::value,
1153 pair<iterator, iterator> >::type
1158 HashTableLink *first = d_impl.find(key);
1205 template <
class INPUT_ITERATOR,
class SENTINEL>
1206 void constructFromRange(INPUT_ITERATOR first, SENTINEL last);
1208#if defined(BSLS_LIBRARYFEATURES_HAS_CPP20_CONCEPTS) \
1209 && defined(BSLS_LIBRARYFEATURES_HAS_CPP20_RANGES)
1217 template <
class INPUT_ITERATOR,
class SENTINEL>
1218 void constructFromRange(INPUT_ITERATOR first,
1220 size_t numElements);
1225 template <
class INPUT_ITERATOR,
class SENTINEL>
1226 void insertFromRange(INPUT_ITERATOR first, SENTINEL last);
1228#if defined(BSLS_LIBRARYFEATURES_HAS_CPP20_CONCEPTS) \
1229 && defined(BSLS_LIBRARYFEATURES_HAS_CPP20_RANGES)
1236 template <
class INPUT_ITERATOR,
class SENTINEL>
1237 void insertFromRange(INPUT_ITERATOR first,
1239 size_t numElements);
1277 template <class LOOKUP_KEY>
1279 BloombergLP::
bslmf::IsTransparentPredicate<HASH, LOOKUP_KEY>::value &&
1280 BloombergLP::
bslmf::IsTransparentPredicate<EQUAL,
1283 contains(const LOOKUP_KEY& key)
const
1319 template <class LOOKUP_KEY>
1321 BloombergLP::
bslmf::IsTransparentPredicate<HASH, LOOKUP_KEY>::value
1322 && BloombergLP::
bslmf::IsTransparentPredicate<EQUAL,LOOKUP_KEY>::value,
1324 find(const LOOKUP_KEY& key)
const
1344 template <
class LOOKUP_KEY>
1346 BloombergLP::bslmf::IsTransparentPredicate<HASH, LOOKUP_KEY>::value
1347 && BloombergLP::bslmf::IsTransparentPredicate<EQUAL,LOOKUP_KEY>::value,
1349 count(
const LOOKUP_KEY& key)
const
1351 return d_impl.find(key) != 0;
1375 template <
class LOOKUP_KEY>
1377 BloombergLP::bslmf::IsTransparentPredicate<HASH, LOOKUP_KEY>::value
1378 && BloombergLP::bslmf::IsTransparentPredicate<EQUAL,LOOKUP_KEY>::value,
1379 pair<const_iterator, const_iterator> >::type
1384 HashTableLink *first = d_impl.find(key);
1429 template <class LOOKUP_KEY>
1431 BloombergLP::
bslmf::IsTransparentPredicate<HASH, LOOKUP_KEY>::value
1432 && BloombergLP::
bslmf::IsTransparentPredicate<EQUAL,LOOKUP_KEY>::value,
1434 bucket(const LOOKUP_KEY& key)
const
1436 return d_impl.bucketIndexForKey(key);
1477#ifdef BSLS_COMPILERFEATURES_SUPPORT_CTAD
1488 class INPUT_ITERATOR,
1489 class KEY = BloombergLP::bslstl::IteratorUtil::IterVal_t<INPUT_ITERATOR>,
1493 class = bsl::enable_if_t<std::is_invocable_v<HASH, const KEY&>>,
1494 class = bsl::enable_if_t<
1495 std::is_invocable_v<EQUAL, const KEY&, const KEY&>>,
1496 class = bsl::enable_if_t< bsl::IsStdAllocator_v<ALLOCATOR>>
1500 typename bsl::allocator_traits<ALLOCATOR>::size_type = 0,
1503 ALLOCATOR = ALLOCATOR())
1512 class INPUT_ITERATOR,
1513 class KEY = BloombergLP::bslstl::IteratorUtil::IterVal_t<INPUT_ITERATOR>,
1517 class DEFAULT_ALLOCATOR = bsl::allocator<KEY>,
1518 class = bsl::enable_if_t<bsl::is_convertible_v<ALLOC *, DEFAULT_ALLOCATOR>>
1522 typename bsl::allocator_traits<DEFAULT_ALLOCATOR>::size_type,
1535 class INPUT_ITERATOR,
1536 class KEY = BloombergLP::bslstl::IteratorUtil::IterVal_t<INPUT_ITERATOR>,
1539 class = bsl::enable_if_t<std::is_invocable_v<HASH, const KEY &>>,
1540 class = bsl::enable_if_t< bsl::IsStdAllocator_v<ALLOCATOR>>
1544 typename bsl::allocator_traits<ALLOCATOR>::size_type,
1555 class INPUT_ITERATOR,
1556 class KEY = BloombergLP::bslstl::IteratorUtil::IterVal_t<INPUT_ITERATOR>,
1559 class DEFAULT_ALLOCATOR = bsl::allocator<KEY>,
1560 class = bsl::enable_if_t<bsl::is_convertible_v<ALLOC *, DEFAULT_ALLOCATOR>>
1564 typename bsl::allocator_traits<DEFAULT_ALLOCATOR>::size_type,
1574 class INPUT_ITERATOR,
1576 class KEY = BloombergLP::bslstl::IteratorUtil::IterVal_t<INPUT_ITERATOR>,
1577 class = bsl::enable_if_t<bsl::IsStdAllocator_v<ALLOCATOR>>
1581 typename bsl::allocator_traits<ALLOCATOR>::size_type,
1583->
unordered_set<KEY, bsl::hash<KEY>, bsl::equal_to<KEY>, ALLOCATOR>;
1590 class INPUT_ITERATOR,
1591 class KEY = BloombergLP::bslstl::IteratorUtil::IterVal_t<INPUT_ITERATOR>,
1593 class DEFAULT_ALLOCATOR = bsl::allocator<KEY>,
1594 class = bsl::enable_if_t<bsl::is_convertible_v<ALLOC *, DEFAULT_ALLOCATOR>>
1598 typename bsl::allocator_traits<DEFAULT_ALLOCATOR>::size_type,
1607 class INPUT_ITERATOR,
1609 class KEY = BloombergLP::bslstl::IteratorUtil::IterVal_t<INPUT_ITERATOR>,
1610 class = bsl::enable_if_t<bsl::IsStdAllocator_v<ALLOCATOR>>
1613->
unordered_set<KEY, bsl::hash<KEY>, bsl::equal_to<KEY>, ALLOCATOR>;
1620 class INPUT_ITERATOR,
1621 class KEY = BloombergLP::bslstl::IteratorUtil::IterVal_t<INPUT_ITERATOR>,
1623 class DEFAULT_ALLOCATOR = bsl::allocator<KEY>,
1624 class = bsl::enable_if_t<bsl::is_convertible_v<ALLOC *, DEFAULT_ALLOCATOR>>
1638 class HASH = bsl::hash<KEY>,
1639 class EQUAL = bsl::equal_to<KEY>,
1640 class ALLOCATOR = bsl::allocator<KEY>,
1641 class = bsl::enable_if_t<std::is_invocable_v<HASH, const KEY&>>,
1642 class = bsl::enable_if_t<
1643 std::is_invocable_v<EQUAL, const KEY&, const KEY&>>,
1644 class = bsl::enable_if_t< bsl::IsStdAllocator_v<ALLOCATOR>>
1647 typename bsl::allocator_traits<ALLOCATOR>::size_type = 0,
1650 ALLOCATOR = ALLOCATOR())
1663 class DEFAULT_ALLOCATOR = bsl::allocator<KEY>,
1664 class = bsl::enable_if_t<bsl::is_convertible_v<ALLOC *, DEFAULT_ALLOCATOR>>
1667 typename bsl::allocator_traits<DEFAULT_ALLOCATOR>::size_type,
1683 class = bsl::enable_if_t<std::is_invocable_v<HASH, const KEY &>>,
1684 class = bsl::enable_if_t< bsl::IsStdAllocator_v<ALLOCATOR>>
1687 typename bsl::allocator_traits<ALLOCATOR>::size_type,
1701 class DEFAULT_ALLOCATOR = bsl::allocator<KEY>,
1702 class = bsl::enable_if_t<bsl::is_convertible_v<ALLOC *, DEFAULT_ALLOCATOR>>
1705 typename bsl::allocator_traits<DEFAULT_ALLOCATOR>::size_type,
1717 class = bsl::enable_if_t<bsl::IsStdAllocator_v<ALLOCATOR>>
1720 typename bsl::allocator_traits<ALLOCATOR>::size_type,
1722->
unordered_set<KEY, bsl::hash<KEY>, bsl::equal_to<KEY>, ALLOCATOR>;
1731 class DEFAULT_ALLOCATOR = bsl::allocator<KEY>,
1732 class = bsl::enable_if_t<bsl::is_convertible_v<ALLOC *, DEFAULT_ALLOCATOR>>
1735 typename bsl::allocator_traits<DEFAULT_ALLOCATOR>::size_type,
1746 class = bsl::enable_if_t<bsl::IsStdAllocator_v<ALLOCATOR>>
1749->
unordered_set<KEY, bsl::hash<KEY>, bsl::equal_to<KEY>, ALLOCATOR>;
1758 class DEFAULT_ALLOCATOR = bsl::allocator<KEY>,
1759 class = bsl::enable_if_t<bsl::is_convertible_v<ALLOC *, DEFAULT_ALLOCATOR>>
1775template <class KEY, class HASH, class EQUAL, class ALLOCATOR>
1776bool operator==(const unordered_set<KEY, HASH, EQUAL, ALLOCATOR>& lhs,
1777 const unordered_set<KEY, HASH, EQUAL, ALLOCATOR>& rhs);
1779#ifndef BSLS_COMPILERFEATURES_SUPPORT_THREE_WAY_COMPARISON
1780template <class KEY, class HASH, class EQUAL, class ALLOCATOR>
1781bool operator!=(const unordered_set<KEY, HASH, EQUAL, ALLOCATOR>& lhs,
1782 const unordered_set<KEY, HASH, EQUAL, ALLOCATOR>& rhs);
1797template <class KEY, class HASH, class EQUAL, class ALLOCATOR, class PREDICATE>
1799erase_if(unordered_set<KEY, HASH, EQUAL, ALLOCATOR>& s, PREDICATE predicate);
1801template <class KEY, class HASH, class EQUAL, class ALLOCATOR>
1802void
swap(unordered_set<KEY, HASH, EQUAL, ALLOCATOR>& a,
1803 unordered_set<KEY, HASH, EQUAL, ALLOCATOR>& b)
1805 BSLS_KEYWORD_NOEXCEPT_OPERATOR(a.swap(b)));
1828template <class KEY, class HASH, class EQUAL, class ALLOCATOR>
1829template <class INPUT_ITERATOR, class SENTINEL>
1831void
unordered_set<KEY, HASH, EQUAL, ALLOCATOR>::constructFromRange(
1832 INPUT_ITERATOR first,
1842 if (first == last) {
1847 BloombergLP::bslstl::IteratorUtil::
1848 canCalculateInsertDistance<INPUT_ITERATOR,SENTINEL>()) {
1850 BloombergLP::bslstl::IteratorUtil::insertDistance(first, last));
1853 bool isInsertedFlag;
1855 while (first != last) {
1856 d_impl.insertIfMissing(&isInsertedFlag, *first);
1861#if defined(BSLS_LIBRARYFEATURES_HAS_CPP20_CONCEPTS) \
1862 && defined(BSLS_LIBRARYFEATURES_HAS_CPP20_RANGES)
1864template <
class KEY,
class HASH,
class EQUAL,
class ALLOCATOR>
1865template <
class INPUT_ITERATOR,
class SENTINEL>
1867void unordered_set<KEY, HASH, EQUAL, ALLOCATOR>::constructFromRange(
1868 INPUT_ITERATOR first,
1873 !BloombergLP::bslstl::IteratorUtil
1874 ::canCalculateInsertDistance<INPUT_ITERATOR, SENTINEL>()
1875 || numElements ==
static_cast<size_t>(
1876 BloombergLP::bslstl::IteratorUtil::insertDistance(first, last))));
1879 if (0 < numElements) {
1883 bool isInsertedFlag;
1885 while (first != last) {
1886 d_impl.insertIfMissing(&isInsertedFlag, *first);
1893template <
class KEY,
class HASH,
class EQUAL,
class ALLOCATOR>
1894template <
class INPUT_ITERATOR,
class SENTINEL>
1896void unordered_set<KEY, HASH, EQUAL, ALLOCATOR>::insertFromRange(
1897 INPUT_ITERATOR first,
1908 ::canCalculateInsertDistance<INPUT_ITERATOR, SENTINEL>()) {
1910 + BloombergLP::bslstl::IteratorUtil::insertDistance(first, last));
1913 bool isInsertedFlag;
1915 while (first != last) {
1916 d_impl.insertIfMissing(&isInsertedFlag, *first);
1921#if defined(BSLS_LIBRARYFEATURES_HAS_CPP20_CONCEPTS) \
1922 && defined(BSLS_LIBRARYFEATURES_HAS_CPP20_RANGES)
1924template <
class KEY,
class HASH,
class EQUAL,
class ALLOCATOR>
1925template <
class INPUT_ITERATOR,
class SENTINEL>
1927void unordered_set<KEY, HASH, EQUAL, ALLOCATOR>::insertFromRange(
1928 INPUT_ITERATOR first,
1933 !BloombergLP::bslstl::IteratorUtil
1934 ::canCalculateInsertDistance<INPUT_ITERATOR, SENTINEL>()
1935 || numElements ==
static_cast<size_t>(
1936 BloombergLP::bslstl::IteratorUtil::insertDistance(first, last))));
1940 bool isInsertedFlag;
1942 while (first != last) {
1943 d_impl.insertIfMissing(&isInsertedFlag, *first);
1951template <
class KEY,
class HASH,
class EQUAL,
class ALLOCATOR>
1954: d_impl(HASH(), EQUAL(), 0, 1.0f, ALLOCATOR())
1958template <
class KEY,
class HASH,
class EQUAL,
class ALLOCATOR>
1960unordered_set<KEY, HASH, EQUAL, ALLOCATOR>::unordered_set(
1961 size_type initialNumBuckets,
1962 const HASH& hashFunction,
1963 const EQUAL& keyEqual,
1964 const ALLOCATOR& basicAllocator)
1965: d_impl(hashFunction, keyEqual, initialNumBuckets, 1.0f, basicAllocator)
1969template <
class KEY,
class HASH,
class EQUAL,
class ALLOCATOR>
1971unordered_set<KEY, HASH, EQUAL, ALLOCATOR>::unordered_set(
1972 size_type initialNumBuckets,
1973 const HASH& hashFunction,
1974 const ALLOCATOR& basicAllocator)
1975: d_impl(hashFunction, EQUAL(), initialNumBuckets, 1.0f, basicAllocator)
1979template <
class KEY,
class HASH,
class EQUAL,
class ALLOCATOR>
1981unordered_set<KEY, HASH, EQUAL, ALLOCATOR>::unordered_set(
1982 size_type initialNumBuckets,
1983 const ALLOCATOR& basicAllocator)
1984: d_impl(HASH(), EQUAL(), initialNumBuckets, 1.0f, basicAllocator)
1988template <
class KEY,
class HASH,
class EQUAL,
class ALLOCATOR>
1990unordered_set<KEY, HASH, EQUAL, ALLOCATOR>::unordered_set(
1991 const ALLOCATOR& basicAllocator)
1992: d_impl(basicAllocator)
1996template <
class KEY,
class HASH,
class EQUAL,
class ALLOCATOR>
1998unordered_set<KEY, HASH, EQUAL, ALLOCATOR>::unordered_set(
1999 const unordered_set& original)
2000: d_impl(original.d_impl,
2001 AllocatorTraits::select_on_container_copy_construction(
2002 original.get_allocator()))
2006template <
class KEY,
class HASH,
class EQUAL,
class ALLOCATOR>
2008unordered_set<KEY, HASH, EQUAL, ALLOCATOR>::unordered_set(
2009 BloombergLP::bslmf::MovableRef<unordered_set> original)
2010: d_impl(MoveUtil::move(MoveUtil::access(original).d_impl))
2014template <
class KEY,
class HASH,
class EQUAL,
class ALLOCATOR>
2016unordered_set<KEY, HASH, EQUAL, ALLOCATOR>::unordered_set(
2017 const unordered_set& original,
2018 const typename type_identity<ALLOCATOR>::type& basicAllocator)
2019: d_impl(original.d_impl, basicAllocator)
2023template <
class KEY,
class HASH,
class EQUAL,
class ALLOCATOR>
2025unordered_set<KEY, HASH, EQUAL, ALLOCATOR>::unordered_set(
2026 BloombergLP::bslmf::MovableRef<unordered_set> original,
2027 const typename type_identity<ALLOCATOR>::type& basicAllocator)
2028: d_impl(MoveUtil::move(MoveUtil::access(original).d_impl), basicAllocator)
2032template <
class KEY,
class HASH,
class EQUAL,
class ALLOCATOR>
2033template <
class INPUT_ITERATOR>
2035unordered_set<KEY, HASH, EQUAL, ALLOCATOR>::unordered_set(
2036 INPUT_ITERATOR first,
2037 INPUT_ITERATOR last,
2038 size_type initialNumBuckets,
2039 const HASH& hashFunction,
2040 const EQUAL& keyEqual,
2041 const ALLOCATOR& basicAllocator)
2042: d_impl(hashFunction, keyEqual, initialNumBuckets, 1.0f, basicAllocator)
2044 constructFromRange(first, last);
2047template <
class KEY,
class HASH,
class EQUAL,
class ALLOCATOR>
2048template <
class INPUT_ITERATOR>
2050unordered_set<KEY, HASH, EQUAL, ALLOCATOR>::unordered_set(
2051 INPUT_ITERATOR first,
2052 INPUT_ITERATOR last,
2053 size_type initialNumBuckets,
2054 const HASH& hashFunction,
2055 const ALLOCATOR& basicAllocator)
2056: d_impl(hashFunction, EQUAL(), initialNumBuckets, 1.0f, basicAllocator)
2058 constructFromRange(first, last);
2061template <
class KEY,
class HASH,
class EQUAL,
class ALLOCATOR>
2062template <
class INPUT_ITERATOR>
2064unordered_set<KEY, HASH, EQUAL, ALLOCATOR>::unordered_set(
2065 INPUT_ITERATOR first,
2066 INPUT_ITERATOR last,
2067 size_type initialNumBuckets,
2068 const ALLOCATOR& basicAllocator)
2069: d_impl(HASH(), EQUAL(), initialNumBuckets, 1.0f, basicAllocator)
2071 constructFromRange(first, last);
2074template <
class KEY,
class HASH,
class EQUAL,
class ALLOCATOR>
2075template <
class INPUT_ITERATOR>
2077unordered_set<KEY, HASH, EQUAL, ALLOCATOR>::unordered_set(
2078 INPUT_ITERATOR first,
2079 INPUT_ITERATOR last,
2080 const ALLOCATOR& basicAllocator)
2081: d_impl(HASH(), EQUAL(), 0, 1.0f, basicAllocator)
2083 constructFromRange(first, last);
2086#if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
2087template <
class KEY,
class HASH,
class EQUAL,
class ALLOCATOR>
2088#ifdef BSLS_COMPILERFEATURES_SUPPORT_CTAD
2089template <
class,
class,
class>
2092unordered_set<KEY, HASH, EQUAL, ALLOCATOR>::unordered_set(
2093 std::initializer_list<KEY> values,
2094 size_type initialNumBuckets,
2095 const hasher& hashFunction,
2096 const key_equal& keyEqual,
2097 const ALLOCATOR& basicAllocator)
2098: unordered_set(values.
begin(), values.
end(), initialNumBuckets,
2099 hashFunction, keyEqual, basicAllocator)
2103template <
class KEY,
class HASH,
class EQUAL,
class ALLOCATOR>
2104#ifdef BSLS_COMPILERFEATURES_SUPPORT_CTAD
2105template <
class,
class>
2108unordered_set<KEY, HASH, EQUAL, ALLOCATOR>::unordered_set(
2109 std::initializer_list<KEY> values,
2110 size_type initialNumBuckets,
2111 const HASH& hashFunction,
2112 const ALLOCATOR& basicAllocator)
2113: unordered_set(values.
begin(),
2122template <
class KEY,
class HASH,
class EQUAL,
class ALLOCATOR>
2123#ifdef BSLS_COMPILERFEATURES_SUPPORT_CTAD
2127unordered_set<KEY, HASH, EQUAL, ALLOCATOR>::unordered_set(
2128 std::initializer_list<KEY> values,
2129 size_type initialNumBuckets,
2130 const ALLOCATOR& basicAllocator)
2131: unordered_set(values.
begin(),
2140template <
class KEY,
class HASH,
class EQUAL,
class ALLOCATOR>
2141#ifdef BSLS_COMPILERFEATURES_SUPPORT_CTAD
2145unordered_set<KEY, HASH, EQUAL, ALLOCATOR>::unordered_set(
2146 std::initializer_list<KEY> values,
2147 const ALLOCATOR& basicAllocator)
2148: unordered_set(values.
begin(),
2159template <
class KEY,
class HASH,
class EQUAL,
class ALLOCATOR>
2161unordered_set<KEY, HASH, EQUAL, ALLOCATOR>::~unordered_set()
2167template <
class KEY,
class HASH,
class EQUAL,
class ALLOCATOR>
2169unordered_set<KEY, HASH, EQUAL, ALLOCATOR>&
2170unordered_set<KEY, HASH, EQUAL, ALLOCATOR>::operator=(
const unordered_set& rhs)
2175 d_impl =
rhs.d_impl;
2180template <
class KEY,
class HASH,
class EQUAL,
class ALLOCATOR>
2182unordered_set<KEY, HASH, EQUAL, ALLOCATOR>&
2183unordered_set<KEY, HASH, EQUAL, ALLOCATOR>::operator=(
2184 BloombergLP::bslmf::MovableRef<unordered_set> rhs)
2186 AllocatorTraits::is_always_equal::value
2187 && std::is_nothrow_move_assignable<HASH>::value
2188 && std::is_nothrow_move_assignable<EQUAL>::value)
2193 unordered_set& lvalue =
rhs;
2195 d_impl = MoveUtil::move(lvalue.d_impl);
2200#if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
2201template <
class KEY,
class HASH,
class EQUAL,
class ALLOCATOR>
2203unordered_set<KEY, HASH, EQUAL, ALLOCATOR>&
2204unordered_set<KEY, HASH, EQUAL, ALLOCATOR>::operator=(
2205 std::initializer_list<KEY> values)
2207 unordered_set tmp(values, d_impl.allocator());
2209 d_impl.swap(tmp.d_impl);
2215template <
class KEY,
class HASH,
class EQUAL,
class ALLOCATOR>
2217typename unordered_set<KEY, HASH, EQUAL, ALLOCATOR>::iterator
2220 return iterator(d_impl.elementListRoot());
2223template <
class KEY,
class HASH,
class EQUAL,
class ALLOCATOR>
2225typename unordered_set<KEY, HASH, EQUAL, ALLOCATOR>::iterator
2231template <
class KEY,
class HASH,
class EQUAL,
class ALLOCATOR>
2233typename unordered_set<KEY, HASH, EQUAL, ALLOCATOR>::local_iterator
2234unordered_set<KEY, HASH, EQUAL, ALLOCATOR>::begin(size_type index)
2238 return local_iterator(&d_impl.bucketAtIndex(index));
2241template <
class KEY,
class HASH,
class EQUAL,
class ALLOCATOR>
2243typename unordered_set<KEY, HASH, EQUAL, ALLOCATOR>::local_iterator
2244unordered_set<KEY, HASH, EQUAL, ALLOCATOR>::end(size_type index)
2248 return local_iterator(0, &d_impl.bucketAtIndex(index));
2251template <
class KEY,
class HASH,
class EQUAL,
class ALLOCATOR>
2258#if BSLS_COMPILERFEATURES_SIMULATE_VARIADIC_TEMPLATES
2261#ifndef BSLSTL_UNORDEREDSET_VARIADIC_LIMIT
2262#define BSLSTL_UNORDEREDSET_VARIADIC_LIMIT 10
2264#ifndef BSLSTL_UNORDEREDSET_VARIADIC_LIMIT_D
2265#define BSLSTL_UNORDEREDSET_VARIADIC_LIMIT_D BSLSTL_UNORDEREDSET_VARIADIC_LIMIT
2267#if BSLSTL_UNORDEREDSET_VARIADIC_LIMIT_D >= 0
2268template <
class KEY,
class HASH,
class EQUAL,
class ALLOCATOR>
2270pair<typename unordered_set<KEY, HASH, EQUAL, ALLOCATOR>::iterator,
bool>
2271unordered_set<KEY, HASH, EQUAL, ALLOCATOR>::emplace(
2276 bool isInsertedFlag =
false;
2278 HashTableLink *result = d_impl.emplaceIfMissing(
2281 return ResultType(iterator(result), isInsertedFlag);
2285#if BSLSTL_UNORDEREDSET_VARIADIC_LIMIT_D >= 1
2286template <
class KEY,
class HASH,
class EQUAL,
class ALLOCATOR>
2287template <
class Args_01>
2289pair<typename unordered_set<KEY, HASH, EQUAL, ALLOCATOR>::iterator,
bool>
2290unordered_set<KEY, HASH, EQUAL, ALLOCATOR>::emplace(
2295 bool isInsertedFlag =
false;
2297 HashTableLink *result = d_impl.emplaceIfMissing(
2301 return ResultType(iterator(result), isInsertedFlag);
2305#if BSLSTL_UNORDEREDSET_VARIADIC_LIMIT_D >= 2
2306template <
class KEY,
class HASH,
class EQUAL,
class ALLOCATOR>
2307template <
class Args_01,
2310pair<typename unordered_set<KEY, HASH, EQUAL, ALLOCATOR>::iterator,
bool>
2311unordered_set<KEY, HASH, EQUAL, ALLOCATOR>::emplace(
2317 bool isInsertedFlag =
false;
2319 HashTableLink *result = d_impl.emplaceIfMissing(
2324 return ResultType(iterator(result), isInsertedFlag);
2328#if BSLSTL_UNORDEREDSET_VARIADIC_LIMIT_D >= 3
2329template <
class KEY,
class HASH,
class EQUAL,
class ALLOCATOR>
2330template <
class Args_01,
2334pair<typename unordered_set<KEY, HASH, EQUAL, ALLOCATOR>::iterator,
bool>
2335unordered_set<KEY, HASH, EQUAL, ALLOCATOR>::emplace(
2342 bool isInsertedFlag =
false;
2344 HashTableLink *result = d_impl.emplaceIfMissing(
2350 return ResultType(iterator(result), isInsertedFlag);
2354#if BSLSTL_UNORDEREDSET_VARIADIC_LIMIT_D >= 4
2355template <
class KEY,
class HASH,
class EQUAL,
class ALLOCATOR>
2356template <
class Args_01,
2361pair<typename unordered_set<KEY, HASH, EQUAL, ALLOCATOR>::iterator,
bool>
2362unordered_set<KEY, HASH, EQUAL, ALLOCATOR>::emplace(
2370 bool isInsertedFlag =
false;
2372 HashTableLink *result = d_impl.emplaceIfMissing(
2379 return ResultType(iterator(result), isInsertedFlag);
2383#if BSLSTL_UNORDEREDSET_VARIADIC_LIMIT_D >= 5
2384template <
class KEY,
class HASH,
class EQUAL,
class ALLOCATOR>
2385template <
class Args_01,
2391pair<typename unordered_set<KEY, HASH, EQUAL, ALLOCATOR>::iterator,
bool>
2392unordered_set<KEY, HASH, EQUAL, ALLOCATOR>::emplace(
2401 bool isInsertedFlag =
false;
2403 HashTableLink *result = d_impl.emplaceIfMissing(
2411 return ResultType(iterator(result), isInsertedFlag);
2415#if BSLSTL_UNORDEREDSET_VARIADIC_LIMIT_D >= 6
2416template <
class KEY,
class HASH,
class EQUAL,
class ALLOCATOR>
2417template <
class Args_01,
2424pair<typename unordered_set<KEY, HASH, EQUAL, ALLOCATOR>::iterator,
bool>
2425unordered_set<KEY, HASH, EQUAL, ALLOCATOR>::emplace(
2435 bool isInsertedFlag =
false;
2437 HashTableLink *result = d_impl.emplaceIfMissing(
2446 return ResultType(iterator(result), isInsertedFlag);
2450#if BSLSTL_UNORDEREDSET_VARIADIC_LIMIT_D >= 7
2451template <
class KEY,
class HASH,
class EQUAL,
class ALLOCATOR>
2452template <
class Args_01,
2460pair<typename unordered_set<KEY, HASH, EQUAL, ALLOCATOR>::iterator,
bool>
2461unordered_set<KEY, HASH, EQUAL, ALLOCATOR>::emplace(
2472 bool isInsertedFlag =
false;
2474 HashTableLink *result = d_impl.emplaceIfMissing(
2484 return ResultType(iterator(result), isInsertedFlag);
2488#if BSLSTL_UNORDEREDSET_VARIADIC_LIMIT_D >= 8
2489template <
class KEY,
class HASH,
class EQUAL,
class ALLOCATOR>
2490template <
class Args_01,
2499pair<typename unordered_set<KEY, HASH, EQUAL, ALLOCATOR>::iterator,
bool>
2500unordered_set<KEY, HASH, EQUAL, ALLOCATOR>::emplace(
2512 bool isInsertedFlag =
false;
2514 HashTableLink *result = d_impl.emplaceIfMissing(
2525 return ResultType(iterator(result), isInsertedFlag);
2529#if BSLSTL_UNORDEREDSET_VARIADIC_LIMIT_D >= 9
2530template <
class KEY,
class HASH,
class EQUAL,
class ALLOCATOR>
2531template <
class Args_01,
2541pair<typename unordered_set<KEY, HASH, EQUAL, ALLOCATOR>::iterator,
bool>
2542unordered_set<KEY, HASH, EQUAL, ALLOCATOR>::emplace(
2555 bool isInsertedFlag =
false;
2557 HashTableLink *result = d_impl.emplaceIfMissing(
2569 return ResultType(iterator(result), isInsertedFlag);
2573#if BSLSTL_UNORDEREDSET_VARIADIC_LIMIT_D >= 10
2574template <
class KEY,
class HASH,
class EQUAL,
class ALLOCATOR>
2575template <
class Args_01,
2586pair<typename unordered_set<KEY, HASH, EQUAL, ALLOCATOR>::iterator,
bool>
2587unordered_set<KEY, HASH, EQUAL, ALLOCATOR>::emplace(
2601 bool isInsertedFlag =
false;
2603 HashTableLink *result = d_impl.emplaceIfMissing(
2616 return ResultType(iterator(result), isInsertedFlag);
2621#if BSLSTL_UNORDEREDSET_VARIADIC_LIMIT_D >= 0
2622template <
class KEY,
class HASH,
class EQUAL,
class ALLOCATOR>
2624typename unordered_set<KEY, HASH, EQUAL, ALLOCATOR>::iterator
2625unordered_set<KEY, HASH, EQUAL, ALLOCATOR>::emplace_hint(const_iterator)
2629 this->emplace().first;
2633#if BSLSTL_UNORDEREDSET_VARIADIC_LIMIT_D >= 1
2634template <
class KEY,
class HASH,
class EQUAL,
class ALLOCATOR>
2635template <
class Args_01>
2637typename unordered_set<KEY, HASH, EQUAL, ALLOCATOR>::iterator
2638unordered_set<KEY, HASH, EQUAL, ALLOCATOR>::emplace_hint(const_iterator,
2648#if BSLSTL_UNORDEREDSET_VARIADIC_LIMIT_D >= 2
2649template <
class KEY,
class HASH,
class EQUAL,
class ALLOCATOR>
2650template <
class Args_01,
2653typename unordered_set<KEY, HASH, EQUAL, ALLOCATOR>::iterator
2654unordered_set<KEY, HASH, EQUAL, ALLOCATOR>::emplace_hint(const_iterator,
2666#if BSLSTL_UNORDEREDSET_VARIADIC_LIMIT_D >= 3
2667template <
class KEY,
class HASH,
class EQUAL,
class ALLOCATOR>
2668template <
class Args_01,
2672typename unordered_set<KEY, HASH, EQUAL, ALLOCATOR>::iterator
2673unordered_set<KEY, HASH, EQUAL, ALLOCATOR>::emplace_hint(const_iterator,
2687#if BSLSTL_UNORDEREDSET_VARIADIC_LIMIT_D >= 4
2688template <
class KEY,
class HASH,
class EQUAL,
class ALLOCATOR>
2689template <
class Args_01,
2694typename unordered_set<KEY, HASH, EQUAL, ALLOCATOR>::iterator
2695unordered_set<KEY, HASH, EQUAL, ALLOCATOR>::emplace_hint(const_iterator,
2711#if BSLSTL_UNORDEREDSET_VARIADIC_LIMIT_D >= 5
2712template <
class KEY,
class HASH,
class EQUAL,
class ALLOCATOR>
2713template <
class Args_01,
2719typename unordered_set<KEY, HASH, EQUAL, ALLOCATOR>::iterator
2720unordered_set<KEY, HASH, EQUAL, ALLOCATOR>::emplace_hint(const_iterator,
2738#if BSLSTL_UNORDEREDSET_VARIADIC_LIMIT_D >= 6
2739template <
class KEY,
class HASH,
class EQUAL,
class ALLOCATOR>
2740template <
class Args_01,
2747typename unordered_set<KEY, HASH, EQUAL, ALLOCATOR>::iterator
2748unordered_set<KEY, HASH, EQUAL, ALLOCATOR>::emplace_hint(const_iterator,
2768#if BSLSTL_UNORDEREDSET_VARIADIC_LIMIT_D >= 7
2769template <
class KEY,
class HASH,
class EQUAL,
class ALLOCATOR>
2770template <
class Args_01,
2778typename unordered_set<KEY, HASH, EQUAL, ALLOCATOR>::iterator
2779unordered_set<KEY, HASH, EQUAL, ALLOCATOR>::emplace_hint(const_iterator,
2801#if BSLSTL_UNORDEREDSET_VARIADIC_LIMIT_D >= 8
2802template <
class KEY,
class HASH,
class EQUAL,
class ALLOCATOR>
2803template <
class Args_01,
2812typename unordered_set<KEY, HASH, EQUAL, ALLOCATOR>::iterator
2813unordered_set<KEY, HASH, EQUAL, ALLOCATOR>::emplace_hint(const_iterator,
2837#if BSLSTL_UNORDEREDSET_VARIADIC_LIMIT_D >= 9
2838template <
class KEY,
class HASH,
class EQUAL,
class ALLOCATOR>
2839template <
class Args_01,
2849typename unordered_set<KEY, HASH, EQUAL, ALLOCATOR>::iterator
2850unordered_set<KEY, HASH, EQUAL, ALLOCATOR>::emplace_hint(const_iterator,
2876#if BSLSTL_UNORDEREDSET_VARIADIC_LIMIT_D >= 10
2877template <
class KEY,
class HASH,
class EQUAL,
class ALLOCATOR>
2878template <
class Args_01,
2889typename unordered_set<KEY, HASH, EQUAL, ALLOCATOR>::iterator
2890unordered_set<KEY, HASH, EQUAL, ALLOCATOR>::emplace_hint(const_iterator,
2921template <
class KEY,
class HASH,
class EQUAL,
class ALLOCATOR>
2922template <
class... Args>
2924pair<typename unordered_set<KEY, HASH, EQUAL, ALLOCATOR>::iterator,
bool>
2925unordered_set<KEY, HASH, EQUAL, ALLOCATOR>::emplace(
2930 bool isInsertedFlag =
false;
2932 HashTableLink *result = d_impl.emplaceIfMissing(
2935 return ResultType(iterator(result), isInsertedFlag);
2938template <
class KEY,
class HASH,
class EQUAL,
class ALLOCATOR>
2939template <
class... Args>
2941typename unordered_set<KEY, HASH, EQUAL, ALLOCATOR>::iterator
2942unordered_set<KEY, HASH, EQUAL, ALLOCATOR>::emplace_hint(const_iterator,
2952template <
class KEY,
class HASH,
class EQUAL,
class ALLOCATOR>
2955 typename unordered_set<KEY, HASH, EQUAL, ALLOCATOR>::iterator>
2956unordered_set<KEY, HASH, EQUAL, ALLOCATOR>::equal_range(
const key_type& key)
2960 iterator first = this->find(key);
2961 if (first == this->
end()) {
2962 return ResultType(first, first);
2965 iterator next = first;
2966 return ResultType(first, ++next);
2970template <
class KEY,
class HASH,
class EQUAL,
class ALLOCATOR>
2972typename unordered_set<KEY, HASH, EQUAL, ALLOCATOR>::iterator
2973unordered_set<KEY, HASH, EQUAL, ALLOCATOR>::erase(const_iterator position)
2977 return iterator(d_impl.remove(position.node()));
2980template <
class KEY,
class HASH,
class EQUAL,
class ALLOCATOR>
2982typename unordered_set<KEY, HASH, EQUAL, ALLOCATOR>::size_type
2983unordered_set<KEY, HASH, EQUAL, ALLOCATOR>::erase(
const key_type& key)
2985 if (HashTableLink *target = d_impl.find(key)) {
2986 d_impl.remove(target);
2994template <
class KEY,
class HASH,
class EQUAL,
class ALLOCATOR>
2996typename unordered_set<KEY, HASH, EQUAL, ALLOCATOR>::iterator
2997unordered_set<KEY, HASH, EQUAL, ALLOCATOR>::erase(const_iterator first,
2998 const_iterator last)
3000#if defined BDE_BUILD_TARGET_SAFE_2
3001 if (first != last) {
3002 iterator it = this->
begin();
3003 const iterator
end = this->end();
3004 for (; it != first; ++it) {
3008 for (; it != last; ++it) {
3014 while (first != last) {
3015 first = this->
erase(first);
3018 return iterator(first.node());
3021template <
class KEY,
class HASH,
class EQUAL,
class ALLOCATOR>
3023typename unordered_set<KEY, HASH, EQUAL, ALLOCATOR>::iterator
3024unordered_set<KEY, HASH, EQUAL, ALLOCATOR>::find(
const key_type& key)
3026 return iterator(d_impl.find(key));
3029template <
class KEY,
class HASH,
class EQUAL,
class ALLOCATOR>
3032unordered_set<KEY, HASH, EQUAL, ALLOCATOR>::insert(
const value_type& value)
3036 bool isInsertedFlag =
false;
3038 HashTableLink *result = d_impl.insertIfMissing(&isInsertedFlag, value);
3040 return ResultType(iterator(result), isInsertedFlag);
3043template <
class KEY,
class HASH,
class EQUAL,
class ALLOCATOR>
3046unordered_set<KEY, HASH, EQUAL, ALLOCATOR>::insert(
3047 BloombergLP::bslmf::MovableRef<value_type> value)
3051 bool isInsertedFlag =
false;
3053 HashTableLink *result = d_impl.insertIfMissing(&isInsertedFlag,
3054 MoveUtil::move(value));
3056 return ResultType(iterator(result), isInsertedFlag);
3059template <
class KEY,
class HASH,
class EQUAL,
class ALLOCATOR>
3061typename unordered_set<KEY, HASH, EQUAL, ALLOCATOR>::iterator
3062unordered_set<KEY, HASH, EQUAL, ALLOCATOR>::insert(const_iterator,
3063 const value_type& value)
3073 return this->insert(value).first;
3076template <
class KEY,
class HASH,
class EQUAL,
class ALLOCATOR>
3078typename unordered_set<KEY, HASH, EQUAL, ALLOCATOR>::iterator
3079unordered_set<KEY, HASH, EQUAL, ALLOCATOR>::insert(
3081 BloombergLP::bslmf::MovableRef<value_type> value)
3091 return this->insert(MoveUtil::move(value)).first;
3094template <
class KEY,
class HASH,
class EQUAL,
class ALLOCATOR>
3095template <
class INPUT_ITERATOR>
3097void unordered_set<KEY, HASH, EQUAL, ALLOCATOR>::insert(INPUT_ITERATOR first,
3098 INPUT_ITERATOR last)
3100 insertFromRange(first, last);
3103#if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
3104template <
class KEY,
class HASH,
class EQUAL,
class ALLOCATOR>
3106void unordered_set<KEY, HASH, EQUAL, ALLOCATOR>::insert(
3107 std::initializer_list<KEY> values)
3109 insert(values.begin(), values.end());
3113template <
class KEY,
class HASH,
class EQUAL,
class ALLOCATOR>
3115void unordered_set<KEY, HASH, EQUAL, ALLOCATOR>::max_load_factor(
3116 float newLoadFactor)
3118 d_impl.setMaxLoadFactor(newLoadFactor);
3121template <
class KEY,
class HASH,
class EQUAL,
class ALLOCATOR>
3123void unordered_set<KEY, HASH, EQUAL, ALLOCATOR>::rehash(size_type numBuckets)
3125 d_impl.rehashForNumBuckets(numBuckets);
3128template <
class KEY,
class HASH,
class EQUAL,
class ALLOCATOR>
3131unordered_set<KEY, HASH, EQUAL, ALLOCATOR>::reserve(size_type numElements)
3133 d_impl.reserveForNumElements(numElements);
3136template <
class KEY,
class HASH,
class EQUAL,
class ALLOCATOR>
3138void unordered_set<KEY, HASH, EQUAL, ALLOCATOR>::swap(unordered_set& other)
3140 AllocatorTraits::is_always_equal::value
3141 && bsl::is_nothrow_swappable<HASH>::value
3142 && bsl::is_nothrow_swappable<EQUAL>::value)
3144 d_impl.swap(other.d_impl);
3148template <
class KEY,
class HASH,
class EQUAL,
class ALLOCATOR>
3150ALLOCATOR unordered_set<KEY, HASH, EQUAL, ALLOCATOR>::get_allocator() const
3153 return d_impl.allocator();
3156template <
class KEY,
class HASH,
class EQUAL,
class ALLOCATOR>
3158typename unordered_set<KEY, HASH, EQUAL, ALLOCATOR>::const_iterator
3161 return const_iterator(d_impl.elementListRoot());
3164template <
class KEY,
class HASH,
class EQUAL,
class ALLOCATOR>
3166typename unordered_set<KEY, HASH, EQUAL, ALLOCATOR>::const_iterator
3169 return const_iterator();
3172template <
class KEY,
class HASH,
class EQUAL,
class ALLOCATOR>
3174typename unordered_set<KEY, HASH, EQUAL, ALLOCATOR>::const_iterator
3175unordered_set<KEY, HASH, EQUAL, ALLOCATOR>::cbegin() const
3178 return const_iterator(d_impl.elementListRoot());
3181template <
class KEY,
class HASH,
class EQUAL,
class ALLOCATOR>
3183typename unordered_set<KEY, HASH, EQUAL, ALLOCATOR>::const_iterator
3186 return const_iterator();
3189template <
class KEY,
class HASH,
class EQUAL,
class ALLOCATOR>
3191bool unordered_set<KEY, HASH, EQUAL, ALLOCATOR>::contains(
3192 const key_type& key)
const
3194 return find(key) !=
end();
3197template <
class KEY,
class HASH,
class EQUAL,
class ALLOCATOR>
3202 return 0 == d_impl.size();
3205template <
class KEY,
class HASH,
class EQUAL,
class ALLOCATOR>
3207typename unordered_set<KEY, HASH, EQUAL, ALLOCATOR>::size_type
3210 return d_impl.size();
3213template <
class KEY,
class HASH,
class EQUAL,
class ALLOCATOR>
3215typename unordered_set<KEY, HASH, EQUAL, ALLOCATOR>::size_type
3216unordered_set<KEY, HASH, EQUAL, ALLOCATOR>::max_size() const
3219 return AllocatorTraits::max_size(get_allocator());
3222template <
class KEY,
class HASH,
class EQUAL,
class ALLOCATOR>
3224typename unordered_set<KEY, HASH, EQUAL, ALLOCATOR>::hasher
3225unordered_set<KEY, HASH, EQUAL, ALLOCATOR>::hash_function()
const
3227 return d_impl.hasher();
3230template <
class KEY,
class HASH,
class EQUAL,
class ALLOCATOR>
3232typename unordered_set<KEY, HASH, EQUAL, ALLOCATOR>::key_equal
3233unordered_set<KEY, HASH, EQUAL, ALLOCATOR>::key_eq()
const
3235 return d_impl.comparator();
3238template <
class KEY,
class HASH,
class EQUAL,
class ALLOCATOR>
3240typename unordered_set<KEY, HASH, EQUAL, ALLOCATOR>::const_iterator
3241unordered_set<KEY, HASH, EQUAL, ALLOCATOR>::find(
const key_type& key)
const
3243 return const_iterator(d_impl.find(key));
3246template <
class KEY,
class HASH,
class EQUAL,
class ALLOCATOR>
3248typename unordered_set<KEY, HASH, EQUAL, ALLOCATOR>::size_type
3249unordered_set<KEY, HASH, EQUAL, ALLOCATOR>::count(
const key_type& key)
const
3251 return 0 != d_impl.find(key);
3254template <
class KEY,
class HASH,
class EQUAL,
class ALLOCATOR>
3257 typename unordered_set<KEY, HASH, EQUAL, ALLOCATOR>::const_iterator>
3258unordered_set<KEY, HASH, EQUAL, ALLOCATOR>::equal_range(
3259 const key_type& key)
const
3263 const_iterator first = this->find(key);
3264 if (first == this->end()) {
3265 return ResultType(first, first);
3268 const_iterator next = first;
3269 return ResultType(first, ++next);
3273template <
class KEY,
class HASH,
class EQUAL,
class ALLOCATOR>
3275typename unordered_set<KEY, HASH, EQUAL, ALLOCATOR>::size_type
3276unordered_set<KEY, HASH, EQUAL, ALLOCATOR>::bucket_count() const
3279 return d_impl.numBuckets();
3282template <
class KEY,
class HASH,
class EQUAL,
class ALLOCATOR>
3284typename unordered_set<KEY, HASH, EQUAL, ALLOCATOR>::size_type
3285unordered_set<KEY, HASH, EQUAL, ALLOCATOR>::max_bucket_count() const
3288 return d_impl.maxNumBuckets();
3291template <
class KEY,
class HASH,
class EQUAL,
class ALLOCATOR>
3293typename unordered_set<KEY, HASH, EQUAL, ALLOCATOR>::size_type
3294unordered_set<KEY, HASH, EQUAL, ALLOCATOR>::bucket_size(size_type index)
const
3298 return d_impl.countElementsInBucket(index);
3301template <
class KEY,
class HASH,
class EQUAL,
class ALLOCATOR>
3303typename unordered_set<KEY, HASH, EQUAL, ALLOCATOR>::size_type
3304unordered_set<KEY, HASH, EQUAL, ALLOCATOR>::bucket(
const key_type& key)
const
3308 return d_impl.bucketIndexForKey(key);
3311template <
class KEY,
class HASH,
class EQUAL,
class ALLOCATOR>
3313typename unordered_set<KEY, HASH, EQUAL, ALLOCATOR>::const_local_iterator
3314unordered_set<KEY, HASH, EQUAL, ALLOCATOR>::begin(size_type index)
const
3318 return const_local_iterator(&d_impl.bucketAtIndex(index));
3321template <
class KEY,
class HASH,
class EQUAL,
class ALLOCATOR>
3323typename unordered_set<KEY, HASH, EQUAL, ALLOCATOR>::const_local_iterator
3324unordered_set<KEY, HASH, EQUAL, ALLOCATOR>::end(size_type index)
const
3328 return const_local_iterator(0, &d_impl.bucketAtIndex(index));
3331template <
class KEY,
class HASH,
class EQUAL,
class ALLOCATOR>
3333typename unordered_set<KEY, HASH, EQUAL, ALLOCATOR>::const_local_iterator
3334unordered_set<KEY, HASH, EQUAL, ALLOCATOR>::cbegin(size_type index)
const
3338 return const_local_iterator(&d_impl.bucketAtIndex(index));
3341template <
class KEY,
class HASH,
class EQUAL,
class ALLOCATOR>
3343typename unordered_set<KEY, HASH, EQUAL, ALLOCATOR>::const_local_iterator
3344unordered_set<KEY, HASH, EQUAL, ALLOCATOR>::cend(size_type index)
const
3348 return const_local_iterator(0, &d_impl.bucketAtIndex(index));
3351template <
class KEY,
class HASH,
class EQUAL,
class ALLOCATOR>
3353float unordered_set<KEY, HASH, EQUAL, ALLOCATOR>::load_factor() const
3356 return d_impl.loadFactor();
3359template <
class KEY,
class HASH,
class EQUAL,
class ALLOCATOR>
3361float unordered_set<KEY, HASH, EQUAL, ALLOCATOR>::max_load_factor() const
3364 return d_impl.maxLoadFactor();
3370template <
class KEY,
class HASH,
class EQUAL,
class ALLOCATOR>
3376 return lhs.d_impl ==
rhs.d_impl;
3379#ifndef BSLS_COMPILERFEATURES_SUPPORT_THREE_WAY_COMPARISON
3380template <
class KEY,
class HASH,
class EQUAL,
class ALLOCATOR>
3391template <
class KEY,
class HASH,
class EQUAL,
class ALLOCATOR,
class PREDICATE>
3395 PREDICATE predicate)
3397 return BloombergLP::bslstl::AlgorithmUtil::containerEraseIf(s, predicate);
3400template <
class KEY,
class HASH,
class EQUAL,
class ALLOCATOR>
3426template <
class KEY,
class HASH,
class EQUAL,
class ALLOCATOR>
3427struct HasStlIterators<
bsl::unordered_set<KEY, HASH, EQUAL, ALLOCATOR> >
3435template <
class KEY,
class HASH,
class EQUAL,
class ALLOCATOR>
3436struct UsesBslmaAllocator<
bsl::unordered_set<KEY, HASH, EQUAL, ALLOCATOR> >
3445# error Not valid except when included from bslstl_unorderedset.h
#define BSLMF_NESTED_TRAIT_DECLARATION_IF(t_TYPE, t_TRAIT, t_COND)
Definition bslmf_nestedtraitdeclaration.h:243
Definition bslma_bslallocator.h:588
Definition bslstl_pair.h:1280
Definition bslstl_unorderedset.h:733
void swap(unordered_set &other) BSLS_KEYWORD_NOEXCEPT_SPECIFICATION(AllocatorTraits void clear() BSLS_KEYWORD_NOEXCEPT
Definition bslstl_unorderedset.h:1485
unordered_set & operator=(const unordered_set &rhs)
Definition bslstl_unorderedset.h:2546
EQUAL key_equal
Definition bslstl_unorderedset.h:782
AllocatorTraits::const_pointer const_pointer
Definition bslstl_unorderedset.h:790
void rehash(size_type numBuckets)
Definition bslstl_unorderedset.h:2842
pair< iterator, bool > insert(const value_type &value)
Definition bslstl_unorderedset.h:2751
EQUAL key_eq() const
Definition bslstl_unorderedset.h:2952
unordered_set &operator=(BloombergLP::bslmf::MovableRef< unordered_set > rhs) BSLS_KEYWORD_NOEXCEPT_SPECIFICATION(AllocatorTraits iterator begin() BSLS_KEYWORD_NOEXCEPT
Definition bslstl_unorderedset.h:2594
HASH hasher
Definition bslstl_unorderedset.h:781
HASH hash_function() const
Definition bslstl_unorderedset.h:2944
size_type bucket_size(size_type index) const
Definition bslstl_unorderedset.h:3013
size_type max_bucket_count() const BSLS_KEYWORD_NOEXCEPT
Definition bslstl_unorderedset.h:3004
AllocatorTraits::size_type size_type
Definition bslstl_unorderedset.h:787
ALLOCATOR allocator_type
Definition bslstl_unorderedset.h:783
enable_if< BloombergLP::bslmf::IsTransparentPredicate< HASH, LOOKUP_KEY >::value &&BloombergLP::bslmf::IsTransparentPredicate< EQUAL, LOOKUP_KEY >::value, pair< iterator, iterator > >::type equal_range(const LOOKUP_KEY &key)
Definition bslstl_unorderedset.h:1530
enable_if< BloombergLP::bslmf::IsTransparentPredicate< HASH, LOOKUP_KEY >::value &&BloombergLP::bslmf::IsTransparentPredicate< EQUAL, LOOKUP_KEY >::value, size_type >::type count(const LOOKUP_KEY &key) const
Definition bslstl_unorderedset.h:1725
const_iterator cbegin() const BSLS_KEYWORD_NOEXCEPT
Definition bslstl_unorderedset.h:2894
friend bool operator==(const unordered_set< KEY2, HASH2, EQUAL2, ALLOCATOR2 > &, const unordered_set< KEY2, HASH2, EQUAL2, ALLOCATOR2 > &)
ALLOCATOR get_allocator() const BSLS_KEYWORD_NOEXCEPT
Definition bslstl_unorderedset.h:2869
KEY value_type
Definition bslstl_unorderedset.h:780
bool empty() const BSLS_KEYWORD_NOEXCEPT
Definition bslstl_unorderedset.h:2919
bool contains(const key_type &key) const
Definition bslstl_unorderedset.h:2910
~unordered_set()
Destroy this object.
Definition bslstl_unorderedset.h:2537
iterator emplace_hint(const_iterator hint, Args &&... arguments)
Definition bslstl_unorderedset.h:2655
size_type bucket(const key_type &key) const
Definition bslstl_unorderedset.h:3023
float load_factor() const BSLS_KEYWORD_NOEXCEPT
Definition bslstl_unorderedset.h:3072
local_iterator const_local_iterator
Definition bslstl_unorderedset.h:797
::BloombergLP::bslstl::HashTableIterator< const value_type, difference_type > iterator
Definition bslstl_unorderedset.h:792
AllocatorTraits::difference_type difference_type
Definition bslstl_unorderedset.h:788
pair< iterator, bool > emplace(Args &&... arguments)
enable_if< BloombergLP::bslmf::IsTransparentPredicate< HASH, LOOKUP_KEY >::value &&BloombergLP::bslmf::IsTransparentPredicate< EQUAL, LOOKUP_KEY >::value, iterator >::type find(const LOOKUP_KEY &key)
Definition bslstl_unorderedset.h:1500
void reserve(size_type numElements)
Definition bslstl_unorderedset.h:2850
void insert_range(BSLS_COMPILERFEATURES_FORWARD_REF(RANGE) range)
Definition bslstl_unorderedset.h:1350
size_type max_size() const BSLS_KEYWORD_NOEXCEPT
Definition bslstl_unorderedset.h:2935
const_iterator cend() const BSLS_KEYWORD_NOEXCEPT
Definition bslstl_unorderedset.h:2903
iterator end() BSLS_KEYWORD_NOEXCEPT
Definition bslstl_unorderedset.h:2602
iterator erase(const_iterator position)
Definition bslstl_unorderedset.h:2692
size_type bucket_count() const BSLS_KEYWORD_NOEXCEPT
Definition bslstl_unorderedset.h:2995
AllocatorTraits::pointer pointer
Definition bslstl_unorderedset.h:789
const value_type & const_reference
Definition bslstl_unorderedset.h:785
KEY key_type
Definition bslstl_unorderedset.h:779
float max_load_factor() const BSLS_KEYWORD_NOEXCEPT
Definition bslstl_unorderedset.h:3080
unordered_set()
Definition bslstl_unorderedset.h:2329
::BloombergLP::bslstl::HashTableBucketIterator< const value_type, difference_type > local_iterator
Definition bslstl_unorderedset.h:794
size_type size() const BSLS_KEYWORD_NOEXCEPT
Return the number of elements in this set.
Definition bslstl_unorderedset.h:2927
iterator const_iterator
Definition bslstl_unorderedset.h:796
value_type & reference
Definition bslstl_unorderedset.h:784
#define BSLS_ASSERT(X)
Definition bsls_assert.h:1976
#define BSLS_ASSERT_SAFE(X)
Definition bsls_assert.h:1917
#define BSLS_COMPILERFEATURES_FORWARD_REF(T)
Definition bsls_compilerfeatures.h:2343
#define BSLS_COMPILERFEATURES_FORWARD(T, V)
Definition bsls_compilerfeatures.h:2349
#define BSLS_KEYWORD_CONSTEXPR_CPP17
Definition bsls_keyword.h:639
#define BSLS_KEYWORD_NOEXCEPT_OPERATOR(...)
Definition bsls_keyword.h:677
#define BSLS_KEYWORD_NOEXCEPT
Definition bsls_keyword.h:674
#define BSLS_KEYWORD_NOEXCEPT_SPECIFICATION(...)
Definition bsls_keyword.h:676
#define BSLSTL_UNORDEREDSET_REQUIRES_CONTAINER_COMPATIBLE_RANGE(R, T)
Definition bslstl_unorderedset.h:695
void swap(OptionValue &a, OptionValue &b)
int reserve(TYPE *array, int numElements)
Definition bdlat_valuetypefunctions.h:939
void swap(array< VALUE_TYPE, SIZE > &lhs, array< VALUE_TYPE, SIZE > &rhs)
ALLOCATOR const STRING_VIEW_LIKE_TYPE & rhs
Definition bslstl_string.h:3918
deque< VALUE_TYPE, ALLOCATOR >::size_type erase(deque< VALUE_TYPE, ALLOCATOR > &deq, const BDE_OTHER_TYPE &value)
Definition bslstl_deque.h:4424
T::iterator begin(T &container)
Definition bslstl_iterator.h:1593
const from_range_t from_range
bool operator==(const memory_resource &a, const memory_resource &b)
ALLOCATOR & lhs
Definition bslstl_string.h:3917
T::iterator end(T &container)
Definition bslstl_iterator.h:1621
deque< VALUE_TYPE, ALLOCATOR >::size_type erase_if(deque< VALUE_TYPE, ALLOCATOR > &deq, PREDICATE predicate)
Definition bslstl_deque.h:4433
bool operator!=(const memory_resource &a, const memory_resource &b)
Definition bdlc_flathashmap.h:2218
Definition baljsn_encoder_testtypes.h:76
Definition bdlbb_blob.h:579
Definition bdldfp_decimal.h:5549
Definition bslma_allocatortraits.h:1089
BloombergLP::bslma::AllocatorTraits_ConstPointerType< ALLOCATOR >::type const_pointer
Definition bslma_allocatortraits.h:1183
BloombergLP::bslma::AllocatorTraits_SizeType< ALLOCATOR >::type size_type
Definition bslma_allocatortraits.h:1196
BloombergLP::bslma::AllocatorTraits_PointerType< ALLOCATOR >::type pointer
Definition bslma_allocatortraits.h:1180
BloombergLP::bslma::AllocatorTraits_DifferenceType< ALLOCATOR >::type difference_type
Definition bslma_allocatortraits.h:1193
Definition bslstl_equalto.h:316
Definition bslstl_ranges.h:301
Definition bslstl_hash.h:495
Definition bslmf_isconvertible.h:875