Set and multiset operations, Declaration and initialization of set – HP Integrity NonStop H-Series User Manual
Page 85
Click on the banner to return to the user guide home page.
©Copyright 1996 Rogue Wave Software
set and multiset Operations
Sets and Bags
The member functions provided by the set and multiset data types will shortly be described in more
detail. Note that while member functions provide basic operations, the utility of these data
structures is greatly extended through the use of the generic algorithms described in Chapters
and
Declaration and Initialization of Set
A
set
is a template data structure, specialized by the type of the elements it contains, and the
operator used to compare keys. The latter argument is optional, and, if it is not provided, the less
than operator for the key type will be assumed. The element type can be a primitive language type
(such as integer or double), a pointer type, or a user-defined type. The element type must recognize
both the equality testing operator (operator ==) and the less than comparison operator (operator <).
Initializing Sets with Iterators
Sets can be declared with no initial elements, or they can be initialized from another container by
providing a pair of iterators. An optional argument in both cases is an alternative comparison
function; this value overrides the value provided by the template parameter. This mechanism is
useful if a program contains two or more sets with the same values but different orderings, as it
prevents more than one copy of the set member function from being instantiated. The copy
constructor can be used to form a new set that is a clone, or copy, of an existing set.
set
set
set
set
set
set
set
(aList.begin(), aList.end(), greater