Quick Links: |
Provide an STL-compliant set class. More...
Classes | |
class | bsl::set< KEY, COMPARATOR, ALLOCATOR > |
class | bsl::set< KEY, COMPARATOR, ALLOCATOR >::DataWrapper |
Typedefs | |
typedef KEY | bsl::set::key_type |
typedef KEY | bsl::set::value_type |
typedef COMPARATOR | bsl::set::key_compare |
typedef COMPARATOR | bsl::set::value_compare |
typedef ALLOCATOR | bsl::set::allocator_type |
typedef value_type & | bsl::set::reference |
typedef const value_type & | bsl::set::const_reference |
typedef AllocatorTraits::size_type | bsl::set::size_type |
typedef AllocatorTraits::difference_type | bsl::set::difference_type |
typedef AllocatorTraits::pointer | bsl::set::pointer |
typedef AllocatorTraits::const_pointer | bsl::set::const_pointer |
typedef BloombergLP::bslstl::TreeIterator < const value_type, Node, difference_type > | bsl::set::iterator |
typedef BloombergLP::bslstl::TreeIterator < const value_type, Node, difference_type > | bsl::set::const_iterator |
typedef bsl::reverse_iterator < iterator > | bsl::set::reverse_iterator |
typedef bsl::reverse_iterator < const_iterator > | bsl::set::const_reverse_iterator |
Functions | |
bsl::set::DataWrapper::DataWrapper (const COMPARATOR &comparator, const ALLOCATOR &basicAllocator) | |
bsl::set::DataWrapper::DataWrapper (BloombergLP::bslmf::MovableRef< DataWrapper > original) | |
NodeFactory & | bsl::set::DataWrapper::nodeFactory () |
const NodeFactory & | bsl::set::DataWrapper::nodeFactory () const |
bsl::set::set () | |
bsl::set::set (const COMPARATOR &comparator, const ALLOCATOR &basicAllocator=ALLOCATOR()) | |
bsl::set::set (const ALLOCATOR &basicAllocator) | |
bsl::set::set (const set &original) | |
bsl::set::set (BloombergLP::bslmf::MovableRef< set > original) | |
bsl::set::set (const set &original, const typename type_identity< ALLOCATOR >::type &basicAllocator) | |
bsl::set::set (BloombergLP::bslmf::MovableRef< set > original, const typename type_identity< ALLOCATOR >::type &basicAllocator) | |
template<class INPUT_ITERATOR > | |
bsl::set::set (INPUT_ITERATOR first, INPUT_ITERATOR last, const COMPARATOR &comparator=COMPARATOR(), const ALLOCATOR &basicAllocator=ALLOCATOR()) | |
template<class INPUT_ITERATOR > | |
bsl::set::set (INPUT_ITERATOR first, INPUT_ITERATOR last, const ALLOCATOR &basicAllocator) | |
bsl::set::set (std::initializer_list< KEY > values, const COMPARATOR &comparator=COMPARATOR(), const ALLOCATOR &basicAllocator=ALLOCATOR()) | |
bsl::set::set (std::initializer_list< KEY > values, const ALLOCATOR &basicAllocator) | |
bsl::set::~set () | |
set & | bsl::set::operator= (const set &rhs) |
set &operator=(BloombergLP::bslmf::MovableRef < set > rhs) BSLS_KEYWORD_NOEXCEPT_SPECIFICATION(AllocatorTraits set & | bsl::set::operator= (std::initializer_list< KEY > values) |
iterator | bsl::set::begin () BSLS_KEYWORD_NOEXCEPT |
iterator | bsl::set::end () BSLS_KEYWORD_NOEXCEPT |
reverse_iterator | bsl::set::rbegin () BSLS_KEYWORD_NOEXCEPT |
reverse_iterator | bsl::set::rend () BSLS_KEYWORD_NOEXCEPT |
pair< iterator, bool > | bsl::set::insert (const value_type &value) |
pair< iterator, bool > | bsl::set::insert (BloombergLP::bslmf::MovableRef< value_type > value) |
iterator | bsl::set::insert (const_iterator hint, const value_type &value) |
iterator | bsl::set::insert (const_iterator hint, BloombergLP::bslmf::MovableRef< value_type > value) |
template<class INPUT_ITERATOR > | |
void | bsl::set::insert (INPUT_ITERATOR first, INPUT_ITERATOR last) |
void | bsl::set::insert (std::initializer_list< KEY > values) |
template<class... Args> | |
pair< iterator, bool > | bsl::set::emplace (Args &&...arguments) |
template<class... Args> | |
iterator | bsl::set::emplace_hint (const_iterator hint, Args &&...arguments) |
iterator | bsl::set::erase (const_iterator position) |
size_type | bsl::set::erase (const key_type &key) |
iterator | bsl::set::erase (const_iterator first, const_iterator last) |
iterator | bsl::set::find (const key_type &key) |
template<class LOOKUP_KEY > | |
bsl::enable_if < BloombergLP::bslmf::IsTransparentPredicate < COMPARATOR, LOOKUP_KEY > ::value, iterator >::type | bsl::set::find (const LOOKUP_KEY &key) |
iterator | bsl::set::lower_bound (const key_type &key) |
template<class LOOKUP_KEY > | |
bsl::enable_if < BloombergLP::bslmf::IsTransparentPredicate < COMPARATOR, LOOKUP_KEY > ::value, iterator >::type | bsl::set::lower_bound (const LOOKUP_KEY &key) |
iterator | bsl::set::upper_bound (const key_type &key) |
template<class LOOKUP_KEY > | |
bsl::enable_if < BloombergLP::bslmf::IsTransparentPredicate < COMPARATOR, LOOKUP_KEY > ::value, iterator >::type | bsl::set::upper_bound (const LOOKUP_KEY &key) |
pair< iterator, iterator > | bsl::set::equal_range (const key_type &key) |
template<class LOOKUP_KEY > | |
bsl::enable_if < BloombergLP::bslmf::IsTransparentPredicate < COMPARATOR, LOOKUP_KEY > ::value, pair< iterator, iterator > >::type | bsl::set::equal_range (const LOOKUP_KEY &key) |
allocator_type | bsl::set::get_allocator () const BSLS_KEYWORD_NOEXCEPT |
const_iterator | bsl::set::begin () const BSLS_KEYWORD_NOEXCEPT |
const_iterator | bsl::set::end () const BSLS_KEYWORD_NOEXCEPT |
const_reverse_iterator | bsl::set::rbegin () const BSLS_KEYWORD_NOEXCEPT |
const_reverse_iterator | bsl::set::rend () const BSLS_KEYWORD_NOEXCEPT |
const_iterator | bsl::set::cbegin () const BSLS_KEYWORD_NOEXCEPT |
const_iterator | bsl::set::cend () const BSLS_KEYWORD_NOEXCEPT |
const_reverse_iterator | bsl::set::crbegin () const BSLS_KEYWORD_NOEXCEPT |
const_reverse_iterator | bsl::set::crend () const BSLS_KEYWORD_NOEXCEPT |
bool | bsl::set::empty () const BSLS_KEYWORD_NOEXCEPT |
size_type | bsl::set::size () const BSLS_KEYWORD_NOEXCEPT |
size_type | bsl::set::max_size () const BSLS_KEYWORD_NOEXCEPT |
key_compare | bsl::set::key_comp () const |
value_compare | bsl::set::value_comp () const |
const_iterator | bsl::set::find (const key_type &key) const |
template<class LOOKUP_KEY > | |
bsl::enable_if < BloombergLP::bslmf::IsTransparentPredicate < COMPARATOR, LOOKUP_KEY > ::value, const_iterator > ::type | bsl::set::find (const LOOKUP_KEY &key) const |
size_type | bsl::set::count (const key_type &key) const |
template<class LOOKUP_KEY > | |
bsl::enable_if < BloombergLP::bslmf::IsTransparentPredicate < COMPARATOR, LOOKUP_KEY > ::value, size_type >::type | bsl::set::count (const LOOKUP_KEY &key) const |
const_iterator | bsl::set::lower_bound (const key_type &key) const |
template<class LOOKUP_KEY > | |
bsl::enable_if < BloombergLP::bslmf::IsTransparentPredicate < COMPARATOR, LOOKUP_KEY > ::value, const_iterator > ::type | bsl::set::lower_bound (const LOOKUP_KEY &key) const |
const_iterator | bsl::set::upper_bound (const key_type &key) const |
template<class LOOKUP_KEY > | |
bsl::enable_if < BloombergLP::bslmf::IsTransparentPredicate < COMPARATOR, LOOKUP_KEY > ::value, const_iterator > ::type | bsl::set::upper_bound (const LOOKUP_KEY &key) const |
pair< const_iterator, const_iterator > | bsl::set::equal_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 | bsl::set::equal_range (const LOOKUP_KEY &key) const |
template<class KEY , class COMPARATOR , class ALLOCATOR > | |
bool | bsl::operator== (const set< KEY, COMPARATOR, ALLOCATOR > &lhs, const set< KEY, COMPARATOR, ALLOCATOR > &rhs) |
template<class KEY , class COMPARATOR , class ALLOCATOR > | |
bool | bsl::operator!= (const set< KEY, COMPARATOR, ALLOCATOR > &lhs, const set< KEY, COMPARATOR, ALLOCATOR > &rhs) |
template<class KEY , class COMPARATOR , class ALLOCATOR > | |
bool | bsl::operator< (const set< KEY, COMPARATOR, ALLOCATOR > &lhs, const set< KEY, COMPARATOR, ALLOCATOR > &rhs) |
template<class KEY , class COMPARATOR , class ALLOCATOR > | |
bool | bsl::operator> (const set< KEY, COMPARATOR, ALLOCATOR > &lhs, const set< KEY, COMPARATOR, ALLOCATOR > &rhs) |
template<class KEY , class COMPARATOR , class ALLOCATOR > | |
bool | bsl::operator<= (const set< KEY, COMPARATOR, ALLOCATOR > &lhs, const set< KEY, COMPARATOR, ALLOCATOR > &rhs) |
template<class KEY , class COMPARATOR , class ALLOCATOR > | |
bool | bsl::operator>= (const set< KEY, COMPARATOR, ALLOCATOR > &lhs, const set< KEY, COMPARATOR, ALLOCATOR > &rhs) |
template<class KEY , class COMPARATOR , class ALLOCATOR , class PREDICATE > | |
set< KEY, COMPARATOR, ALLOCATOR >::size_type | bsl::erase_if (set< KEY, COMPARATOR, ALLOCATOR > &s, PREDICATE predicate) |
template<class KEY , class COMPARATOR , class ALLOCATOR > | |
void | bsl::swap (set< KEY, COMPARATOR, ALLOCATOR > &a, set< KEY, COMPARATOR, ALLOCATOR > &b) BSLS_KEYWORD_NOEXCEPT_SPECIFICATION(BSLS_KEYWORD_NOEXCEPT_OPERATOR(a.swap(b))) |
Variables | |
void swap(set &other) BSLS_KEYWORD_NOEXCEPT_SPECIFICATION(AllocatorTraits void | bsl::set::clear () BSLS_KEYWORD_NOEXCEPT |
bsl::set | STL-compatible set template |
bsl::set
, implementing the standard container holding an ordered sequence of unique keys. set
is an allocator-aware, value-semantic type whose salient attributes are its size (number of keys) and the ordered sequence of keys the set
contains. If set
is instantiated with a key type that is not itself value-semantic, then it will not retain all of its value-semantic qualities. In particular, if the key type cannot be tested for equality, then a set containing that type cannot be tested for equality. It is even possible to instantiate set
with a key type that does not have a copy-constructor, in which case the set
will not be copyable. set
implemented here adheres to the C++11 standard when compiled with a C++11 compiler, and makes the best approximation when compiled with a C++03 compiler. In particular, for C++03 we emulate move semantics, but limit forwarding (in emplace
) to const
lvalues, and make no effort to emulate noexcept
or initializer-lists. set
is a fully Value-Semantic Type (see bsldoc_glossary
) only if the supplied KEY
template parameters is fully value-semantic. It is possible to instantiate a set
with KEY
parameter arguments that do not provide a full set of value-semantic operations, but then some methods of the container may not be instantiable. The following terminology, adopted from the C++11 standard, is used in the function documentation of set
to describe a function's requirements for the KEY
template parameter. These terms are also defined in section [17.6.3.1] of the C++11 standard. Note that, in the context of a set
instantiation, the requirements apply specifically to the set's entry type, value_type
, which is an alias for KEY
. Legend ------ 'X' - denotes an allocator-aware container type (e.g., 'set') 'T' - 'value_type' associated with 'X' 'A' - type of the allocator used by 'X' 'm' - lvalue of type 'A' (allocator) 'p', - address ('T *') of uninitialized storage for a 'T' within an 'X' 'rv' - rvalue of type (non-'const') 'T' 'v' - rvalue or lvalue of type (possibly 'const') 'T' 'args' - 0 or more arguments
T
has a default constructor. More precisely, T
is default-insertable
into X
means that the following expression is well-formed: allocator_traits<A>construct(m, p)
T
provides a constructor that takes an rvalue of type (non-'const') T
. More precisely, T
is move-insertable
into X
means that the following expression is well-formed: allocator_traits<A>construct(m, p, rv)
T
provides a constructor that takes an lvalue or rvalue of type (possibly const
) T
. More precisely, T
is copy-insertable
into X
means that the following expression is well-formed: allocator_traits<A>construct(m, p, v)
T
provides an assignment operator that takes an rvalue of type (non-'const') T
.T
provides an assignment operator that takes an lvalue or rvalue of type (possibly const
) T
.T
is emplace-constructible
into X
from args
means that the following expression is well-formed: allocator_traits<A>construct(m, p, args)
T
provides a destructor. More precisely, T
is erasable
from X
means that the following expression is well-formed: allocator_traits<A>destroy(m, p)
ALLOCATOR
template parameter determines how that set will allocate memory. The set
template supports allocators meeting the requirements of the C++11 standard [17.6.3.5], in addition it supports scoped-allocators derived from the bslma::Allocator
memory allocation protocol. Clients intending to use bslma
style allocators should use the template's default ALLOCATOR
type: The default type for the ALLOCATOR
template parameter, bsl::allocator
, provides a C++11 standard-compatible adapter for a bslma::Allocator
object. ALLOCATOR
of a set
instantiation' is bsl::allocator
, then objects of that set type will conform to the standard behavior of a bslma
-allocator-enabled type. Such a set accepts an optional bslma::Allocator
argument at construction. If the address of a bslma::Allocator
object is explicitly supplied at construction, it is used to supply memory for the set throughout its lifetime; otherwise, the set will use the default allocator installed at the time of the set's construction (see bslma_default
). In addition to directly allocating memory from the indicated bslma::Allocator
, a set supplies that allocator's address to the constructors of contained objects of the (template parameter) type KEY
with the bslma::UsesBslmaAllocator
trait. set
: Legend ------ 'K' - (template parameter) type 'KEY' of the set 'a', 'b' - two distinct objects of type 'set<K>' 'rv' - modifiable rvalue of type 'set<K>' 'n', 'm' - number of elements in 'a' and 'b' respectively 'c' - comparator providing an ordering for objects of type 'K' 'al - an STL-style memory allocator 'i1', 'i2' - two iterators defining a sequence of 'value_type' objects 'k' - an object of type 'K' 'rk' - modifiable rvalue of type 'K' 'p1', 'p2' - two 'const' iterators belonging to 'a' distance(i1,i2) - the number of elements in the range [i1, i2) +----------------------------------------------------+--------------------+ | Operation | Complexity | +====================================================+====================+ | set<K> a; (default construction) | O[1] | | set<K> a(al); | | | set<K> a(c, al); | | +----------------------------------------------------+--------------------+ | set<K> a(rv); (move construction) | O[1] if 'a' and | | set<K> a(rv, al); | 'rv' use the same | | | allocator, | | | O[n] otherwise | +----------------------------------------------------+--------------------+ | set<K> a(b); (copy construction) | O[n] | | set<K> a(b, al); | | +----------------------------------------------------+--------------------+ | set<K> a(i1, i2); | O[N] if [i1, i2) | | set<K> a(i1, i2, al); | is sorted with | | set<K> a(i1, i2, c, al); | 'a.value_comp()', | | | O[N * log(N)] | | | otherwise, where N | | | is distance(i1,i2) | +----------------------------------------------------+--------------------+ | a.~set<K>(); (destruction) | O[n] | +----------------------------------------------------+--------------------+ | a = rv; (move assignment) | O[1] if 'a' and | | | 'rv' use the same | | | allocator, | | | O[n] otherwise | +----------------------------------------------------+--------------------+ | a = b; (copy assignment) | O[n] | +----------------------------------------------------+--------------------+ | a.begin(), a.end(), a.cbegin(), a.cend(), | O[1] | | a.rbegin(), a.rend(), a.crbegin(), a.crend() | | +----------------------------------------------------+--------------------+ | a == b, a != b | O[n] | +----------------------------------------------------+--------------------+ | a < b, a <= b, a > b, a >= b | O[n] | +----------------------------------------------------+--------------------+ | a.swap(b), swap(a, b) | O[1] if 'a' and | | | 'b' use the same | | | allocator, | | | O[n + m] otherwise | +----------------------------------------------------+--------------------+ | a.size() | O[1] | +----------------------------------------------------+--------------------+ | a.max_size() | O[1] | +----------------------------------------------------+--------------------+ | a.empty() | O[1] | +----------------------------------------------------+--------------------+ | get_allocator() | O[1] | +----------------------------------------------------+--------------------+ | a.insert(k) | O[log(n)] | | a.insert(rk) | | | a.emplace(Args&&...) | | +----------------------------------------------------+--------------------+ | a.insert(p1, k) | amortized constant | | a.insert(p1, rk) | if the value is | | a.emplace(p1, Args&&...) | inserted right | | | before p1, | | | O[log(n)] | | | otherwise | +----------------------------------------------------+--------------------+ | a.insert(i1, i2) | O[log(N) * | | | distance(i1,i2)] | | | | | | where N is | | | n + distance(i1,i2)| +----------------------------------------------------+--------------------+ | a.erase(p1) | amortized constant | +----------------------------------------------------+--------------------+ | a.erase(k) | O[log(n) + | | | a.count(k)] | +----------------------------------------------------+--------------------+ | a.erase(p1, p2) | O[log(n) + | | | distance(p1, p2)] | +----------------------------------------------------+--------------------+ | a.erase(p1, p2) | O[log(n) + | | | distance(p1, p2)] | +----------------------------------------------------+--------------------+ | a.clear() | O[n] | +----------------------------------------------------+--------------------+ | a.key_comp() | O[1] | +----------------------------------------------------+--------------------+ | a.value_comp() | O[1] | +----------------------------------------------------+--------------------+ | a.find(k) | O[log(n)] | +----------------------------------------------------+--------------------+ | a.count(k) | O[log(n) + | | | a.count(k)] | +----------------------------------------------------+--------------------+ | a.lower_bound(k) | O[log(n)] | +----------------------------------------------------+--------------------+ | a.upper_bound(k) | O[log(n)] | +----------------------------------------------------+--------------------+ | a.equal_range(k) | O[log(n)] | +----------------------------------------------------+--------------------+
bsl::set
to define and implement a class, HolidayCalendar
, that provides a calendar that allows client to add and remove holiday dates and determine whether a particular date is a holiday. MyDate
, that represents a date: (Note that for brevity, we do not explicitly document the invariants of a valid date.) class MyDate { // This class implements a value-semantic attribute class // characterizing a date according to the (Gregorian) Unix date // convention. // DATA int d_year; int d_month; int d_day; public: // CREATORS MyDate(int year, int month, int day) // Create a 'MyDate' object having the value represented by the // specified 'year', 'month', and 'day. The behavior is undefined // unless the value represented by 'year', 'month', and 'day is // valid. : d_year(year), d_month(month), d_day(day) { } MyDate(const MyDate& original) // Create a 'MyDate' object having the same value as the specified // 'original' object. : d_year(original.d_year) , d_month(original.d_month) , d_day(original.d_day) { } // Destroy this object // MANIPULATORS MyDate& operator=(const MyDate& rhs) // Assign to this object the value of the specified 'rhs' object, // and return a reference providing modifiable access to this // object. { d_year = rhs.d_year; d_month = rhs.d_month; d_day = rhs.d_day; return *this; } // ACCESSORS int year() const // Return the year of this date. { return d_year; } int month() const // Return the month of this date. { return d_month; } int day() const // Return the day of this date. { return d_day; } }; // FREE FUNCTIONS inline bool operator==(const MyDate& lhs, const MyDate& rhs) // Return 'true' if the specified 'lhs' and 'rhs' objects have the same // value, and 'false' otherwise. Two 'MyDate' objects have the same // value if each of their corresponding 'year', 'month', and 'day' // attributes respective have the same value. { return lhs.year() == rhs.year() && lhs.month() == rhs.month() && lhs.day() == rhs.day(); } inline bool operator!=(const MyDate& lhs, const MyDate& rhs) // Return 'true' if the specified 'lhs' and 'rhs' objects do not have // the same value, and 'false' otherwise. Two 'MyDate' objects do not // have the same value if each of their corresponding 'year', 'month', // and 'day' attributes respective do not have the same value. { return !(lhs == rhs); }
MyDate
objects in order for them to be stored in a bsl::set
object: struct MyDateLess { // This 'struct' defines an ordering on 'MyDate' objects, allowing them // to be included in associative containers such as 'bsl::set'. bool operator() (const MyDate& lhs, const MyDate& rhs) const // Return 'true' if the value of the specified 'lhs' is less than // (ordered before) the value of the specified 'rhs', and 'false' // otherwise. The 'lhs' value is considered less than the 'rhs' // value if the date represented by 'lhs' is earlier than the date // represented by 'rhs' in time. { if (lhs.year() < rhs.year()) return true; if (lhs.year() == rhs.year()) { if (lhs.month() < rhs.month()) return true; if (lhs.month() == rhs.month()) { if (lhs.day() < rhs.day()) return true; } } return false; } };
HolidayCalendar
: class HolidayCalendar { // This class provides a value-semantic type that allows clients to // modify and query a set of dates considered to be holidays.
DateSet
, for a bsl::set
that will serve as the data member for a HolidayCalendar
. A DateSet
has keys of type MyDate
, and a comparator of type MyDateLess
. We use the default ALLOCATOR
template parameter as we intend to use HolidayCalendar
with bslma
style allocators: // PRIVATE TYPES typedef bsl::set<MyDate, MyDateLess> DateSet; // This 'typedef' is an alias for a set of 'MyDate' objects. // DATA DateSet d_holidayDates; // set of dates considered to be holidays public: // PUBLIC TYPES typedef DateSet::const_iterator ConstIterator; // This 'typedef' provides an alias for the type of an iterator // providing non-modifiable access to holiday dates in a // 'HolidayCalendar'. // CREATORS HolidayCalendar(bslma::Allocator *basicAllocator = 0); // Create an empty 'HolidayCalendar' object. Optionally specify a // 'basicAllocator' used to supply memory. If 'basicAllocator' is // 0, the currently installed default allocator is used. HolidayCalendar(const HolidayCalendar& original, bslma::Allocator *basicAllocator = 0); // Create a 'HolidayCalendar' object having the same value as the // specified 'original' object. Optionally specify a // 'basicAllocator' used to supply memory. If 'basicAllocator' is // 0, the currently installed default allocator is used. // Destroy this object. // MANIPULATORS void addHolidayDate(const MyDate& date); // Add the specified 'date' as a holiday date maintained by this // calendar. If 'date' is already a holiday date, this method has // no effect. void removeHolidayDate(const MyDate& date); // Remove the specify 'date' from the set of holiday dates // maintained by this calendar. If 'date' is not a holiday date, // this method has no effect. // ACCESSORS bool isHolidayDate(const MyDate& date) const; // Return 'true' if the specified 'date' is in the set of holiday // dates maintained by this calendar, and return 'false' otherwise. ConstIterator beginHolidayDates() const; // Return an iterator providing non-modifiable access to the first // date in the ordered sequence of holiday dates maintained by this // calendar. ConstIterator endHolidayDates() const; // Return an iterator providing non-modifiable access to // past-the-end date in the ordered sequence of holiday dates // maintained by this calendar. };
HolidayCalendar
: inline bool operator==(const HolidayCalendar& lhs, const HolidayCalendar& rhs); // Return 'true' if the specified 'lhs' and 'rhs' objects have the same // value, and 'false' otherwise. Two 'HolidayCalendar' objects have // the same value if they have the same number of holiday dates, and // each corresponding holiday date, in their respective ordered // sequence of dates, is the same. inline bool operator!=(const HolidayCalendar& lhs, const HolidayCalendar& rhs); // Return 'true' if the specified 'lhs' and 'rhs' objects do not have // the same value, and 'false' otherwise. Two 'HolidayCalendar' // objects do not have the same value if they either differ in their // number of holiday dates, or if any of the corresponding holiday // dates, in their respective ordered sequences of dates, is not the // same.
HolidayCalendar
class: // CREATORS HolidayCalendar::HolidayCalendar(bslma::Allocator *basicAllocator) : d_holidayDates(basicAllocator) { }
bsl::set
object the specified bsl::Allocator
object. // MANIPULATORS void HolidayCalendar::addHolidayDate(const MyDate& date) { d_holidayDates.insert(date); } void HolidayCalendar::removeHolidayDate(const MyDate& date) { d_holidayDates.erase(date); } // ACCESSORS bool HolidayCalendar::isHolidayDate(const MyDate& date) const { return d_holidayDates.find(date) != d_holidayDates.end(); } HolidayCalendar::ConstIterator HolidayCalendar::beginHolidayDates() const { return d_holidayDates.begin(); } HolidayCalendar::ConstIterator HolidayCalendar::endHolidayDates() const { return d_holidayDates.end(); }
HolidayCalendar
: inline bool operator==(const HolidayCalendar& lhs, const HolidayCalendar& rhs) { return lhs.d_holidayDates == rhs.d_holidayDates; } inline bool operator!=(const HolidayCalendar& lhs, const HolidayCalendar& rhs) { return !(lhs == rhs); }
typedef KEY bsl::set< KEY, COMPARATOR, ALLOCATOR >::key_type [inherited] |
typedef KEY bsl::set< KEY, COMPARATOR, ALLOCATOR >::value_type [inherited] |
typedef COMPARATOR bsl::set< KEY, COMPARATOR, ALLOCATOR >::key_compare [inherited] |
typedef COMPARATOR bsl::set< KEY, COMPARATOR, ALLOCATOR >::value_compare [inherited] |
typedef ALLOCATOR bsl::set< KEY, COMPARATOR, ALLOCATOR >::allocator_type [inherited] |
typedef value_type& bsl::set< KEY, COMPARATOR, ALLOCATOR >::reference [inherited] |
typedef const value_type& bsl::set< KEY, COMPARATOR, ALLOCATOR >::const_reference [inherited] |
typedef AllocatorTraits::size_type bsl::set< KEY, COMPARATOR, ALLOCATOR >::size_type [inherited] |
typedef AllocatorTraits::difference_type bsl::set< KEY, COMPARATOR, ALLOCATOR >::difference_type [inherited] |
typedef AllocatorTraits::pointer bsl::set< KEY, COMPARATOR, ALLOCATOR >::pointer [inherited] |
typedef AllocatorTraits::const_pointer bsl::set< KEY, COMPARATOR, ALLOCATOR >::const_pointer [inherited] |
typedef BloombergLP::bslstl::TreeIterator<const value_type, Node, difference_type> bsl::set< KEY, COMPARATOR, ALLOCATOR >::iterator [inherited] |
typedef BloombergLP::bslstl::TreeIterator<const value_type, Node, difference_type> bsl::set< KEY, COMPARATOR, ALLOCATOR >::const_iterator [inherited] |
typedef bsl::reverse_iterator<iterator> bsl::set< KEY, COMPARATOR, ALLOCATOR >::reverse_iterator [inherited] |
typedef bsl::reverse_iterator<const_iterator> bsl::set< KEY, COMPARATOR, ALLOCATOR >::const_reverse_iterator [inherited] |
bsl::set< KEY, COMPARATOR, ALLOCATOR >::DataWrapper::DataWrapper | ( | const COMPARATOR & | comparator, | |
const ALLOCATOR & | basicAllocator | |||
) | [explicit, inherited] |
Create a data wrapper using a copy of the specified comparator
to order keys and a copy of the specified basicAllocator
to supply memory.
bsl::set< KEY, COMPARATOR, ALLOCATOR >::DataWrapper::DataWrapper | ( | BloombergLP::bslmf::MovableRef< DataWrapper > | original | ) | [inherited] |
IMPLICIT: Create a data wrapper initialized to the contents of the pool
associated with the specified original
data wrapper. The comparator and allocator associated with original
are propagated to the new data wrapper. original
is left in a valid but unspecified state.
NodeFactory& bsl::set< KEY, COMPARATOR, ALLOCATOR >::DataWrapper::nodeFactory | ( | ) | [inherited] |
Return a reference providing modifiable access to the node factory associated with this data wrapper.
const NodeFactory& bsl::set< KEY, COMPARATOR, ALLOCATOR >::DataWrapper::nodeFactory | ( | ) | const [inherited] |
Return a reference providing non-modifiable access to the node factory associated with this data wrapper.
bsl::set< KEY, COMPARATOR, ALLOCATOR >::set | ( | ) | [inherited] |
bsl::set< KEY, COMPARATOR, ALLOCATOR >::set | ( | const COMPARATOR & | comparator, | |
const ALLOCATOR & | basicAllocator = ALLOCATOR() | |||
) | [inline, explicit, inherited] |
basicAllocator | 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). |
bsl::set< KEY, COMPARATOR, ALLOCATOR >::set | ( | const ALLOCATOR & | basicAllocator | ) | [explicit, inherited] |
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).
bsl::set< KEY, COMPARATOR, ALLOCATOR >::set | ( | const set< KEY, COMPARATOR, ALLOCATOR > & | original | ) | [inherited] |
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 'bslallocator_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
).
bsl::set< KEY, COMPARATOR, ALLOCATOR >::set | ( | BloombergLP::bslmf::MovableRef< set< KEY, COMPARATOR, ALLOCATOR > > | original | ) | [inherited] |
IMPLICIT: 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.
bsl::set< KEY, COMPARATOR, ALLOCATOR >::set | ( | const set< KEY, COMPARATOR, ALLOCATOR > & | original, | |
const typename type_identity< ALLOCATOR >::type & | basicAllocator | |||
) | [inherited] |
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).
bsl::set< KEY, COMPARATOR, ALLOCATOR >::set | ( | BloombergLP::bslmf::MovableRef< set< KEY, COMPARATOR, ALLOCATOR > > | original, | |
const typename type_identity< ALLOCATOR >::type & | basicAllocator | |||
) | [inherited] |
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).
bsl::set< KEY, COMPARATOR, ALLOCATOR >::set | ( | INPUT_ITERATOR | first, | |
INPUT_ITERATOR | last, | |||
const COMPARATOR & | comparator = COMPARATOR() , |
|||
const ALLOCATOR & | basicAllocator = ALLOCATOR() | |||
) | [inherited] |
bsl::set< KEY, COMPARATOR, ALLOCATOR >::set | ( | INPUT_ITERATOR | first, | |
INPUT_ITERATOR | last, | |||
const ALLOCATOR & | basicAllocator | |||
) | [inherited] |
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).
bsl::set< KEY, COMPARATOR, ALLOCATOR >::set | ( | std::initializer_list< KEY > | values, | |
const COMPARATOR & | comparator = COMPARATOR() , |
|||
const ALLOCATOR & | basicAllocator = ALLOCATOR() | |||
) | [inherited] |
bsl::set< KEY, COMPARATOR, ALLOCATOR >::set | ( | std::initializer_list< KEY > | values, | |
const ALLOCATOR & | basicAllocator | |||
) | [inherited] |
Create a set and insert each value_type
object in the specified values
initializer list, ignoring those keys having a value equivalent to that which appears earlier in the list. 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 values
is ordered according to comparator
, then this operation has O[N]
complexity, where N
is the number of elements in list
; otherwise this operation has O[N * log(N)]
complexity. 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 type ALLOCATOR
is bsl::allocator
(the default).
bsl::set< KEY, COMPARATOR, ALLOCATOR >::~set | ( | ) | [inherited] |
Destroy this object.
set& bsl::set< KEY, COMPARATOR, ALLOCATOR >::operator= | ( | const set< KEY, COMPARATOR, ALLOCATOR > & | rhs | ) | [inherited] |
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
).
set& operator= (BloombergLP::bslmf::MovableRef<set> rhs) BSLS_KEYWORD_NOEXCEPT_SPECIFICATION( AllocatorTraits set& bsl::set< KEY, COMPARATOR, ALLOCATOR >::operator= | ( | std::initializer_list< KEY > | values | ) | [inherited] |
< 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
). Assign to this object the value resulting from first clearing this set and then inserting each value_type
object in the specified values
initializer list, ignoring those keys having a value equivalent to that which appears earlier in the list; return a reference providing modifiable access to this object. This method requires that the (template parameter) type KEY
be copy-insertable
into this set (see Requirements on KEY
).
iterator bsl::set< KEY, COMPARATOR, ALLOCATOR >::begin | ( | ) | [inherited] |
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.
iterator bsl::set< KEY, COMPARATOR, ALLOCATOR >::end | ( | ) | [inherited] |
Return an iterator providing modifiable access to the past-the-end element in the ordered sequence of value_type
objects maintained by this set.
Referenced by bsl::set< Observer * >::count(), and bsl::set< Observer * >::equal_range().
reverse_iterator bsl::set< KEY, COMPARATOR, ALLOCATOR >::rbegin | ( | ) | [inherited] |
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.
reverse_iterator bsl::set< KEY, COMPARATOR, ALLOCATOR >::rend | ( | ) | [inherited] |
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.
pair<iterator, bool> bsl::set< KEY, COMPARATOR, ALLOCATOR >::insert | ( | const value_type & | value | ) | [inherited] |
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
).
pair<iterator, bool> bsl::set< KEY, COMPARATOR, ALLOCATOR >::insert | ( | BloombergLP::bslmf::MovableRef< value_type > | value | ) | [inherited] |
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
).
iterator bsl::set< KEY, COMPARATOR, ALLOCATOR >::insert | ( | const_iterator | hint, | |
const value_type & | value | |||
) | [inherited] |
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).
iterator bsl::set< KEY, COMPARATOR, ALLOCATOR >::insert | ( | const_iterator | hint, | |
BloombergLP::bslmf::MovableRef< value_type > | value | |||
) | [inherited] |
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).
void bsl::set< KEY, COMPARATOR, ALLOCATOR >::insert | ( | INPUT_ITERATOR | first, | |
INPUT_ITERATOR | last | |||
) | [inherited] |
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
.
void bsl::set< KEY, COMPARATOR, ALLOCATOR >::insert | ( | std::initializer_list< KEY > | values | ) | [inherited] |
Insert into this set the value of each value_type
object in the specified values
initializer list if a key equivalent to the object is not already contained in this set. This method requires that the (template parameter) type KEY
be copy-insertable
(see Requirements on KEY
).
pair<iterator, bool> bsl::set< KEY, COMPARATOR, ALLOCATOR >::emplace | ( | Args &&... | arguments | ) | [inherited] |
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
).
iterator bsl::set< KEY, COMPARATOR, ALLOCATOR >::emplace_hint | ( | const_iterator | hint, | |
Args &&... | arguments | |||
) | [inherited] |
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).
iterator bsl::set< KEY, COMPARATOR, ALLOCATOR >::erase | ( | const_iterator | position | ) | [inherited] |
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.
size_type bsl::set< KEY, COMPARATOR, ALLOCATOR >::erase | ( | const key_type & | key | ) | [inherited] |
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.
iterator bsl::set< KEY, COMPARATOR, ALLOCATOR >::erase | ( | const_iterator | first, | |
const_iterator | last | |||
) | [inherited] |
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.
iterator bsl::set< KEY, COMPARATOR, ALLOCATOR >::find | ( | const key_type & | key | ) | [inline, inherited] |
key | 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.
Referenced by bsl::set< Observer * >::count().
bsl::enable_if< BloombergLP::bslmf::IsTransparentPredicate<COMPARATOR, LOOKUP_KEY>::value, iterator>::type bsl::set< KEY, COMPARATOR, ALLOCATOR >::find | ( | const LOOKUP_KEY & | key | ) | [inline, inherited] |
key | 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.
iterator bsl::set< KEY, COMPARATOR, ALLOCATOR >::lower_bound | ( | const key_type & | key | ) | [inline, inherited] |
key | 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.
Referenced by bsl::set< Observer * >::count(), and bsl::set< Observer * >::equal_range().
bsl::enable_if< BloombergLP::bslmf::IsTransparentPredicate<COMPARATOR, LOOKUP_KEY>::value, iterator>::type bsl::set< KEY, COMPARATOR, ALLOCATOR >::lower_bound | ( | const LOOKUP_KEY & | key | ) | [inline, inherited] |
key | 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.
iterator bsl::set< KEY, COMPARATOR, ALLOCATOR >::upper_bound | ( | const key_type & | key | ) | [inline, inherited] |
key | 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.
Referenced by bsl::set< Observer * >::equal_range().
bsl::enable_if< BloombergLP::bslmf::IsTransparentPredicate<COMPARATOR, LOOKUP_KEY>::value, iterator>::type bsl::set< KEY, COMPARATOR, ALLOCATOR >::upper_bound | ( | const LOOKUP_KEY & | key | ) | [inline, inherited] |
key | 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.
pair<iterator, iterator> bsl::set< KEY, COMPARATOR, ALLOCATOR >::equal_range | ( | const key_type & | key | ) | [inline, inherited] |
key | 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.
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, inherited] |
key | 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.
allocator_type bsl::set< KEY, COMPARATOR, ALLOCATOR >::get_allocator | ( | ) | const [inherited] |
Return (a copy of) the allocator used for memory allocation by this set.
const_iterator bsl::set< KEY, COMPARATOR, ALLOCATOR >::begin | ( | ) | const [inherited] |
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.
const_iterator bsl::set< KEY, COMPARATOR, ALLOCATOR >::end | ( | ) | const [inherited] |
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.
const_reverse_iterator bsl::set< KEY, COMPARATOR, ALLOCATOR >::rbegin | ( | ) | const [inherited] |
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.
const_reverse_iterator bsl::set< KEY, COMPARATOR, ALLOCATOR >::rend | ( | ) | const [inherited] |
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.
const_iterator bsl::set< KEY, COMPARATOR, ALLOCATOR >::cbegin | ( | ) | const [inherited] |
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.
const_iterator bsl::set< KEY, COMPARATOR, ALLOCATOR >::cend | ( | ) | const [inherited] |
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.
const_reverse_iterator bsl::set< KEY, COMPARATOR, ALLOCATOR >::crbegin | ( | ) | const [inherited] |
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.
const_reverse_iterator bsl::set< KEY, COMPARATOR, ALLOCATOR >::crend | ( | ) | const [inherited] |
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.
bool bsl::set< KEY, COMPARATOR, ALLOCATOR >::empty | ( | ) | const [inherited] |
Return true
if this set contains no elements, and false
otherwise.
size_type bsl::set< KEY, COMPARATOR, ALLOCATOR >::size | ( | ) | const [inherited] |
Return the number of elements in this set.
size_type bsl::set< KEY, COMPARATOR, ALLOCATOR >::max_size | ( | ) | const [inherited] |
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.
key_compare bsl::set< KEY, COMPARATOR, ALLOCATOR >::key_comp | ( | ) | const [inherited] |
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.
value_compare bsl::set< KEY, COMPARATOR, ALLOCATOR >::value_comp | ( | ) | const [inherited] |
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()
.
const_iterator bsl::set< KEY, COMPARATOR, ALLOCATOR >::find | ( | const key_type & | key | ) | const [inline, inherited] |
< 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.
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, inherited] |
< 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.
size_type bsl::set< KEY, COMPARATOR, ALLOCATOR >::count | ( | const key_type & | key | ) | const [inline, inherited] |
< 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.
Referenced by bsl::set< Observer * >::count().
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, inherited] |
< 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.
const_iterator bsl::set< KEY, COMPARATOR, ALLOCATOR >::lower_bound | ( | const key_type & | key | ) | const [inline, inherited] |
< 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.
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, inherited] |
< 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.
const_iterator bsl::set< KEY, COMPARATOR, ALLOCATOR >::upper_bound | ( | const key_type & | key | ) | const [inline, inherited] |
< 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.
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, inherited] |
< 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.
pair<const_iterator, const_iterator> bsl::set< KEY, COMPARATOR, ALLOCATOR >::equal_range | ( | const key_type & | key | ) | const [inline, inherited] |
< 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.
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, inherited] |
< 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.
bool bsl::operator== | ( | const set< KEY, COMPARATOR, ALLOCATOR > & | lhs, | |
const set< KEY, COMPARATOR, ALLOCATOR > & | rhs | |||
) |
Return true
if the specified lhs
and rhs
objects have the same value, and false
otherwise. Two set
objects lhs
and rhs
have the same value if they have the same number of keys, and each element in the ordered sequence of keys of lhs
has the same value as the corresponding element in the ordered sequence of keys of rhs
. This method requires that the (template parameter) type KEY
be equality-comparable
(see Requirements on KEY
).
bool bsl::operator!= | ( | const set< KEY, COMPARATOR, ALLOCATOR > & | lhs, | |
const set< KEY, COMPARATOR, ALLOCATOR > & | rhs | |||
) |
Return true
if the specified lhs
and rhs
objects do not have the same value, and false
otherwise. Two set
objects lhs
and rhs
do not have the same value if they do not have the same number of keys, or some element in the ordered sequence of keys of lhs
does not have the same value as the corresponding element in the ordered sequence of keys of rhs
. This method requires that the (template parameter) type KEY
be equality-comparable
(see Requirements on KEY
).
bool bsl::operator< | ( | const set< KEY, COMPARATOR, ALLOCATOR > & | lhs, | |
const set< KEY, COMPARATOR, ALLOCATOR > & | rhs | |||
) |
Return true
if the value of the specified lhs
set is lexicographically less than that of the specified rhs
set, and false
otherwise. Given iterators i
and j
over the respective sequences [lhs.begin() .. lhs.end())
and [rhs.begin() .. rhs.end())
, the value of set lhs
is lexicographically less than that of set rhs
if true == *i < *j
for the first pair of corresponding iterator positions where *i < *j
and *j < *i
are not both false
. If no such corresponding iterator position exists, the value of lhs
is lexicographically less than that of rhs
if lhs.size() < rhs.size()
. This method requires that operator<
, inducing a total order, be defined for value_type
.
bool bsl::operator> | ( | const set< KEY, COMPARATOR, ALLOCATOR > & | lhs, | |
const set< KEY, COMPARATOR, ALLOCATOR > & | rhs | |||
) |
Return true
if the value of the specified lhs
set is lexicographically greater than that of the specified rhs
set, and false
otherwise. The value of set lhs
is lexicographically greater than that of set rhs
if rhs
is lexicographically less than lhs
(see operator<
). This method requires that operator<
, inducing a total order, be defined for value_type
. Note that this operator returns rhs < lhs
.
bool bsl::operator<= | ( | const set< KEY, COMPARATOR, ALLOCATOR > & | lhs, | |
const set< KEY, COMPARATOR, ALLOCATOR > & | rhs | |||
) |
Return true
if the value of the specified lhs
set is lexicographically less than or equal to that of the specified rhs
set, and false
otherwise. The value of set lhs
is lexicographically less than or equal to that of set rhs
if rhs
is not lexicographically less than lhs
(see operator<
). This method requires that operator<
, inducing a total order, be defined for value_type
. Note that this operator returns !(rhs < lhs)
.
bool bsl::operator>= | ( | const set< KEY, COMPARATOR, ALLOCATOR > & | lhs, | |
const set< KEY, COMPARATOR, ALLOCATOR > & | rhs | |||
) |
Return true
if the value of the specified lhs
set is lexicographically greater than or equal to that of the specified rhs
set, and false
otherwise. The value of set lhs
is lexicographically greater than or equal to that of set rhs
if lhs
is not lexicographically less than rhs
(see operator<
). This method requires that operator<
, inducing a total order, be defined for value_type
. Note that this operator returns !(lhs < rhs)
.
set<KEY, COMPARATOR, ALLOCATOR>::size_type bsl::erase_if | ( | set< KEY, COMPARATOR, ALLOCATOR > & | s, | |
PREDICATE | predicate | |||
) |
Erase all the elements in the specified set s
that satisfy the specified predicate predicate
. Return the number of elements erased.
void bsl::swap | ( | set< KEY, COMPARATOR, ALLOCATOR > & | a, | |
set< KEY, COMPARATOR, ALLOCATOR > & | b | |||
) |
Exchange the value and comparator of the specified a
object with those of the specified b
object; also exchange the allocator of a
with that of b
if the (template parameter) type ALLOCATOR
has the propagate_on_container_swap
trait, and do not modify either allocator otherwise. This function 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 a
was created with the same allocator as b
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 a
and b
, respectively. Note that this function's support for swapping objects created with different allocators when ALLOCATOR
does not have the propagate_on_container_swap
trait is a departure from the C++ Standard.
void swap (set& other) BSLS_KEYWORD_NOEXCEPT_SPECIFICATION( AllocatorTraits void bsl::set< KEY, COMPARATOR, ALLOCATOR >::clear() BSLS_KEYWORD_NOEXCEPT [inherited] |
< 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 method's support for swapping objects created with different allocators when ALLOCATOR
does not have the propagate_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.