bsl::set::insert

Insert value near hint if an equivalent key is not present.

Synopsis

Declared in <bslstl_set.h>

set<KEY, COMPARATOR, ALLOCATOR>::iterator
insert(
    const_iterator hint,
    value_type const& value);

Description

Insert in amortized constant time if hint is a valid immediate successor to value; otherwise this method has no effect if a key equivalent to value already exists. 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).

Return Value

iterator to the existing or newly inserted element

Parameters

NameDescription
hintiterator hint for insertion position
valuekey to insert