File: set.yo

package info (click to toggle)
c%2B%2B-annotations 10.6.0-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 10,536 kB
  • ctags: 3,247
  • sloc: cpp: 19,157; makefile: 1,521; ansic: 165; sh: 128; perl: 90
file content (152 lines) | stat: -rw-r--r-- 7,189 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
The ti(set) class implements a i(sorted collection of values). Before using
tt(set) containers the tthi(set) header file must be included.

    A set contains unique values (of a container-acceptable type). Each value
is stored only once.

A specific value can be explicitly created: Every tt(set) defines a
ti(value_type) which may be used to create values that can be stored in the
tt(set). For example, a value for a tt(set<string>) can be constructed as
follows:
        verb(
    set<string>::value_type setValue("Hello");
        )
    The tt(value_type) is associated with the tt(set<string>). Anonymous
tt(value_type) objects are also often used. E.g.,
        verb(
    set<string>::value_type("Hello");
        )
    Instead of using the line tt(set<string>::value_type(...)) over
and over again, a tt(typedef) is often used to reduce typing and to improve
readability:
        verb(
    typedef set<string>::value_type StringSetValue
        )
    Using this typedef, values for the tt(set<string>) may be constructed
as follows:
        verb(
    StringSetValue("Hello");
        )
    Alternatively, values of the set's type may be used
immediately. In that case the value of type tt(Type) is implicitly
converted  to a tt(set<Type>::value_type).

    The following constructors, operators, and member functions are available
for the tt(set) container:
    itemization(
    it() Constructors:
        itemization(
        it() The copy and move constructors are available;
        it() A tt(set) may be constructed empty:
        verb(
    set<int> object;
        )
        it() A set may be initialized using two iterators. For example:
            verb(
    int intarr[] = {1, 2, 3, 4, 5};

    set<int> object(&intarr[0], &intarr[5]);
            )
        )

    Note that all values in the set must be different: it is not possible to
store the same value repeatedly when the set is constructed. If the same value
occurs repeatedly, only the first instance of the value is entered into the
set; the remaining values are silently ignored.

    Like the link(map)(MAP), the tt(set) receives its own copy of the data it
contains.
    it() The tt(set) container only supports the standard set of operators
that are available for containers.
    it() The tt(set) class has the following member functions:
        itemization(
        ithtq(begin)(set::iterator begin())(returns an i(iterator) pointing to
the first element of the set. If the set is empty tt(end) is returned.)
        ithtq(clear)(void clear())
            (erases all elements from the set.)
        ithtq(count)(size_t count(key))(returns 1 if
the provided key is available in the tt(set), otherwise 0 is returned.)
        ithtq(empty)(bool empty())(returns tt(true) if
the set contains no elements.)
        ithtq(end)(set::iterator end())(returns an iterator pointing beyond
the last element of the set.)
        ithtq(equal_range)
            (pair<set::iterator, set::iterator> equal_range(key))(this
member returns a pair of iterators, being respectively the return values of
the member functions tt(lower_bound) and tt(upper_bound), introduced
below.)
        ithtq(erase)(... erase())(erases a specific element or range of
elements from the set:)
            itemization(
            itt(bool erase(value)) erases the element having the given
tt(value) from the tt(set). tt(True) is returned if the value was removed,
tt(false) if the set did not contain an element `tt(value)'.
            itt(void erase(pos)) erases the element pointed to by the iterator
tt(pos).
            itt(void erase(first, beyond)) erases all elements
indicated by the iterator range rangett(first, beyond).
            )

        ithtq(find)(set::iterator find(value))(returns
an iterator to the element having the given value. If the element isn't
available, tt(end) is returned.)
        ithtq(get_allocator)(allocator_type get_allocator() const)(returns a
copy of the allocator object used by the tt(set) object.)
        ithtq(insert)(... insert())(inserts elements into the tt(set). If the
element already exists, the existing element is left untouched and the element
to be inserted is ignored.  The return value depends on the version of
tt(insert) that is called:)
            itemization(
            itt(pair<set::iterator, bool> insert(keyvalue)) inserts
a new tt(set::value_type) into the set. The return value is a
ti(pair<set::iterator, bool>).  If the returned ti(bool) field is tt(true),
tt(value) was inserted into the set. The value tt(false) indicates that the
value that was specified was already available in the set, and
so the provided tt(value) was not inserted into the set.  In both cases the
tt(set::iterator) field points to the data element in the tt(set) having the
specified tt(value).
            itt(set::iterator insert(pos, keyvalue)). This way a
tt(set::value_type) may also be inserted into the set. tt(pos) is ignored, and
an iterator to the inserted element is returned.
            itt(void insert(first, beyond)) inserts the (tt(set::value_type))
elements pointed to by the i(iterator range) rangeti(first, beyond) into the
set.
            )

    ithtq(key_comp)(key_compare key_comp())
       (returns a copy of the object used by the tt(set) to compare keys. The
        type nl()
        tt(set<ValueType>::key_compare) is defined by the set container
        and tt(key_compare)'s parameters have types tt(ValueType const &). The
        comparison function returns tt(true) if its first argument should
        be ordered before its second argument.)
    ithtq(lower_bound) (set::iterator lower_bound(key))
       (returns an iterator pointing to the first tt(keyvalue) element of
        which the tt(key) is at least equal to the specified tt(key).  If no
        such element exists, the function returns tt(end).)
    ithtq(max_size)(size_t max_size())(returns the maximum number of
        elements this tt(set) may contain.)
    ithtq(rbegin)(set::reverse_iterator rbegin())(
    hi(reverse_iterator) returns an iterator pointing to the last element of
the set.)
    ithtq(rend)(set::reverse_iterator rend)(returns an iterator pointing
        before the first element of the set.)
    ithtq(size)(size_t size())(returns the
number of elements in the set.)
    ithtq(swap)(void swap(argument))(swaps two sets (tt(argument) being
the second set) that use identical data types.)
    ithtq(upper_bound)
            (set::iterator upper_bound(key))
            (returns an iterator pointing to the first
tt(keyvalue) element having a tt(key) exceeding the specified tt(key).  If no
such element exists, the function returns tt(end).)
        )
    ithtq(value_comp)(value_compare value_comp())
       (returns a copy of the object used by the tt(set) to compare keys. The
        type nl()
       tt(set<ValueType>::value_compare) is defined by the set container and
        tt(value_compare)'s parameters have types tt(ValueType const &). The
        comparison function returns tt(true) if its first argument should be
        ordered before its second argument. Its operation is identical to that
        of a tt(key_compare) object, returned by tt(key_comp).)
    )