BDE 4.14.0 Production release
Loading...
Searching...
No Matches
bsl::set< KEY, COMPARATOR, ALLOCATOR > Class Template Reference

#include <bslstl_set.h>

Public Types

typedef KEY key_type
 
typedef KEY value_type
 
typedef COMPARATOR key_compare
 
typedef COMPARATOR value_compare
 
typedef ALLOCATOR allocator_type
 
typedef value_typereference
 
typedef const value_typeconst_reference
 
typedef AllocatorTraits::size_type size_type
 
typedef AllocatorTraits::difference_type difference_type
 
typedef AllocatorTraits::pointer pointer
 
typedef AllocatorTraits::const_pointer const_pointer
 
typedef BloombergLP::bslstl::TreeIterator< const value_type, Node, difference_typeiterator
 
typedef BloombergLP::bslstl::TreeIterator< const value_type, Node, difference_typeconst_iterator
 
typedef bsl::reverse_iterator< iteratorreverse_iterator
 
typedef bsl::reverse_iterator< const_iteratorconst_reverse_iterator
 

Public Member Functions

 set ()
 
 set (const COMPARATOR &comparator, const ALLOCATOR &basicAllocator=ALLOCATOR())
 
 set (const ALLOCATOR &basicAllocator)
 
 set (const set &original)
 
 set (BloombergLP::bslmf::MovableRef< set > original)
 
 set (const set &original, const typename type_identity< ALLOCATOR >::type &basicAllocator)
 
 set (BloombergLP::bslmf::MovableRef< set > original, const typename type_identity< ALLOCATOR >::type &basicAllocator)
 
template<class INPUT_ITERATOR >
 set (INPUT_ITERATOR first, INPUT_ITERATOR last, const COMPARATOR &comparator=COMPARATOR(), const ALLOCATOR &basicAllocator=ALLOCATOR())
 
template<class INPUT_ITERATOR >
 set (INPUT_ITERATOR first, INPUT_ITERATOR last, const ALLOCATOR &basicAllocator)
 
 ~set ()
 Destroy this object.
 
setoperator= (const set &rhs)
 
set &operator=(BloombergLP::bslmf::MovableRef< set > rhs) BSLS_KEYWORD_NOEXCEPT_SPECIFICATION(AllocatorTraits iterator begin () BSLS_KEYWORD_NOEXCEPT
 
iterator end () BSLS_KEYWORD_NOEXCEPT
 
reverse_iterator rbegin () BSLS_KEYWORD_NOEXCEPT
 
reverse_iterator rend () BSLS_KEYWORD_NOEXCEPT
 
pair< iterator, bool > insert (const value_type &value)
 
pair< iterator, bool > insert (BloombergLP::bslmf::MovableRef< value_type > value)
 
iterator insert (const_iterator hint, const value_type &value)
 
iterator insert (const_iterator hint, BloombergLP::bslmf::MovableRef< value_type > value)
 
template<class INPUT_ITERATOR >
void insert (INPUT_ITERATOR first, INPUT_ITERATOR last)
 
template<class... Args>
pair< iterator, bool > emplace (Args &&... arguments)
 
template<class... Args>
iterator emplace_hint (const_iterator hint, Args &&... arguments)
 
iterator erase (const_iterator position)
 
size_type erase (const key_type &key)
 
iterator erase (const_iterator first, const_iterator last)
 
iterator find (const key_type &key)
 
template<class LOOKUP_KEY >
bsl::enable_if< BloombergLP::bslmf::IsTransparentPredicate< COMPARATOR, LOOKUP_KEY >::value, iterator >::type find (const LOOKUP_KEY &key)
 
iterator lower_bound (const key_type &key)
 
template<class LOOKUP_KEY >
bsl::enable_if< BloombergLP::bslmf::IsTransparentPredicate< COMPARATOR, LOOKUP_KEY >::value, iterator >::type lower_bound (const LOOKUP_KEY &key)
 
iterator upper_bound (const key_type &key)
 
template<class LOOKUP_KEY >
bsl::enable_if< BloombergLP::bslmf::IsTransparentPredicate< COMPARATOR, LOOKUP_KEY >::value, iterator >::type upper_bound (const LOOKUP_KEY &key)
 
pair< iterator, iteratorequal_range (const key_type &key)
 
template<class LOOKUP_KEY >
bsl::enable_if< BloombergLP::bslmf::IsTransparentPredicate< COMPARATOR, LOOKUP_KEY >::value, pair< iterator, iterator > >::type equal_range (const LOOKUP_KEY &key)
 
allocator_type get_allocator () const BSLS_KEYWORD_NOEXCEPT
 
const_iterator begin () const BSLS_KEYWORD_NOEXCEPT
 
const_iterator end () const BSLS_KEYWORD_NOEXCEPT
 
const_reverse_iterator rbegin () const BSLS_KEYWORD_NOEXCEPT
 
const_reverse_iterator rend () const BSLS_KEYWORD_NOEXCEPT
 
const_iterator cbegin () const BSLS_KEYWORD_NOEXCEPT
 
const_iterator cend () const BSLS_KEYWORD_NOEXCEPT
 
const_reverse_iterator crbegin () const BSLS_KEYWORD_NOEXCEPT
 
const_reverse_iterator crend () const BSLS_KEYWORD_NOEXCEPT
 
bool contains (const key_type &key) const
 
template<class LOOKUP_KEY >
bsl::enable_if< BloombergLP::bslmf::IsTransparentPredicate< COMPARATOR, LOOKUP_KEY >::value, bool >::type contains (const LOOKUP_KEY &key) const
 
bool empty () const BSLS_KEYWORD_NOEXCEPT
 
size_type size () const BSLS_KEYWORD_NOEXCEPT
 Return the number of elements in this set.
 
size_type max_size () const BSLS_KEYWORD_NOEXCEPT
 
key_compare key_comp () const
 
value_compare value_comp () const
 
const_iterator find (const key_type &key) const
 
template<class LOOKUP_KEY >
bsl::enable_if< BloombergLP::bslmf::IsTransparentPredicate< COMPARATOR, LOOKUP_KEY >::value, const_iterator >::type find (const LOOKUP_KEY &key) const
 
size_type count (const key_type &key) const
 
template<class LOOKUP_KEY >
bsl::enable_if< BloombergLP::bslmf::IsTransparentPredicate< COMPARATOR, LOOKUP_KEY >::value, size_type >::type count (const LOOKUP_KEY &key) const
 
const_iterator lower_bound (const key_type &key) const
 
template<class LOOKUP_KEY >
bsl::enable_if< BloombergLP::bslmf::IsTransparentPredicate< COMPARATOR, LOOKUP_KEY >::value, const_iterator >::type lower_bound (const LOOKUP_KEY &key) const
 
const_iterator upper_bound (const key_type &key) const
 
template<class LOOKUP_KEY >
bsl::enable_if< BloombergLP::bslmf::IsTransparentPredicate< COMPARATOR, LOOKUP_KEY >::value, const_iterator >::type upper_bound (const LOOKUP_KEY &key) const
 
pair< const_iterator, const_iteratorequal_range (const key_type &key) const
 
template<class LOOKUP_KEY >
bsl::enable_if< BloombergLP::bslmf::IsTransparentPredicate< COMPARATOR, LOOKUP_KEY >::value, pair< const_iterator, const_iterator > >::type equal_range (const LOOKUP_KEY &key) const
 
template<class... Args>
pair< typename set< KEY, COMPARATOR, ALLOCATOR >::iterator, bool > emplace (Args &&... arguments)
 

Public Attributes

void swap(set &other) BSLS_KEYWORD_NOEXCEPT_SPECIFICATION(AllocatorTraits void clear () BSLS_KEYWORD_NOEXCEPT
 

Detailed Description

template<class KEY, class COMPARATOR = std::less<KEY>, class ALLOCATOR = allocator<KEY>>
class bsl::set< KEY, COMPARATOR, ALLOCATOR >

This class template implements a value-semantic container type holding an ordered sequence of unique keys (of the template parameter type, KEY).

This class:

  • supports a complete set of value-semantic operations except for BDEX serialization
  • is exception-neutral (agnostic except for the at method)
  • is alias-safe
  • is const thread-safe For terminology see bsldoc_glossary .

See bslstl_set

Member Typedef Documentation

◆ allocator_type

template<class KEY , class COMPARATOR = std::less<KEY>, class ALLOCATOR = allocator<KEY>>
typedef ALLOCATOR bsl::set< KEY, COMPARATOR, ALLOCATOR >::allocator_type

◆ const_iterator

template<class KEY , class COMPARATOR = std::less<KEY>, class ALLOCATOR = allocator<KEY>>
typedef BloombergLP::bslstl::TreeIterator<const value_type, Node, difference_type> bsl::set< KEY, COMPARATOR, ALLOCATOR >::const_iterator

◆ const_pointer

template<class KEY , class COMPARATOR = std::less<KEY>, class ALLOCATOR = allocator<KEY>>
typedef AllocatorTraits::const_pointer bsl::set< KEY, COMPARATOR, ALLOCATOR >::const_pointer

◆ const_reference

template<class KEY , class COMPARATOR = std::less<KEY>, class ALLOCATOR = allocator<KEY>>
typedef const value_type& bsl::set< KEY, COMPARATOR, ALLOCATOR >::const_reference

◆ const_reverse_iterator

template<class KEY , class COMPARATOR = std::less<KEY>, class ALLOCATOR = allocator<KEY>>
typedef bsl::reverse_iterator<const_iterator> bsl::set< KEY, COMPARATOR, ALLOCATOR >::const_reverse_iterator

◆ difference_type

template<class KEY , class COMPARATOR = std::less<KEY>, class ALLOCATOR = allocator<KEY>>
typedef AllocatorTraits::difference_type bsl::set< KEY, COMPARATOR, ALLOCATOR >::difference_type

◆ iterator

template<class KEY , class COMPARATOR = std::less<KEY>, class ALLOCATOR = allocator<KEY>>
typedef BloombergLP::bslstl::TreeIterator<const value_type, Node, difference_type> bsl::set< KEY, COMPARATOR, ALLOCATOR >::iterator

◆ key_compare

template<class KEY , class COMPARATOR = std::less<KEY>, class ALLOCATOR = allocator<KEY>>
typedef COMPARATOR bsl::set< KEY, COMPARATOR, ALLOCATOR >::key_compare

◆ key_type

template<class KEY , class COMPARATOR = std::less<KEY>, class ALLOCATOR = allocator<KEY>>
typedef KEY bsl::set< KEY, COMPARATOR, ALLOCATOR >::key_type

◆ pointer

template<class KEY , class COMPARATOR = std::less<KEY>, class ALLOCATOR = allocator<KEY>>
typedef AllocatorTraits::pointer bsl::set< KEY, COMPARATOR, ALLOCATOR >::pointer

◆ reference

template<class KEY , class COMPARATOR = std::less<KEY>, class ALLOCATOR = allocator<KEY>>
typedef value_type& bsl::set< KEY, COMPARATOR, ALLOCATOR >::reference

◆ reverse_iterator

template<class KEY , class COMPARATOR = std::less<KEY>, class ALLOCATOR = allocator<KEY>>
typedef bsl::reverse_iterator<iterator> bsl::set< KEY, COMPARATOR, ALLOCATOR >::reverse_iterator

◆ size_type

template<class KEY , class COMPARATOR = std::less<KEY>, class ALLOCATOR = allocator<KEY>>
typedef AllocatorTraits::size_type bsl::set< KEY, COMPARATOR, ALLOCATOR >::size_type

◆ value_compare

template<class KEY , class COMPARATOR = std::less<KEY>, class ALLOCATOR = allocator<KEY>>
typedef COMPARATOR bsl::set< KEY, COMPARATOR, ALLOCATOR >::value_compare

◆ value_type

template<class KEY , class COMPARATOR = std::less<KEY>, class ALLOCATOR = allocator<KEY>>
typedef KEY bsl::set< KEY, COMPARATOR, ALLOCATOR >::value_type

Constructor & Destructor Documentation

◆ set() [1/9]

template<class KEY , class COMPARATOR , class ALLOCATOR >
bsl::set< KEY, COMPARATOR, ALLOCATOR >::set ( )
inline

◆ set() [2/9]

template<class KEY , class COMPARATOR = std::less<KEY>, class ALLOCATOR = allocator<KEY>>
bsl::set< KEY, COMPARATOR, ALLOCATOR >::set ( const COMPARATOR &  comparator,
const ALLOCATOR &  basicAllocator = ALLOCATOR() 
)
inlineexplicit

Create an empty set. Optionally specify a comparator used to order keys contained in this object. If comparator is not supplied, a default-constructed object of the (template parameter) type COMPARATOR is used. Optionally specify a basicAllocator used to supply memory. If basicAllocator is not supplied, a default-constructed object of the (template parameter) type ALLOCATOR is used. If the type ALLOCATOR is bsl::allocator and basicAllocator is not supplied, the currently installed default allocator is used. Note that a bslma::Allocator * can be supplied for basicAllocator if the type ALLOCATOR is bsl::allocator (the default).

◆ set() [3/9]

template<class KEY , class COMPARATOR , class ALLOCATOR >
bsl::set< KEY, COMPARATOR, ALLOCATOR >::set ( const ALLOCATOR &  basicAllocator)
inlineexplicit

Create an empty set that uses the specified basicAllocator to supply memory. Use a default-constructed object of the (template parameter) type COMPARATOR to order the keys contained in this set. Note that a bslma::Allocator * can be supplied for basicAllocator if the (template parameter) type ALLOCATOR is bsl::allocator (the default).

◆ set() [4/9]

template<class KEY , class COMPARATOR , class ALLOCATOR >
bsl::set< KEY, COMPARATOR, ALLOCATOR >::set ( const set< KEY, COMPARATOR, ALLOCATOR > &  original)
inline

Create a set having the same value as the specified original object. Use a copy of original.key_comp() to order the keys contained in this set. Use the allocator returned by bsl::allocator_traits<ALLOCATOR>:: select_on_container_copy_construction(original.get_allocator()) to allocate memory. This method requires that the (template parameter) type KEY be copy-insertable into this set (see {Requirements on KEY}).

◆ set() [5/9]

template<class KEY , class COMPARATOR , class ALLOCATOR >
bsl::set< KEY, COMPARATOR, ALLOCATOR >::set ( BloombergLP::bslmf::MovableRef< set< KEY, COMPARATOR, ALLOCATOR > >  original)
inline

Create a set having the same value as the specified original object by moving (in constant time) the contents of original to the new set. Use a copy of original.key_comp() to order the keys contained in this set. The allocator associated with original is propagated for use in the newly-created set. original is left in a valid but unspecified state.

◆ set() [6/9]

template<class KEY , class COMPARATOR , class ALLOCATOR >
bsl::set< KEY, COMPARATOR, ALLOCATOR >::set ( const set< KEY, COMPARATOR, ALLOCATOR > &  original,
const typename type_identity< ALLOCATOR >::type &  basicAllocator 
)
inline

Create a set having the same value as the specified original object that uses the specified basicAllocator to supply memory. Use a copy of original.key_comp() to order the keys contained in this set. This method requires that the (template parameter) type KEY be copy-insertable into this set (see {Requirements on KEY}). Note that a bslma::Allocator * can be supplied for basicAllocator if the (template parameter) type ALLOCATOR is bsl::allocator (the default).

◆ set() [7/9]

template<class KEY , class COMPARATOR , class ALLOCATOR >
bsl::set< KEY, COMPARATOR, ALLOCATOR >::set ( BloombergLP::bslmf::MovableRef< set< KEY, COMPARATOR, ALLOCATOR > >  original,
const typename type_identity< ALLOCATOR >::type &  basicAllocator 
)
inline

Create a set having the same value as the specified original object that uses the specified basicAllocator to supply memory. The contents of original are moved (in constant time) to the new set if basicAllocator == original.get_allocator(), and are move- inserted (in linear time) using basicAllocator otherwise. original is left in a valid but unspecified state. Use a copy of original.key_comp() to order the keys contained in this set. This method requires that the (template parameter) type KEY be move-insertable into this set (see {Requirements on KEY}). Note that a bslma::Allocator * can be supplied for basicAllocator if the (template parameter) type ALLOCATOR is bsl::allocator (the default).

◆ set() [8/9]

template<class KEY , class COMPARATOR , class ALLOCATOR >
template<class INPUT_ITERATOR >
bsl::set< KEY, COMPARATOR, ALLOCATOR >::set ( INPUT_ITERATOR  first,
INPUT_ITERATOR  last,
const COMPARATOR &  comparator = COMPARATOR(),
const ALLOCATOR &  basicAllocator = ALLOCATOR() 
)
inline

Create a set, and insert each value_type object in the sequence starting at the specified first element, and ending immediately before the specified last element, ignoring those keys having a value equivalent to that which appears earlier in the sequence. Optionally specify a comparator used to order keys contained in this object. If comparator is not supplied, a default-constructed object of the (template parameter) type COMPARATOR is used. Optionally specify a basicAllocator used to supply memory. If basicAllocator is not supplied, a default-constructed object of the (template parameter) type ALLOCATOR is used. If the type ALLOCATOR is bsl::allocator and basicAllocator is not supplied, the currently installed default allocator is used. If the sequence first to last is ordered according to comparator, then this operation has O[N] complexity, where N is the number of elements between first and last, otherwise this operation has O[N * log(N)] complexity. The (template parameter) type INPUT_ITERATOR shall meet the requirements of an input iterator defined in the C++11 standard [24.2.3] providing access to values of a type convertible to value_type, and value_type must be emplace-constructible from *i into this set, where i is a dereferenceable iterator in the range [first .. last) (see {Requirements on KEY}). The behavior is undefined unless first and last refer to a sequence of valid values where first is at a position at or before last. Note that a bslma::Allocator * can be supplied for basicAllocator if the type ALLOCATOR is bsl::allocator (the default).

◆ set() [9/9]

template<class KEY , class COMPARATOR , class ALLOCATOR >
template<class INPUT_ITERATOR >
bsl::set< KEY, COMPARATOR, ALLOCATOR >::set ( INPUT_ITERATOR  first,
INPUT_ITERATOR  last,
const ALLOCATOR &  basicAllocator 
)
inline

◆ ~set()

template<class KEY , class COMPARATOR , class ALLOCATOR >
bsl::set< KEY, COMPARATOR, ALLOCATOR >::~set ( )
inline

Member Function Documentation

◆ begin() [1/2]

template<class KEY , class COMPARATOR , class ALLOCATOR >
set< KEY, COMPARATOR, ALLOCATOR >::iterator bsl::set< KEY, COMPARATOR, ALLOCATOR >::begin ( )
inline

Assign to this object the value and comparator of the specified rhs object, propagate to this object the allocator of rhs if the ALLOCATOR type has trait propagate_on_container_move_assignment, and return a reference providing modifiable access to this object. The contents of rhs are moved (in constant time) to this set if get_allocator() == rhs.get_allocator() (after accounting for the aforementioned trait); otherwise, all elements in this set are either destroyed or move-assigned to and each additional element in rhs is move-inserted into this set. rhs is left in a valid but unspecified state, and if an exception is thrown, *this is left in a valid but unspecified state. This method requires that the (template parameter) type KEY be move-assignable and move-insertable into this set (see {Requirements on KEY}). Return an iterator providing modifiable access to the first value_type object in the ordered sequence of value_type objects maintained by this set, or the end iterator if this set is empty.

◆ begin() [2/2]

template<class KEY , class COMPARATOR , class ALLOCATOR >
set< KEY, COMPARATOR, ALLOCATOR >::const_iterator bsl::set< KEY, COMPARATOR, ALLOCATOR >::begin ( ) const
inline

Return an iterator providing non-modifiable access to the first value_type object in the ordered sequence of value_type objects maintained by this set, or the end iterator if this set is empty.

◆ cbegin()

template<class KEY , class COMPARATOR , class ALLOCATOR >
set< KEY, COMPARATOR, ALLOCATOR >::const_iterator bsl::set< KEY, COMPARATOR, ALLOCATOR >::cbegin ( ) const
inline

Return an iterator providing non-modifiable access to the first value_type object in the ordered sequence of value_type objects maintained by this set, or the cend iterator if this set is empty.

◆ cend()

template<class KEY , class COMPARATOR , class ALLOCATOR >
set< KEY, COMPARATOR, ALLOCATOR >::const_iterator bsl::set< KEY, COMPARATOR, ALLOCATOR >::cend ( ) const
inline

Return an iterator providing non-modifiable access to the past-the-end element in the ordered sequence of value_type objects maintained by this set.

◆ contains() [1/2]

template<class KEY , class COMPARATOR , class ALLOCATOR >
bool bsl::set< KEY, COMPARATOR, ALLOCATOR >::contains ( const key_type key) const
inline

Return true if this map contains an element whose key is equivalent to the specified key.

◆ contains() [2/2]

template<class KEY , class COMPARATOR = std::less<KEY>, class ALLOCATOR = allocator<KEY>>
template<class LOOKUP_KEY >
bsl::enable_if< BloombergLP::bslmf::IsTransparentPredicate< COMPARATOR, LOOKUP_KEY >::value, bool >::type bsl::set< KEY, COMPARATOR, ALLOCATOR >::contains ( const LOOKUP_KEY &  key) const
inline

Return true if this map contains an element whose key is equivalent to the specified key.

Note: implemented inline due to Sun CC compilation error

◆ count() [1/2]

template<class KEY , class COMPARATOR = std::less<KEY>, class ALLOCATOR = allocator<KEY>>
size_type bsl::set< KEY, COMPARATOR, ALLOCATOR >::count ( const key_type key) const
inline

Return the number of value_type objects within this set that are equivalent to the specified key. Note that since a set maintains unique keys, the returned value will be either 0 or 1.

Note: implemented inline due to Sun CC compilation error.

◆ count() [2/2]

template<class KEY , class COMPARATOR = std::less<KEY>, class ALLOCATOR = allocator<KEY>>
template<class LOOKUP_KEY >
bsl::enable_if< BloombergLP::bslmf::IsTransparentPredicate< COMPARATOR, LOOKUP_KEY >::value, size_type >::type bsl::set< KEY, COMPARATOR, ALLOCATOR >::count ( const LOOKUP_KEY &  key) const
inline

Return the number of value_type objects within this set that are equivalent to the specified key. Note that although a set maintains unique keys, the returned value can be other than 0 or 1, because a transparent comparator may have been supplied that provides a different (but compatible) partitioning of keys for LOOKUP_KEY as the comparisons used to order the keys in the set.

Note: implemented inline due to Sun CC compilation error.

◆ crbegin()

template<class KEY , class COMPARATOR , class ALLOCATOR >
set< KEY, COMPARATOR, ALLOCATOR >::const_reverse_iterator bsl::set< KEY, COMPARATOR, ALLOCATOR >::crbegin ( ) const
inline

Return a reverse iterator providing non-modifiable access to the last value_type object in the ordered sequence of value_type objects maintained by this set, or crend if this set is empty.

◆ crend()

template<class KEY , class COMPARATOR , class ALLOCATOR >
set< KEY, COMPARATOR, ALLOCATOR >::const_reverse_iterator bsl::set< KEY, COMPARATOR, ALLOCATOR >::crend ( ) const
inline

Return a reverse iterator providing non-modifiable access to the prior-to-the-beginning element in the ordered sequence of value_type objects maintained by this set.

◆ emplace() [1/2]

template<class KEY , class COMPARATOR = std::less<KEY>, class ALLOCATOR = allocator<KEY>>
template<class... Args>
pair< iterator, bool > bsl::set< KEY, COMPARATOR, ALLOCATOR >::emplace ( Args &&...  arguments)

Insert into this set a newly created value_type object, constructed by forwarding get_allocator() (if required) and the specified (variable number of) arguments to the corresponding constructor of value_type, if a key equivalent to such a value does not already exist in this set; otherwise, this method has no effect (other than possibly creating a temporary value_type object). Return a pair whose first member is an iterator referring to the (possibly newly created and inserted) object in this set whose value is equivalent to that of an object constructed from arguments, and whose second member is true if a new value was inserted, and false if an equivalent key was already present. This method requires that the (template parameter) type KEY be emplace-constructible from arguments (see {Requirements on KEY}).

◆ emplace() [2/2]

template<class KEY , class COMPARATOR = std::less<KEY>, class ALLOCATOR = allocator<KEY>>
template<class... Args>
pair< typename set< KEY, COMPARATOR, ALLOCATOR >::iterator, bool > bsl::set< KEY, COMPARATOR, ALLOCATOR >::emplace ( Args &&...  arguments)
inline

◆ emplace_hint()

template<class KEY , class COMPARATOR , class ALLOCATOR >
template<class... Args>
set< KEY, COMPARATOR, ALLOCATOR >::iterator bsl::set< KEY, COMPARATOR, ALLOCATOR >::emplace_hint ( const_iterator  hint,
Args &&...  arguments 
)
inline

Insert into this set a newly created value_type object, constructed by forwarding get_allocator() (if required) and the specified (variable number of) arguments to the corresponding constructor of value_type, (in amortized constant time if the specified hint is a valid immediate successor to the value_type object constructed from arguments), if a key equivalent to such a value does not already exist in this set; otherwise, this method has no effect (other than possibly creating a temporary value_type object). Return an iterator referring to the (possibly newly created and inserted) object in this set whose value is equivalent to that of an object constructed from arguments. If hint is not a valid immediate successor to the value_type object implied by arguments, this operation has O[log(N)] complexity where N is the size of this set. This method requires that the (template parameter) type KEY be emplace-constructible from arguments (see {Requirements on KEY}). The behavior is undefined unless hint is an iterator in the range [begin() .. end()] (both endpoints included).

◆ empty()

template<class KEY , class COMPARATOR , class ALLOCATOR >
bool bsl::set< KEY, COMPARATOR, ALLOCATOR >::empty ( ) const
inline

Return true if this set contains no elements, and false otherwise.

◆ end() [1/2]

template<class KEY , class COMPARATOR , class ALLOCATOR >
set< KEY, COMPARATOR, ALLOCATOR >::iterator bsl::set< KEY, COMPARATOR, ALLOCATOR >::end ( )
inline

Return an iterator providing modifiable access to the past-the-end element in the ordered sequence of value_type objects maintained by this set.

◆ end() [2/2]

template<class KEY , class COMPARATOR , class ALLOCATOR >
set< KEY, COMPARATOR, ALLOCATOR >::const_iterator bsl::set< KEY, COMPARATOR, ALLOCATOR >::end ( ) const
inline

Return an iterator providing non-modifiable access to the past-the-end element in the ordered sequence of value_type objects maintained by this set.

◆ equal_range() [1/4]

template<class KEY , class COMPARATOR = std::less<KEY>, class ALLOCATOR = allocator<KEY>>
pair< iterator, iterator > bsl::set< KEY, COMPARATOR, ALLOCATOR >::equal_range ( const key_type key)
inline

Return a pair of iterators providing modifiable access to the sequence of value_type objects in this set that are equivalent to the specified key, where the first iterator is positioned at the start of the sequence, and the second is positioned one past the end of the sequence. The first returned iterator will be lower_bound(key); the second returned iterator will be upper_bound(key); and, if this set contains no value_type objects equivalent to key, then the two returned iterators will have the same value. Note that since a set maintains unique keys, the range will contain at most one element.

Note: implemented inline due to Sun CC compilation error.

◆ equal_range() [2/4]

template<class KEY , class COMPARATOR = std::less<KEY>, class ALLOCATOR = allocator<KEY>>
pair< const_iterator, const_iterator > bsl::set< KEY, COMPARATOR, ALLOCATOR >::equal_range ( const key_type key) const
inline

Return a pair of iterators providing non-modifiable access to the sequence of value_type objects in this set that are equivalent to the specified key, where the first iterator is positioned at the start of the sequence, and the second is positioned one past the end of the sequence. The first returned iterator will be lower_bound(key); the second returned iterator will be upper_bound(key); and, if this set contains no value_type objects equivalent to key, then the two returned iterators will have the same value. Note that since a set maintains unique keys, the range will contain at most one element.

Note: implemented inline due to Sun CC compilation error.

◆ equal_range() [3/4]

template<class KEY , class COMPARATOR = std::less<KEY>, class ALLOCATOR = allocator<KEY>>
template<class LOOKUP_KEY >
bsl::enable_if< BloombergLP::bslmf::IsTransparentPredicate< COMPARATOR, LOOKUP_KEY >::value, pair< iterator, iterator > >::type bsl::set< KEY, COMPARATOR, ALLOCATOR >::equal_range ( const LOOKUP_KEY &  key)
inline

Return a pair of iterators providing modifiable access to the sequence of value_type objects in this set that are equivalent to the specified key, where the first iterator is positioned at the start of the sequence, and the second is positioned one past the end of the sequence. The first returned iterator will be lower_bound(key); the second returned iterator will be upper_bound(key); and, if this set contains no value_type objects equivalent to key, then the two returned iterators will have the same value. Note that although a set maintains unique keys, the range may contain more than one element, because a transparent comparator may have been supplied that provides a different (but compatible) partitioning of keys for LOOKUP_KEY as the comparisons used to order the keys in the set.

Note: implemented inline due to Sun CC compilation error.

◆ equal_range() [4/4]

template<class KEY , class COMPARATOR = std::less<KEY>, class ALLOCATOR = allocator<KEY>>
template<class LOOKUP_KEY >
bsl::enable_if< BloombergLP::bslmf::IsTransparentPredicate< COMPARATOR, LOOKUP_KEY >::value, pair< const_iterator, const_iterator > >::type bsl::set< KEY, COMPARATOR, ALLOCATOR >::equal_range ( const LOOKUP_KEY &  key) const
inline

Return a pair of iterators providing non-modifiable access to the sequence of value_type objects in this set that are equivalent to the specified key, where the first iterator is positioned at the start of the sequence, and the second is positioned one past the end of the sequence. The first returned iterator will be lower_bound(key); the second returned iterator will be upper_bound(key); and, if this set contains no value_type objects equivalent to key, then the two returned iterators will have the same value. Note that although a set maintains unique keys, the range may contain more than one element, because a transparent comparator may have been supplied that provides a different (but compatible) partitioning of keys for LOOKUP_KEY as the comparisons used to order the keys in the set.

Note: implemented inline due to Sun CC compilation error.

◆ erase() [1/3]

template<class KEY , class COMPARATOR , class ALLOCATOR >
set< KEY, COMPARATOR, ALLOCATOR >::size_type bsl::set< KEY, COMPARATOR, ALLOCATOR >::erase ( const key_type key)
inline

Remove from this set the value_type object that is equivalent to the specified key, if such an entry exists, and return 1; otherwise, if there is no value_type object that is equivalent to key, return 0 with no other effect. This method invalidates only iterators and references to the removed element and previously saved values of the end() iterator.

◆ erase() [2/3]

template<class KEY , class COMPARATOR , class ALLOCATOR >
set< KEY, COMPARATOR, ALLOCATOR >::iterator bsl::set< KEY, COMPARATOR, ALLOCATOR >::erase ( const_iterator  first,
const_iterator  last 
)
inline

Remove from this set the value_type objects starting at the specified first position up to, but including the specified last position, and return last. This method invalidates only iterators and references to the removed element and previously saved values of the end() iterator. The behavior is undefined unless first and last either refer to elements in this set or are the end iterator, and the first position is at or before the last position in the ordered sequence provided by this container.

◆ erase() [3/3]

template<class KEY , class COMPARATOR , class ALLOCATOR >
set< KEY, COMPARATOR, ALLOCATOR >::iterator bsl::set< KEY, COMPARATOR, ALLOCATOR >::erase ( const_iterator  position)
inline

Remove from this set the value_type object at the specified position, and return an iterator referring to the element immediately following the removed element, or to the past-the-end position if the removed element was the last element in the sequence of elements maintained by this set. This method invalidates only iterators and references to the removed element and previously saved values of the end() iterator. The behavior is undefined unless position refers to a value_type object in this set.

◆ find() [1/4]

template<class KEY , class COMPARATOR = std::less<KEY>, class ALLOCATOR = allocator<KEY>>
iterator bsl::set< KEY, COMPARATOR, ALLOCATOR >::find ( const key_type key)
inline

Return an iterator providing modifiable access to the value_type object in this set that is equivalent to the specified key, if such an entry exists, and the past-the-end (end) iterator otherwise.

Note: implemented inline due to Sun CC compilation error.

◆ find() [2/4]

template<class KEY , class COMPARATOR = std::less<KEY>, class ALLOCATOR = allocator<KEY>>
const_iterator bsl::set< KEY, COMPARATOR, ALLOCATOR >::find ( const key_type key) const
inline

Return an iterator providing non-modifiable access to the value_type object in this set that is equivalent to the specified key, if such an entry exists, and the past-the-end (end) iterator otherwise.

Note: implemented inline due to Sun CC compilation error.

◆ find() [3/4]

template<class KEY , class COMPARATOR = std::less<KEY>, class ALLOCATOR = allocator<KEY>>
template<class LOOKUP_KEY >
bsl::enable_if< BloombergLP::bslmf::IsTransparentPredicate< COMPARATOR, LOOKUP_KEY >::value, iterator >::type bsl::set< KEY, COMPARATOR, ALLOCATOR >::find ( const LOOKUP_KEY &  key)
inline

Return an iterator providing modifiable access to the value_type object in this set that is equivalent to the specified key, if such an entry exists, and the past-the-end (end) iterator otherwise.

Note: implemented inline due to Sun CC compilation error.

◆ find() [4/4]

template<class KEY , class COMPARATOR = std::less<KEY>, class ALLOCATOR = allocator<KEY>>
template<class LOOKUP_KEY >
bsl::enable_if< BloombergLP::bslmf::IsTransparentPredicate< COMPARATOR, LOOKUP_KEY >::value, const_iterator >::type bsl::set< KEY, COMPARATOR, ALLOCATOR >::find ( const LOOKUP_KEY &  key) const
inline

Return an iterator providing non-modifiable access to the value_type object in this set that is equivalent to the specified key, if such an entry exists, and the past-the-end (end) iterator otherwise.

Note: implemented inline due to Sun CC compilation error.

◆ get_allocator()

template<class KEY , class COMPARATOR , class ALLOCATOR >
set< KEY, COMPARATOR, ALLOCATOR >::allocator_type bsl::set< KEY, COMPARATOR, ALLOCATOR >::get_allocator ( ) const
inline

Return (a copy of) the allocator used for memory allocation by this set.

◆ insert() [1/5]

template<class KEY , class COMPARATOR , class ALLOCATOR >
pair< typename set< KEY, COMPARATOR, ALLOCATOR >::iterator, bool > bsl::set< KEY, COMPARATOR, ALLOCATOR >::insert ( BloombergLP::bslmf::MovableRef< value_type value)
inline

Insert the specified value into this set if a key equivalent to value does not already exist in this set; otherwise, if a key equivalent to value already exists in this set, this method has no effect. value is left in a valid but unspecified state. Return a pair whose first member is an iterator referring to the (possibly newly inserted) value_type object in this set that is equivalent to value, and whose second member is true if a new value was inserted, and false if the key was already present. This method requires that the (template parameter) type KEY be move-insertable (see {Requirements on KEY}).

◆ insert() [2/5]

template<class KEY , class COMPARATOR , class ALLOCATOR >
pair< typename set< KEY, COMPARATOR, ALLOCATOR >::iterator, bool > bsl::set< KEY, COMPARATOR, ALLOCATOR >::insert ( const value_type value)
inline

Insert the specified value into this set if a key equivalent to value does not already exist in this set; otherwise, if a key equivalent to value already exists in this set, this method has no effect. Return a pair whose first member is an iterator referring to the (possibly newly inserted) value_type object in this set that is equivalent to value, and whose second member is true if a new value was inserted, and false if the key was already present. This method requires that the (template parameter) type KEY be copy-insertable into this set (see {Requirements on KEY}).

◆ insert() [3/5]

template<class KEY , class COMPARATOR , class ALLOCATOR >
set< KEY, COMPARATOR, ALLOCATOR >::iterator bsl::set< KEY, COMPARATOR, ALLOCATOR >::insert ( const_iterator  hint,
BloombergLP::bslmf::MovableRef< value_type value 
)
inline

Insert the specified value into this set (in amortized constant time if the specified hint is a valid immediate successor to value) if a key equivalent to value does not already exist in this set; otherwise, this method has no effect. value is left in a valid but unspecified state. Return an iterator referring to the (possibly newly inserted) value_type object in this set that is equivalent to value. If hint is not a valid immediate successor to value, this operation has O[log(N)] complexity, where N is the size of this set. This method requires that the (template parameter) type KEY be move-insertable (see {Requirements on KEY}). The behavior is undefined unless hint is an iterator in the range [begin() .. end()] (both endpoints included).

◆ insert() [4/5]

template<class KEY , class COMPARATOR , class ALLOCATOR >
set< KEY, COMPARATOR, ALLOCATOR >::iterator bsl::set< KEY, COMPARATOR, ALLOCATOR >::insert ( const_iterator  hint,
const value_type value 
)
inline

Insert the specified value into this set (in amortized constant time if the specified hint is a valid immediate successor to value), if a key equivalent to value does not already exist in this set; otherwise, if a key equivalent to value already exists in this set, this method has no effect. Return an iterator referring to the (possibly newly inserted) value_type object in this set that is equivalent to value. If hint is not a valid immediate successor to value, this operation has O[log(N)] complexity, where N is the size of this set. This method requires that the (template parameter) type KEY be copy-insertable into this set (see {Requirements on KEY}). The behavior is undefined unless hint is an iterator in the range [begin() .. end()] (both endpoints included).

◆ insert() [5/5]

template<class KEY , class COMPARATOR , class ALLOCATOR >
template<class INPUT_ITERATOR >
void bsl::set< KEY, COMPARATOR, ALLOCATOR >::insert ( INPUT_ITERATOR  first,
INPUT_ITERATOR  last 
)
inline

Insert into this set the value of each value_type object in the range starting at the specified first iterator and ending immediately before the specified last iterator, if a key equivalent to the object is not already contained in this set. The (template parameter) type INPUT_ITERATOR shall meet the requirements of an input iterator defined in the C++11 standard [24.2.3] providing access to values of a type convertible to value_type, and value_type must be emplace-constructible from *i into this set, where i is a dereferenceable iterator in the range [first .. last) (see {Requirements on KEY}). The behavior is undefined unless first and last refer to a sequence of valid values where first is at a position at or before last.

Implementation Notes

◆ key_comp()

template<class KEY , class COMPARATOR , class ALLOCATOR >
set< KEY, COMPARATOR, ALLOCATOR >::key_compare bsl::set< KEY, COMPARATOR, ALLOCATOR >::key_comp ( ) const
inline

Return the key-comparison functor (or function pointer) used by this set; if a comparator was supplied at construction, return its value, otherwise return a default constructed key_compare object. Note that this comparator compares objects of type KEY, which is the type of the value_type objects contained in this set.

◆ lower_bound() [1/4]

template<class KEY , class COMPARATOR = std::less<KEY>, class ALLOCATOR = allocator<KEY>>
iterator bsl::set< KEY, COMPARATOR, ALLOCATOR >::lower_bound ( const key_type key)
inline

Return an iterator providing modifiable access to the first (i.e., ordered least) value_type object in this set greater-than or equal-to the specified key, and the past-the-end iterator if this set does not contain a value_type object greater-than or equal-to key. Note that this function returns the first position before which a value_type object equivalent to key could be inserted into the ordered sequence maintained by this set, while preserving its ordering.

Note: implemented inline due to Sun CC compilation error.

◆ lower_bound() [2/4]

template<class KEY , class COMPARATOR = std::less<KEY>, class ALLOCATOR = allocator<KEY>>
const_iterator bsl::set< KEY, COMPARATOR, ALLOCATOR >::lower_bound ( const key_type key) const
inline

Return an iterator providing non-modifiable access to the first (i.e., ordered least) value_type object in this set greater-than or equal-to the specified key, and the past-the-end iterator if this set does not contain a value_type greater-than or equal-to key. Note that this function returns the first position before which a value_type object equivalent to key could be inserted into the ordered sequence maintained by this set, while preserving its ordering.

Note: implemented inline due to Sun CC compilation error.

◆ lower_bound() [3/4]

template<class KEY , class COMPARATOR = std::less<KEY>, class ALLOCATOR = allocator<KEY>>
template<class LOOKUP_KEY >
bsl::enable_if< BloombergLP::bslmf::IsTransparentPredicate< COMPARATOR, LOOKUP_KEY >::value, iterator >::type bsl::set< KEY, COMPARATOR, ALLOCATOR >::lower_bound ( const LOOKUP_KEY &  key)
inline

Return an iterator providing modifiable access to the first (i.e., ordered least) value_type object in this set greater-than or equal-to the specified key, and the past-the-end iterator if this set does not contain a value_type object greater-than or equal-to key. Note that this function returns the first position before which a value_type object equivalent to key could be inserted into the ordered sequence maintained by this set, while preserving its ordering.

Note: implemented inline due to Sun CC compilation error.

◆ lower_bound() [4/4]

template<class KEY , class COMPARATOR = std::less<KEY>, class ALLOCATOR = allocator<KEY>>
template<class LOOKUP_KEY >
bsl::enable_if< BloombergLP::bslmf::IsTransparentPredicate< COMPARATOR, LOOKUP_KEY >::value, const_iterator >::type bsl::set< KEY, COMPARATOR, ALLOCATOR >::lower_bound ( const LOOKUP_KEY &  key) const
inline

Return an iterator providing non-modifiable access to the first (i.e., ordered least) value_type object in this set greater-than or equal-to the specified key, and the past-the-end iterator if this set does not contain a value_type greater-than or equal-to key. Note that this function returns the first position before which a value_type object equivalent to key could be inserted into the ordered sequence maintained by this set, while preserving its ordering.

Note: implemented inline due to Sun CC compilation error.

◆ max_size()

template<class KEY , class COMPARATOR , class ALLOCATOR >
set< KEY, COMPARATOR, ALLOCATOR >::size_type bsl::set< KEY, COMPARATOR, ALLOCATOR >::max_size ( ) const
inline

Return a theoretical upper bound on the largest number of elements that this set could possibly hold. Note that there is no guarantee that the set can successfully grow to the returned size, or even close to that size without running out of resources.

◆ operator=()

template<class KEY , class COMPARATOR , class ALLOCATOR >
set< KEY, COMPARATOR, ALLOCATOR > & bsl::set< KEY, COMPARATOR, ALLOCATOR >::operator= ( const set< KEY, COMPARATOR, ALLOCATOR > &  rhs)
inline

Assign to this object the value and comparator of the specified rhs object, propagate to this object the allocator of rhs if the ALLOCATOR type has trait propagate_on_container_copy_assignment, and return a reference providing modifiable access to this object. If an exception is thrown, *this is left in a valid but unspecified state. This method requires that the (template parameter) type KEY be copy-assignable and copy-insertable into this set (see {Requirements on KEY}).

◆ rbegin() [1/2]

template<class KEY , class COMPARATOR , class ALLOCATOR >
set< KEY, COMPARATOR, ALLOCATOR >::reverse_iterator bsl::set< KEY, COMPARATOR, ALLOCATOR >::rbegin ( )
inline

Return a reverse iterator providing modifiable access to the last value_type object in the ordered sequence of value_type objects maintained by this set, or rend if this object is empty.

◆ rbegin() [2/2]

template<class KEY , class COMPARATOR , class ALLOCATOR >
set< KEY, COMPARATOR, ALLOCATOR >::const_reverse_iterator bsl::set< KEY, COMPARATOR, ALLOCATOR >::rbegin ( ) const
inline

Return a reverse iterator providing non-modifiable access to the last value_type object in the ordered sequence of value_type objects maintained by this set, or rend if this object is empty.

◆ rend() [1/2]

template<class KEY , class COMPARATOR , class ALLOCATOR >
set< KEY, COMPARATOR, ALLOCATOR >::reverse_iterator bsl::set< KEY, COMPARATOR, ALLOCATOR >::rend ( )
inline

Return a reverse iterator providing modifiable access to the prior-to-the-beginning element in the ordered sequence of value_type objects maintained by this set.

◆ rend() [2/2]

template<class KEY , class COMPARATOR , class ALLOCATOR >
set< KEY, COMPARATOR, ALLOCATOR >::const_reverse_iterator bsl::set< KEY, COMPARATOR, ALLOCATOR >::rend ( ) const
inline

Return a reverse iterator providing non-modifiable access to the prior-to-the-beginning element in the ordered sequence of value_type objects maintained by this set.

◆ size()

template<class KEY , class COMPARATOR , class ALLOCATOR >
set< KEY, COMPARATOR, ALLOCATOR >::size_type bsl::set< KEY, COMPARATOR, ALLOCATOR >::size ( ) const
inline

◆ upper_bound() [1/4]

template<class KEY , class COMPARATOR = std::less<KEY>, class ALLOCATOR = allocator<KEY>>
iterator bsl::set< KEY, COMPARATOR, ALLOCATOR >::upper_bound ( const key_type key)
inline

Return an iterator providing modifiable access to the first (i.e., ordered least) value_type object in this set greater than the specified key, and the past-the-end iterator if this set does not contain a value_type object greater-than key. Note that this function returns the last position before which a value_type object equivalent to key could be inserted into the ordered sequence maintained by this set, while preserving its ordering.

Note: implemented inline due to Sun CC compilation error.

◆ upper_bound() [2/4]

template<class KEY , class COMPARATOR = std::less<KEY>, class ALLOCATOR = allocator<KEY>>
const_iterator bsl::set< KEY, COMPARATOR, ALLOCATOR >::upper_bound ( const key_type key) const
inline

Return an iterator providing non-modifiable access to the first (i.e., ordered least) value_type object in this set greater than the specified key, and the past-the-end iterator if this set does not contain a value_type object greater-than key. Note that this function returns the last position before which a value_type object equivalent to key could be inserted into the ordered sequence maintained by this set, while preserving its ordering.

Note: implemented inline due to Sun CC compilation error.

◆ upper_bound() [3/4]

template<class KEY , class COMPARATOR = std::less<KEY>, class ALLOCATOR = allocator<KEY>>
template<class LOOKUP_KEY >
bsl::enable_if< BloombergLP::bslmf::IsTransparentPredicate< COMPARATOR, LOOKUP_KEY >::value, iterator >::type bsl::set< KEY, COMPARATOR, ALLOCATOR >::upper_bound ( const LOOKUP_KEY &  key)
inline

Return an iterator providing modifiable access to the first (i.e., ordered least) value_type object in this set greater than the specified key, and the past-the-end iterator if this set does not contain a value_type object greater-than key. Note that this function returns the last position before which a value_type object equivalent to key could be inserted into the ordered sequence maintained by this set, while preserving its ordering.

Note: implemented inline due to Sun CC compilation error.

◆ upper_bound() [4/4]

template<class KEY , class COMPARATOR = std::less<KEY>, class ALLOCATOR = allocator<KEY>>
template<class LOOKUP_KEY >
bsl::enable_if< BloombergLP::bslmf::IsTransparentPredicate< COMPARATOR, LOOKUP_KEY >::value, const_iterator >::type bsl::set< KEY, COMPARATOR, ALLOCATOR >::upper_bound ( const LOOKUP_KEY &  key) const
inline

Return an iterator providing non-modifiable access to the first (i.e., ordered least) value_type object in this set greater than the specified key, and the past-the-end iterator if this set does not contain a value_type object greater-than key. Note that this function returns the last position before which a value_type object equivalent to key could be inserted into the ordered sequence maintained by this set, while preserving its ordering.

Note: implemented inline due to Sun CC compilation error.

◆ value_comp()

template<class KEY , class COMPARATOR , class ALLOCATOR >
set< KEY, COMPARATOR, ALLOCATOR >::value_compare bsl::set< KEY, COMPARATOR, ALLOCATOR >::value_comp ( ) const
inline

Return a functor for comparing two value_type objects using key_comp(). Note that since value_type is an alias to KEY for set, this method returns the same functor as key_comp().

Member Data Documentation

◆ clear

template<class KEY , class COMPARATOR , class ALLOCATOR >
void bsl::set< KEY, COMPARATOR, ALLOCATOR >::clear
inline

Exchange the value and comparator of this object with those of the specified other object; also exchange the allocator of this object with that of other if the (template parameter) type ALLOCATOR has the propagate_on_container_swap trait, and do not modify either allocator otherwise. This method provides the no-throw exception-safety guarantee if and only if the (template parameter) type COMPARATOR provides a no-throw swap operation, and provides the basic exception-safety guarantee otherwise; if an exception is thrown, both objects are left in valid but unspecified states. This operation has O[1] complexity if either this object was created with the same allocator as other or ALLOCATOR has the propagate_on_container_swap trait; otherwise, it has O[n + m] complexity, where n and m are the number of elements in this object and other, respectively. Note that this methods support for swapping objects created with different allocators when ALLOCATORdoes not have thepropagate_on_container_swap` trait is a departure from the C++ Standard. Remove all entries from this set. Note that the set is empty after this call, but allocated memory may be retained for future use.


The documentation for this class was generated from the following file: