Concurrently safe modifiers
Contents
Concurrently safe modifiers#
All member functions in this section can be performed concurrently with each other, lookup methods and while traversing the container.
Inserting values#
std::pair<iterator, bool> insert( const value_type& value );Attempts to insert the value
value
into the container.Returns:
std::pair<iterator, bool>
whereiterator
points to the inserted element or to an existing equal element. Boolean value istrue
if insertion took place;false
, otherwise.Requirements: the type
value_type
must meet theCopyInsertable
requirements from the [container.requirements] ISO C++ Standard section.
iterator insert( const_iterator hint, const value_type& other );Attempts to insert the value
value
into the container.Optionally uses the parameter
hint
as a suggestion to where the element should be placed.Returns: an
iterator
to the inserted element or to an existing equal element.Requirements: the type
value_type
must meet theCopyInsertable
requirements from the [container.requirements] ISO C++ Standard section.
std::pair<iterator, bool> insert( value_type&& value );Attempts to insert the value
value
into the container using move semantics.
value
is left in a valid, but unspecified state.Returns:
std::pair<iterator, bool>
, whereiterator
points to the inserted element or to an existing equal element. Boolean value istrue
if insertion took place;false
, otherwise.Requirements: the type
value_type
must meet theMoveInsertable
requirements from the [container.requirements] ISO C++ Standard section.
iterator insert( const_iterator hint, value_type&& other );Attempts to insert the value
value
into the container using move semantics.Optionally uses the parameter
hint
as a suggestion to where the element should be placed.
value
is left in a valid, but unspecified state.Returns: an
iterator
to the inserted element or to an existing equal element.Requirements: the type
value_type
must meet theMoveInsertable
requirements from the [container.requirements] ISO C++ Standard section.
Inserting sequences of elements#
template <typename InputIterator> void insert( InputIterator first, InputIterator last );Attempts to insert all items from the half-open interval
[first, last)
into the container.If the interval
[first, last)
contains multiple equal elements, it is unspecified which element should be inserted.Requirements: the type
InputIterator
must meet the requirements of InputIterator from[input.iterators]
ISO C++ Standard section.
void insert( std::initializer_list<value_type> init );Equivalent to
insert(init.begin(), init.end())
.
Inserting nodes#
std::pair<iterator, bool> insert( node_type&& nh );If the node handle
nh
is empty, does nothing.Otherwise, attempts to insert the node owned by
nh
into the container.If the insertion fails, node handle
nh
keeps ownership of the node.Otherwise,
nh
is left in an empty state.No copy or move constructors of
value_type
are performed.The behavior is undefined if
nh
is not empty andget_allocator() != nh.get_allocator()
.Returns:
std::pair<iterator, bool>
, whereiterator
points to the inserted element or to an existing element equal tonh.value()
. Boolean value istrue
if insertion took place;false
, otherwise.
iterator insert( const_iterator hint, node_type&& nh );If the node handle
nh
is empty, does nothing.Otherwise, attempts to insert the node owned by
nh
into the container.Optionally uses the parameter
hint
as a suggestion to where the node should be placed.If the insertion fails, node handle
nh
keeps ownership of the node.Otherwise,
nh
is left in an empty state.No copy or move constructors of
value_type
are performed.The behavior is undefined if
nh
is not empty andget_allocator() != nh.get_allocator()
.Returns: an iterator pointing to the inserted element or to an existing element equal to
nh.value()
.
Emplacing elements#
template <typename... Args> std::pair<iterator, bool> emplace( Args&&... args );Attempts to insert an element constructed in-place from
args
into the container.Returns:
std::pair<iterator, bool>
, whereiterator
points to the inserted element or to an existing equal element. Boolean value istrue
if insertion took place,false
otherwise.Requirements: the type
value_type
must meet theEmplaceConstructible
requirements from the [container.requirements] ISO C++ Standard section.
template <typename... Args> iterator emplace_hint( const_iterator hint, Args&&... args );Attempts to insert an element constructed in-place from
args
into the container.Optionally uses the parameter
hint
as a suggestion to where the node should be placed.Returns: an
iterator
to the inserted element or to an existing equal element.Requirements: the type
value_type
must meet theEmplaceConstructible
requirements from the [container.requirements] ISO C++ Standard section.
Merging containers#
template <typename SrcHash, typename SrcKeyEqual> void merge( concurrent_unordered_set<T, SrcHash, SrcKeyEqual, Allocator>& source ); template <typename SrcHash, typename SrcKeyEqual> void merge( concurrent_unordered_set<T, SrcHash, SrcKeyEqual, Allocator>&& source ); template <typename SrcHash, typename SrcKeyEqual> void merge( concurrent_unordered_multiset<T, SrcHash, SrcKeyEqual, Allocator>& source ); template <typename SrcHash, typename SrcKeyEqual> void merge( concurrent_unordered_multiset<T, SrcHash, SrcKeyEqual, Allocator>&& source );Transfers those elements from
source
that do not exist in the container.In case of merging with the container with multiple equal elements, it is unspecified which element would be transferred.
No copy or move constructors of
value_type
are performed.The behavior is undefined if
get_allocator() != source.get_allocator()
.