cplusplus.com Open in urlscan Pro
54.39.7.252  Public Scan

URL: https://cplusplus.com/reference/set/set/
Submission: On December 17 via api from US — Scanned from CA

Form analysis 2 forms found in the DOM

<form class="gsc-search-box gsc-search-box-tools" accept-charset="utf-8">
  <table cellspacing="0" cellpadding="0" role="presentation" class="gsc-search-box">
    <tbody>
      <tr>
        <td class="gsc-input">
          <div class="gsc-input-box" id="gsc-iw-id1">
            <table cellspacing="0" cellpadding="0" role="presentation" id="gs_id50" class="gstl_50 gsc-input" style="width: 100%; padding: 0px;">
              <tbody>
                <tr>
                  <td id="gs_tti50" class="gsib_a"><input autocomplete="off" type="text" size="10" class="gsc-input" name="search" title="search" aria-label="search" id="gsc-i-id1" dir="ltr" spellcheck="false"
                      style="width: 100%; padding: 0px; border: none; margin: 0px; height: auto; outline: none;"></td>
                  <td class="gsib_b">
                    <div class="gsst_b" id="gs_st50" dir="ltr"><a class="gsst_a" href="javascript:void(0)" title="Clear search box" role="button" style="display: none;"><span class="gscb_a" id="gs_cb50" aria-hidden="true">×</span></a></div>
                  </td>
                </tr>
              </tbody>
            </table>
          </div>
        </td>
        <td class="gsc-search-button"><button class="gsc-search-button gsc-search-button-v2"><svg width="13" height="13" viewBox="0 0 13 13">
              <title>search</title>
              <path
                d="m4.8495 7.8226c0.82666 0 1.5262-0.29146 2.0985-0.87438 0.57232-0.58292 0.86378-1.2877 0.87438-2.1144 0.010599-0.82666-0.28086-1.5262-0.87438-2.0985-0.59352-0.57232-1.293-0.86378-2.0985-0.87438-0.8055-0.010599-1.5103 0.28086-2.1144 0.87438-0.60414 0.59352-0.8956 1.293-0.87438 2.0985 0.021197 0.8055 0.31266 1.5103 0.87438 2.1144 0.56172 0.60414 1.2665 0.8956 2.1144 0.87438zm4.4695 0.2115 3.681 3.6819-1.259 1.284-3.6817-3.7 0.0019784-0.69479-0.090043-0.098846c-0.87973 0.76087-1.92 1.1413-3.1207 1.1413-1.3553 0-2.5025-0.46363-3.4417-1.3909s-1.4088-2.0686-1.4088-3.4239c0-1.3553 0.4696-2.4966 1.4088-3.4239 0.9392-0.92727 2.0864-1.3969 3.4417-1.4088 1.3553-0.011889 2.4906 0.45771 3.406 1.4088 0.9154 0.95107 1.379 2.0924 1.3909 3.4239 0 1.2126-0.38043 2.2588-1.1413 3.1385l0.098834 0.090049z">
              </path>
            </svg></button></td>
        <td class="gsc-clear-button">
          <div class="gsc-clear-button" title="clear results">&nbsp;</div>
        </td>
      </tr>
    </tbody>
  </table>
</form>

Name: I_loginformPOST /user/access.cgi

<form name="I_loginform" method="POST" action="/user/access.cgi" style="display: none;">
  <div class="fields"><input type="hidden" name="w" value="login"><input type="hidden" name="y" value="1"><input type="hidden" name="to" value="https://cplusplus.com/reference/set/set/">user name: <input type="text" name="l" id="l" class="txt"
      size="8" title="Type user name"><br>password: <input type="password" name="p" id="p" class="txt" size="8" title="Type password"><br><input type="checkbox" name="rememberme" value="1" class="chk" id="rememberme"><label
      for="rememberme"></label><input type="submit" class="rbtn" value="sign in">
    <div class="forgot"><a href="/user/access.cgi?w=lostpass">Forgot your password?</a></div>
  </div>
</form>

Text Content

cplusplus.com
 * TUTORIALS
 * REFERENCE
 * ARTICLES
 * FORUM

×

search
 

user name:
password:

Forgot your password?


please wait

try again cancel
forgot your password?

sign up log in
[Legacy version]


C++

 * Tutorials
 * Reference
 * Articles
 * Forum


REFERENCE

 * C LIBRARY:
   
    * 
      <cassert> (assert.h)
    * 
      <cctype> (ctype.h)
    * 
      <cerrno> (errno.h)
    * C++11
      <cfenv> (fenv.h)
    * 
      <cfloat> (float.h)
    * C++11
      <cinttypes> (inttypes.h)
    * 
      <ciso646> (iso646.h)
    * 
      <climits> (limits.h)
    * 
      <clocale> (locale.h)
    * 
      <cmath> (math.h)
    * 
      <csetjmp> (setjmp.h)
    * 
      <csignal> (signal.h)
    * 
      <cstdarg> (stdarg.h)
    * C++11
      <cstdbool> (stdbool.h)
    * 
      <cstddef> (stddef.h)
    * C++11
      <cstdint> (stdint.h)
    * 
      <cstdio> (stdio.h)
    * 
      <cstdlib> (stdlib.h)
    * 
      <cstring> (string.h)
    * C++11
      <ctgmath> (tgmath.h)
    * 
      <ctime> (time.h)
    * C++11
      <cuchar> (uchar.h)
    * 
      <cwchar> (wchar.h)
    * 
      <cwctype> (wctype.h)

 * CONTAINERS:
   
    * C++11
      <array>
    * 
      <deque>
    * C++11
      <forward_list>
    * 
      <list>
    * 
      <map>
    * 
      <queue>
    * 
      <set>
    * 
      <stack>
    * C++11
      <unordered_map>
    * C++11
      <unordered_set>
    * 
      <vector>

 * INPUT/OUTPUT:
   
    * 
      <fstream>
    * 
      <iomanip>
    * 
      <ios>
    * 
      <iosfwd>
    * 
      <iostream>
    * 
      <istream>
    * 
      <ostream>
    * 
      <sstream>
    * 
      <streambuf>

 * MULTI-THREADING:
   
    * C++11
      <atomic>
    * C++11
      <condition_variable>
    * C++11
      <future>
    * C++11
      <mutex>
    * C++11
      <thread>

 * OTHER:
   
    * 
      <algorithm>
    * 
      <bitset>
    * C++11
      <chrono>
    * C++11
      <codecvt>
    * 
      <complex>
    * 
      <exception>
    * 
      <functional>
    * C++11
      <initializer_list>
    * 
      <iterator>
    * 
      <limits>
    * 
      <locale>
    * 
      <memory>
    * 
      <new>
    * 
      <numeric>
    * C++11
      <random>
    * C++11
      <ratio>
    * C++11
      <regex>
    * 
      <stdexcept>
    * 
      <string>
    * C++11
      <system_error>
    * C++11
      <tuple>
    * C++11
      <type_traits>
    * C++11
      <typeindex>
    * 
      <typeinfo>
    * 
      <utility>
    * 
      <valarray>

 * 
   <algorithm>
 * 
   <bitset>
 * 
   <cassert> (assert.h)
 * 
   <cctype> (ctype.h)
 * 
   <cerrno> (errno.h)
 * 
   <cfloat> (float.h)
 * 
   <ciso646> (iso646.h)
 * 
   <climits> (limits.h)
 * 
   <clocale> (locale.h)
 * 
   <cmath> (math.h)
 * 
   <complex>
 * 
   <csetjmp> (setjmp.h)
 * 
   <csignal> (signal.h)
 * 
   <cstdarg> (stdarg.h)
 * 
   <cstddef> (stddef.h)
 * 
   <cstdio> (stdio.h)
 * 
   <cstdlib> (stdlib.h)
 * 
   <cstring> (string.h)
 * 
   <ctime> (time.h)
 * 
   <cwchar> (wchar.h)
 * 
   <cwctype> (wctype.h)
 * 
   <deque>
 * 
   <exception>
 * 
   <fstream>
 * 
   <functional>
 * 
   <iomanip>
 * 
   <ios>
 * 
   <iosfwd>
 * 
   <iostream>
 * 
   <istream>
 * 
   <iterator>
 * 
   <limits>
 * 
   <list>
 * 
   <locale>
 * 
   <map>
 * 
   <memory>
 * 
   <new>
 * 
   <numeric>
 * 
   <ostream>
 * 
   <queue>
 * 
   <set>
 * 
   <sstream>
 * 
   <stack>
 * 
   <stdexcept>
 * 
   <streambuf>
 * 
   <string>
 * 
   <typeinfo>
 * 
   <utility>
 * 
   <valarray>
 * 
   <vector>
 * C++11
   <array>
 * C++11
   <atomic>
 * C++11
   <cfenv> (fenv.h)
 * C++11
   <chrono>
 * C++11
   <cinttypes> (inttypes.h)
 * C++11
   <codecvt>
 * C++11
   <condition_variable>
 * C++11
   <cstdbool> (stdbool.h)
 * C++11
   <cstdint> (stdint.h)
 * C++11
   <ctgmath> (tgmath.h)
 * C++11
   <cuchar> (uchar.h)
 * C++11
   <forward_list>
 * C++11
   <future>
 * C++11
   <initializer_list>
 * C++11
   <mutex>
 * C++11
   <random>
 * C++11
   <ratio>
 * C++11
   <regex>
 * C++11
   <system_error>
 * C++11
   <thread>
 * C++11
   <tuple>
 * C++11
   <type_traits>
 * C++11
   <typeindex>
 * C++11
   <unordered_map>
 * C++11
   <unordered_set>


<SET>

 * multiset
 * set


SET

 * set::~set
 * set::set

 * MEMBER FUNCTIONS
   
    * 
      set::begin
    * C++11
      set::cbegin
    * C++11
      set::cend
    * 
      set::clear
    * 
      set::count
    * C++11
      set::crbegin
    * C++11
      set::crend
    * C++11
      set::emplace
    * C++11
      set::emplace_hint
    * 
      set::empty
    * 
      set::end
    * 
      set::equal_range
    * 
      set::erase
    * 
      set::find
    * 
      set::get_allocator
    * 
      set::insert
    * 
      set::key_comp
    * 
      set::lower_bound
    * 
      set::max_size
    * 
      set::operator=
    * 
      set::rbegin
    * 
      set::rend
    * 
      set::size
    * 
      set::swap
    * 
      set::upper_bound
    * 
      set::value_comp

 * NON-MEMBER OVERLOADS
   
    * 
      relational operators (set)
    * 
      swap (set)

 * C++11
   set::cbegin
 * C++11
   set::cend
 * C++11
   set::crbegin
 * C++11
   set::crend
 * C++11
   set::emplace
 * C++11
   set::emplace_hint
 * 
   relational operators (set)
 * 
   set::begin
 * 
   set::clear
 * 
   set::count
 * 
   set::empty
 * 
   set::end
 * 
   set::equal_range
 * 
   set::erase
 * 
   set::find
 * 
   set::get_allocator
 * 
   set::insert
 * 
   set::key_comp
 * 
   set::lower_bound
 * 
   set::max_size
 * 
   set::operator=
 * 
   set::rbegin
 * 
   set::rend
 * set::set
 * 
   set::size
 * 
   set::swap
 * 
   set::upper_bound
 * 
   set::value_comp
 * set::~set
 * 
   swap (set)


 * Reference
 * <set>
 * set


class template
<set>


STD::SET

template < class T,                        // set::key_type/value_type           class Compare = less<T>,        // set::key_compare/value_compare           class Alloc = allocator<T>      // set::allocator_type           > class set;

Set
Sets are containers that store unique elements following a specific order.

In a set, the value of an element also identifies it (the value is itself the
key, of type T), and each value must be unique. The value of the elements in a
set cannot be modified once in the container (the elements are always const),
but they can be inserted or removed from the container.

Internally, the elements in a set are always sorted following a specific strict
weak ordering criterion indicated by its internal comparison object (of type
Compare).

set containers are generally slower than unordered_set containers to access
individual elements by their key, but they allow the direct iteration on subsets
based on their order.

Sets are typically implemented as binary search trees.




CONTAINER PROPERTIES

Associative Elements in associative containers are referenced by their key and
not by their absolute position in the container. Ordered The elements in the
container follow a strict order at all times. All inserted elements are given a
position in this order. Set The value of an element is also the key used to
identify it. Unique keys No two elements in the container can have equivalent
keys. Allocator-aware The container uses an allocator object to dynamically
handle its storage needs.



TEMPLATE PARAMETERS

T Type of the elements. Each element in a set container is also uniquely
identified by this value (each value is itself also the element's key).
Aliased as member types set::key_type and set::value_type. Compare A binary
predicate that takes two arguments of the same type as the elements and returns
a bool. The expression comp(a,b), where comp is an object of this type and a and
b are key values, shall return true if a is considered to go before b in the
strict weak ordering the function defines.
The set object uses this expression to determine both the order the elements
follow in the container and whether two element keys are equivalent (by
comparing them reflexively: they are equivalent if !comp(a,b) && !comp(b,a)). No
two elements in a set container can be equivalent.
This can be a function pointer or a function object (see constructor for an
example). This defaults to less<T>, which returns the same as applying the
less-than operator (a<b).
Aliased as member types set::key_compare and set::value_compare. Alloc Type of
the allocator object used to define the storage allocation model. By default,
the allocator class template is used, which defines the simplest memory
allocation model and is value-independent.
Aliased as member type set::allocator_type.



MEMBER TYPES

 * C++98
 * C++11
 * 

member typedefinitionnotes key_typeThe first template parameter (T)
value_typeThe first template parameter (T) key_compareThe second template
parameter (Compare)defaults to: less<key_type> value_compareThe second template
parameter (Compare)defaults to: less<value_type> allocator_typeThe third
template parameter (Alloc)defaults to: allocator<value_type>
referenceallocator_type::referencefor the default allocator: value_type&
const_referenceallocator_type::const_referencefor the default allocator: const
value_type& pointerallocator_type::pointerfor the default allocator: value_type*
const_pointerallocator_type::const_pointerfor the default allocator: const
value_type* iteratora bidirectional iterator to value_typeconvertible to
const_iterator const_iteratora bidirectional iterator to const value_type
reverse_iteratorreverse_iterator<iterator>
const_reverse_iteratorreverse_iterator<const_iterator> difference_typea signed
integral type, identical to: iterator_traits<iterator>::difference_typeusually
the same as ptrdiff_t size_typean unsigned integral type that can represent any
non-negative value of difference_typeusually the same as size_t

member typedefinitionnotes key_typeThe first template parameter (T)
value_typeThe first template parameter (T) key_compareThe second template
parameter (Compare)defaults to: less<key_type> value_compareThe second template
parameter (Compare)defaults to: less<value_type> allocator_typeThe third
template parameter (Alloc)defaults to: allocator<value_type>
referencevalue_type& const_referenceconst value_type&
pointerallocator_traits<allocator_type>::pointerfor the default allocator:
value_type* const_pointerallocator_traits<allocator_type>::const_pointerfor the
default allocator: const value_type* iteratora bidirectional iterator to const
value_type* convertible to const_iterator const_iteratora bidirectional iterator
to const value_type* reverse_iteratorreverse_iterator<iterator>*
const_reverse_iteratorreverse_iterator<const_iterator>* difference_typea signed
integral type, identical to:
iterator_traits<iterator>::difference_typeusually the same as ptrdiff_t
size_typean unsigned integral type that can represent any non-negative value of
difference_typeusually the same as size_t

*Note: All iterators in a set point to const elements. Whether the const_ member
type is the same type as its non-const_ counterpart depends on the particular
library implementation, but programs should not rely on them being different to
overload functions: const_iterator is more generic, since iterator is always
convertible to it.




MEMBER FUNCTIONS

(constructor)Construct set (public member function)(destructor)Set destructor
(public member function)operator=Copy container content (public member function)
Iterators:
beginReturn iterator to beginning (public member function)endReturn iterator to
end (public member function)rbeginReturn reverse iterator to reverse beginning
(public member function)rendReturn reverse iterator to reverse end (public
member function)cbegin Return const_iterator to beginning (public member
function)cend Return const_iterator to end (public member function)crbegin
Return const_reverse_iterator to reverse beginning (public member function)crend
Return const_reverse_iterator to reverse end (public member function)
Capacity:
emptyTest whether container is empty (public member function)sizeReturn
container size (public member function)max_sizeReturn maximum size (public
member function)
Modifiers:
insertInsert element (public member function)eraseErase elements (public member
function)swapSwap content (public member function)clearClear content (public
member function)emplace Construct and insert element (public member
function)emplace_hint Construct and insert element with hint (public member
function)
Observers:
key_compReturn comparison object (public member function)value_compReturn
comparison object (public member function)
Operations:
findGet iterator to element (public member function)countCount elements with a
specific value (public member function)lower_boundReturn iterator to lower bound
(public member function)upper_boundReturn iterator to upper bound (public member
function)equal_rangeGet range of equal elements (public member function)
Allocator:
get_allocatorGet allocator (public member function)



Home page | Privacy policy
© cplusplus.com, 2000-2023 - All rights reserved - v3.3.4s
Spotted an error? contact us

x