8#ifndef INCLUDED_BDLC_FLATHASHSET
9#define INCLUDED_BDLC_FLATHASHSET
450#include <bdlscm_version.h>
478#if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
479#include <bsl_initializer_list.h>
481#include <bsl_cstddef.h>
482#include <bsl_ostream.h>
483#include <bsl_utility.h>
485#if BSLS_COMPILERFEATURES_SIMULATE_CPP11_FEATURES
489# define COMPILING_BDLC_FLATHASHSET_H
491# undef COMPILING_BDLC_FLATHASHSET_H
503template <
class KEY,
class HASH,
class EQUAL>
507template <
class KEY,
class HASH,
class EQUAL>
511template <
class KEY,
class HASH,
class EQUAL>
521template <
class ENTRY>
525#if !BSLS_COMPILERFEATURES_SIMULATE_CPP11_FEATURES
530 template <
class... ARGS>
541 template <
class KEY_TYPE>
548 static const ENTRY&
key(
const ENTRY& entry);
563template <
class KEY,
class HASH,
class EQUAL>
581 template <
class K,
class H,
class E>
651 template <
class INPUT_ITERATOR>
655 template <
class INPUT_ITERATOR>
660 template <
class INPUT_ITERATOR>
666 template <
class INPUT_ITERATOR>
674#if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
752#if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
768#if !BSLS_COMPILERFEATURES_SIMULATE_CPP11_FEATURES
780 template <
class... ARGS>
795 template <
class... ARGS>
805 bsl::size_t
erase(
const KEY& key);
825#if defined(BSLS_PLATFORM_CMP_SUN) && BSLS_PLATFORM_CMP_VERSION < 0x5130
826 template <
class KEY_TYPE>
837 template <
class KEY_TYPE>
849#if defined(BSLS_PLATFORM_CMP_SUN) && BSLS_PLATFORM_CMP_VERSION < 0x5130
850 template <
class KEY_TYPE>
859 template <
class KEY_TYPE>
880 template <
class INPUT_ITERATOR>
881 void insert(INPUT_ITERATOR first, INPUT_ITERATOR last);
883#if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
889 void insert(bsl::initializer_list<KEY> values);
899 void rehash(bsl::size_t minimumCapacity);
913 void reserve(bsl::size_t numEntries);
935 bool contains(
const KEY& key)
const;
940 bsl::size_t count(
const KEY& key)
const;
954 const KEY& key)
const;
984 bsl::size_t
size()
const;
1021 bsl::ostream&
print(bsl::ostream& stream,
1023 int spacesPerLevel = 4)
const;
1033template <
class KEY,
class HASH,
class EQUAL>
1034bool operator==(
const FlatHashSet<KEY, HASH, EQUAL> &lhs,
1035 const FlatHashSet<KEY, HASH, EQUAL> &rhs);
1042template <
class KEY,
class HASH,
class EQUAL>
1043bool operator!=(
const FlatHashSet<KEY, HASH, EQUAL> &lhs,
1044 const FlatHashSet<KEY, HASH, EQUAL> &rhs);
1051template <
class KEY,
class HASH,
class EQUAL>
1061template <
class KEY,
class HASH,
class EQUAL>
1073#if !BSLS_COMPILERFEATURES_SIMULATE_CPP11_FEATURES
1074template <
class ENTRY>
1075template <
class... ARGS>
1090template <
class ENTRY>
1106template <
class ENTRY>
1118template <
class KEY,
class HASH,
class EQUAL>
1121: d_impl(0, HASH(), EQUAL())
1125template <
class KEY,
class HASH,
class EQUAL>
1128: d_impl(0, HASH(), EQUAL(), basicAllocator)
1132template <
class KEY,
class HASH,
class EQUAL>
1135: d_impl(capacity, HASH(), EQUAL())
1139template <
class KEY,
class HASH,
class EQUAL>
1143: d_impl(capacity, HASH(), EQUAL(), basicAllocator)
1147template <
class KEY,
class HASH,
class EQUAL>
1152: d_impl(capacity, hash, EQUAL(), basicAllocator)
1156template <
class KEY,
class HASH,
class EQUAL>
1162: d_impl(capacity, hash, equal, basicAllocator)
1166template <
class KEY,
class HASH,
class EQUAL>
1167template <
class INPUT_ITERATOR>
1170 INPUT_ITERATOR last,
1172: d_impl(0, HASH(), EQUAL(), basicAllocator)
1177template <
class KEY,
class HASH,
class EQUAL>
1178template <
class INPUT_ITERATOR>
1181 INPUT_ITERATOR last,
1182 bsl::size_t capacity,
1184: d_impl(capacity, HASH(), EQUAL(), basicAllocator)
1189template <
class KEY,
class HASH,
class EQUAL>
1190template <
class INPUT_ITERATOR>
1193 INPUT_ITERATOR last,
1194 bsl::size_t capacity,
1197: d_impl(capacity, hash, EQUAL(), basicAllocator)
1202template <
class KEY,
class HASH,
class EQUAL>
1203template <
class INPUT_ITERATOR>
1206 INPUT_ITERATOR last,
1207 bsl::size_t capacity,
1211: d_impl(capacity, hash, equal, basicAllocator)
1216#if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
1217template <
class KEY,
class HASH,
class EQUAL>
1220 bsl::initializer_list<KEY> values,
1231template <
class KEY,
class HASH,
class EQUAL>
1234 bsl::initializer_list<KEY> values,
1235 bsl::size_t capacity,
1237: FlatHashSet(values.begin(),
1246template <
class KEY,
class HASH,
class EQUAL>
1249 bsl::initializer_list<KEY> values,
1250 bsl::size_t capacity,
1253: FlatHashSet(values.
begin(),
1262template <
class KEY,
class HASH,
class EQUAL>
1265 bsl::initializer_list<KEY> values,
1266 bsl::size_t capacity,
1270: FlatHashSet(values.
begin(),
1280template <
class KEY,
class HASH,
class EQUAL>
1284: d_impl(original.d_impl, basicAllocator)
1288template <
class KEY,
class HASH,
class EQUAL>
1292: d_impl(
bslmf::MovableRefUtil::move(
1293 bslmf::MovableRefUtil::access(original).d_impl))
1297template <
class KEY,
class HASH,
class EQUAL>
1302: d_impl(
bslmf::MovableRefUtil::move(
1303 bslmf::MovableRefUtil::access(original).d_impl),
1308template <
class KEY,
class HASH,
class EQUAL>
1315template <
class KEY,
class HASH,
class EQUAL>
1320 d_impl = rhs.d_impl;
1325template <
class KEY,
class HASH,
class EQUAL>
1337#if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
1338template <
class KEY,
class HASH,
class EQUAL>
1341 bsl::initializer_list<KEY> values)
1356template <
class KEY,
class HASH,
class EQUAL>
1363#if !BSLS_COMPILERFEATURES_SIMULATE_CPP11_FEATURES
1364template <
class KEY,
class HASH,
class EQUAL>
1365template <
class... ARGS>
1372template <
class KEY,
class HASH,
class EQUAL>
1373template <
class... ARGS>
1385template <
class KEY,
class HASH,
class EQUAL>
1389 return d_impl.
erase(key);
1392template <
class KEY,
class HASH,
class EQUAL>
1399 return d_impl.
erase(position);
1402template <
class KEY,
class HASH,
class EQUAL>
1407 return d_impl.
erase(first, last);
1410template <
class KEY,
class HASH,
class EQUAL>
1411template <
class INPUT_ITERATOR>
1414 INPUT_ITERATOR last)
1416 d_impl.
insert(first, last);
1419#if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
1420template <
class KEY,
class HASH,
class EQUAL>
1424 insert(values.begin(), values.end());
1428template <
class KEY,
class HASH,
class EQUAL>
1432 d_impl.
rehash(minimumCapacity);
1435template <
class KEY,
class HASH,
class EQUAL>
1442template <
class KEY,
class HASH,
class EQUAL>
1451template <
class KEY,
class HASH,
class EQUAL>
1457 d_impl.
swap(other.d_impl);
1461template <
class KEY,
class HASH,
class EQUAL>
1468template <
class KEY,
class HASH,
class EQUAL>
1475template <
class KEY,
class HASH,
class EQUAL>
1479 return d_impl.
count(key);
1482template <
class KEY,
class HASH,
class EQUAL>
1486 return d_impl.
empty();
1489template <
class KEY,
class HASH,
class EQUAL>
1498template <
class KEY,
class HASH,
class EQUAL>
1503 return d_impl.
find(key);
1506template <
class KEY,
class HASH,
class EQUAL>
1513template <
class KEY,
class HASH,
class EQUAL>
1520template <
class KEY,
class HASH,
class EQUAL>
1527template <
class KEY,
class HASH,
class EQUAL>
1534template <
class KEY,
class HASH,
class EQUAL>
1538 return d_impl.
size();
1543template <
class KEY,
class HASH,
class EQUAL>
1548 return d_impl.
begin();
1551template <
class KEY,
class HASH,
class EQUAL>
1559template <
class KEY,
class HASH,
class EQUAL>
1564 return d_impl.
cend();
1567template <
class KEY,
class HASH,
class EQUAL>
1572 return d_impl.
end();
1577template <
class KEY,
class HASH,
class EQUAL>
1584template <
class KEY,
class HASH,
class EQUAL>
1586 bsl::ostream& stream,
1588 int spacesPerLevel)
const
1599 while (iter != end()) {
1612template <
class KEY,
class HASH,
class EQUAL>
1615 const FlatHashSet<KEY, HASH, EQUAL>& rhs)
1617 return lhs.d_impl == rhs.d_impl;
1620template <
class KEY,
class HASH,
class EQUAL>
1623 const FlatHashSet<KEY, HASH, EQUAL>& rhs)
1625 return lhs.d_impl != rhs.d_impl;
1628template <
class KEY,
class HASH,
class EQUAL>
1631 const FlatHashSet<KEY, HASH, EQUAL>& set)
1633 return set.
print(stream, 0, -1);
1637template <
class KEY,
class HASH,
class EQUAL>
1639void bdlc::swap(FlatHashSet<KEY, HASH, EQUAL>& a,
1640 FlatHashSet<KEY, HASH, EQUAL>& b)
1651template <
class KEY,
class HASH,
class EQUAL>
1660template <
class KEY,
class HASH,
class EQUAL>
bsl::ostream & print(bsl::ostream &stream, int level=0, int spacesPerLevel=4) const
Definition bdlc_flathashset.h:564
iterator emplace_hint(const_iterator hint, ARGS &&... args)
bsl::enable_if< bsl::is_convertible< KEY_TYPE, KEY >::value, bsl::pair< const_iterator, bool > >::type insert(BSLS_COMPILERFEATURES_FORWARD_REF(KEY_TYPE) value)
Definition bdlc_flathashset.h:840
EQUAL key_eq() const
Definition bdlc_flathashset.h:1515
bsl::size_t count(const KEY &key) const
Definition bdlc_flathashset.h:1477
bsl::pair< iterator, bool > emplace(ARGS &&... args)
EQUAL value_compare
Definition bdlc_flathashset.h:591
const_iterator begin() const
Definition bdlc_flathashset.h:1546
HASH hash_function() const
Definition bdlc_flathashset.h:1508
void reserve(bsl::size_t numEntries)
Definition bdlc_flathashset.h:1437
HASH hasher
Definition bdlc_flathashset.h:592
bsl::ostream & print(bsl::ostream &stream, int level=0, int spacesPerLevel=4) const
Definition bdlc_flathashset.h:1585
const value_type * const_pointer
Definition bdlc_flathashset.h:596
bslma::Allocator * allocator() const
Return the allocator used by this flat hash set to supply memory.
Definition bdlc_flathashset.h:1579
EQUAL key_compare
Definition bdlc_flathashset.h:590
friend void swap(FlatHashSet< K, H, E > &, FlatHashSet< K, H, E > &)
value_type * pointer
Definition bdlc_flathashset.h:595
value_type & reference
Definition bdlc_flathashset.h:593
float load_factor() const
Definition bdlc_flathashset.h:1522
const_iterator find(const KEY &key) const
Definition bdlc_flathashset.h:1501
FlatHashSet()
Definition bdlc_flathashset.h:1120
~FlatHashSet()
Destroy this object and each of its elements.
Definition bdlc_flathashset.h:1310
void clear()
Definition bdlc_flathashset.h:1358
const value_type & const_reference
Definition bdlc_flathashset.h:594
void rehash(bsl::size_t minimumCapacity)
Definition bdlc_flathashset.h:1430
ImplType::const_iterator iterator
Definition bdlc_flathashset.h:597
bsl::size_t size() const
Return the number of elements in this set.
Definition bdlc_flathashset.h:1536
const_iterator cbegin() const
Definition bdlc_flathashset.h:1554
KEY value_type
Definition bdlc_flathashset.h:587
const_iterator cend() const
Definition bdlc_flathashset.h:1562
FlatHashSet & operator=(const FlatHashSet &rhs)
Definition bdlc_flathashset.h:1317
bsl::ptrdiff_t difference_type
Definition bdlc_flathashset.h:589
bsl::size_t capacity() const
Definition bdlc_flathashset.h:1463
bsl::size_t erase(const KEY &key)
Definition bdlc_flathashset.h:1387
void reset()
Definition bdlc_flathashset.h:1444
bsl::enable_if< bsl::is_convertible< KEY_TYPE, KEY >::value, const_iterator >::type insert(const_iterator, BSLS_COMPILERFEATURES_FORWARD_REF(KEY_TYPE) value)
Definition bdlc_flathashset.h:862
bsl::size_t size_type
Definition bdlc_flathashset.h:588
ImplType::const_iterator const_iterator
Definition bdlc_flathashset.h:598
bool empty() const
Definition bdlc_flathashset.h:1484
float max_load_factor() const
Definition bdlc_flathashset.h:1529
bool contains(const KEY &key) const
Definition bdlc_flathashset.h:1470
bsl::pair< const_iterator, const_iterator > equal_range(const KEY &key) const
Definition bdlc_flathashset.h:1493
const_iterator end() const
Definition bdlc_flathashset.h:1570
KEY key_type
Definition bdlc_flathashset.h:586
Definition bdlc_flathashtable.h:317
void clear()
Definition bdlc_flathashtable.h:1580
bsl::size_t erase(const KEY &key)
Definition bdlc_flathashtable.h:1632
float max_load_factor() const
Definition bdlc_flathashtable.h:2056
const_iterator cbegin() const
Definition bdlc_flathashtable.h:2092
void swap(FlatHashTable &other)
Definition bdlc_flathashtable.h:1918
void reset()
Definition bdlc_flathashtable.h:1806
bsl::pair< iterator, bool > emplace(ARGS &&... args)
iterator find(const KEY &key)
Definition bdlc_flathashtable.h:1741
iterator end()
Definition bdlc_flathashtable.h:1909
bool empty() const
Definition bdlc_flathashtable.h:1970
bsl::enable_if< bsl::is_convertible< ENTRY_TYPE, ENTRY >::value, bsl::pair< iterator, bool > >::type insert(BSLS_COMPILERFEATURES_FORWARD_REF(ENTRY_TYPE) entry)
Definition bdlc_flathashtable.h:564
bslma::Allocator * allocator() const
Return the allocator used by this hash table to supply memory.
Definition bdlc_flathashtable.h:2118
bsl::size_t capacity() const
Definition bdlc_flathashtable.h:1936
bslstl::ForwardIterator< const KEY, IteratorImp > const_iterator
Definition bdlc_flathashtable.h:334
EQUAL key_eq() const
Definition bdlc_flathashtable.h:2032
bool contains(const KEY &key) const
Definition bdlc_flathashtable.h:1943
iterator begin()
Definition bdlc_flathashtable.h:1892
void reserve(bsl::size_t numEntries)
Definition bdlc_flathashtable.h:1787
const_iterator cend() const
Definition bdlc_flathashtable.h:2100
bsl::size_t size() const
Return the number of entries in this table.
Definition bdlc_flathashtable.h:2064
bsl::size_t count(const KEY &key) const
Definition bdlc_flathashtable.h:1962
HASH hash_function() const
Definition bdlc_flathashtable.h:2025
float load_factor() const
Definition bdlc_flathashtable.h:2043
void rehash(bsl::size_t minimumCapacity)
Definition bdlc_flathashtable.h:1766
bsl::pair< iterator, iterator > equal_range(const KEY &key)
Definition bdlc_flathashtable.h:1599
Definition bslstl_pair.h:1210
static void swap(T *a, T *b)
Definition bslalg_swaputil.h:194
Definition bslh_fibonaccibadhashwrapper.h:165
Definition bslim_printer.h:601
void printValue(const TYPE &data) const
Definition bslim_printer.h:1207
void end(bool suppressBracket=false) const
void start(bool suppressBracket=false) const
Definition bslma_allocator.h:457
Definition bslmf_movableref.h:751
#define BSLS_ASSERT_SAFE(X)
Definition bsls_assert.h:1762
#define BSLS_COMPILERFEATURES_FORWARD_REF(T)
Definition bsls_compilerfeatures.h:2012
#define BSLS_COMPILERFEATURES_FORWARD(T, V)
Definition bsls_compilerfeatures.h:2018
#define BSLS_IDENT(str)
Definition bsls_ident.h:195
Definition bdlc_bitarray.h:503
void swap(BitArray &a, BitArray &b)
bool operator==(const BitArray &lhs, const BitArray &rhs)
bool operator!=(const BitArray &lhs, const BitArray &rhs)
BitArray operator<<(const BitArray &array, bsl::size_t numBits)
T::iterator begin(T &container)
Definition bslstl_iterator.h:1495
T::iterator end(T &container)
Definition bslstl_iterator.h:1523
Definition bdlc_flathashmap.h:1805
Definition balxml_encoderoptions.h:68
Definition bdlbb_blob.h:576
Definition bdlc_flathashset.h:523
static void constructFromKey(ENTRY *entry, bslma::Allocator *allocator, BSLS_COMPILERFEATURES_FORWARD_REF(KEY_TYPE) key)
static const ENTRY & key(const ENTRY &entry)
Return the specified entry.
Definition bdlc_flathashset.h:1108
static void construct(ENTRY *entry, bslma::Allocator *allocator, ARGS &&... args)
Definition bdlc_flathashset.h:1077
Definition bslmf_enableif.h:525
Definition bslstl_equalto.h:311
Definition bslalg_hasstliterators.h:99
static void construct(TARGET_TYPE *address, const ALLOCATOR &allocator)
Definition bslma_constructionutil.h:1243
Definition bslma_usesbslmaallocator.h:343
static MovableRef< t_TYPE > move(t_TYPE &reference) BSLS_KEYWORD_NOEXCEPT
Definition bslmf_movableref.h:1060