File: set.yo

package info (click to toggle)
c%2B%2B-annotations 8.2.0-1
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 11,804 kB
  • ctags: 2,845
  • sloc: cpp: 15,418; makefile: 2,473; ansic: 165; perl: 90; sh: 29
file content (138 lines) | stat: -rw-r--r-- 6,329 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
The ti(set) class implements a i(sorted collection of values). Before using
tt(set) containers the tthi(set) header file must have been 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() 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 will be entered, the
other values will be silently ignored.

    Like the link(map)(MAP), the tt(set) receives its own copy of the data it
contains.
        it() A set may be initialized using a copy constructor:
        verb(
    extern set<string> container;
    set<string> object(container);
        )
    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())(this member
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())
            (this member erases all elements from the set.)
        ithtq(count)(size_t count(key))(this member returns 1 if
the provided key is available in the tt(set), otherwise 0 is returned.)
        ithtq(empty)(bool empty())(this member returns tt(true) if
the set contains no elements.)
        ithtq(end)(set::iterator end())(this member
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())(this member can be
used to erase 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))(this member returns
an iterator to the element having the given value. If the element isn't
available, tt(end) is returned.)
        ithtq(insert)(... insert())(this member can be used to
insert 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(lower_bound)
            (set::iterator lower_bound(key))
            (this member 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(rbegin)(set::reverse_iterator rbegin())(
    hi(reverse_iterator) this member returns an iterator pointing to the last
element of the set.)
        ithtq(rend)(set::reverse_iterator rend)(this member
returns an iterator pointing before the first element of the set.)
        ithtq(size)(size_t size())(this member returns the
number of elements in the set.)
        ithtq(swap)(void swap(argument))(this member can be used
to swap two sets (tt(argument) being the second set) that use identical data
types.)
        ithtq(upper_bound)
            (set::iterator upper_bound(key))
            (this member 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).)
        )
    )