C++-Referenz/ Standardbibliothek/ Container-Klassen/ set
Erscheinungsbild
Alte Seite
Die Arbeit am Buch »C++-Referenz« wurde vom Hauptautor eingestellt. Ein Lehrbuch zum Thema C++ ist unter »C++-Programmierung« zu finden. Eine sehr umfangreiche und gute Referenz gibt es unter cppreference.com.
Diese Seite beschreibt C++98, einen stark veralteten Standard. Aktuelle Referenz.
// Header: set
template <typename Key, typename Compare = less<Key>, typename Allocator = allocator<Key> >
class set{
public:
typedef Key key_type;
typedef Key value_type;
typedef Compare key_compare;
typedef Compare value_compare;
typedef Allocator allocator_type;
typedef typename Allocator::reference reference;
typedef typename Allocator::const_reference const_reference;
typedef implementation defined iterator;
typedef implementation defined const_iterator;
typedef typename Allocator::size_type size_type;
typedef typename Allocator::difference_type difference_type;
typedef typename Allocator::pointer pointer;
typedef typename Allocator::const_pointer const_pointer;
typedef std::reverse_iterator<iterator> reverse_iterator;
typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
// Konstruktoren, Destruktor, Kopieren
explicit set(Compare const& comp = Compare(), Allocator const& = Allocator());
template <typename InputIterator> set(
InputIterator first,
InputIterator last,
Compare const& comp = Compare(),
Allocator const& = Allocator()
);
set(set<Key,Compare,Allocator> const& x);
~set();
set<Key,Compare,Allocator>& operator=(set<Key,Compare,Allocator> const& x);
allocator_type get_allocator()const;
// Iteratoren
iterator begin();
const_iterator begin()const;
iterator end();
const_iterator end()const;
reverse_iterator rbegin();
const_reverse_iterator rbegin()const;
reverse_iterator rend();
const_reverse_iterator rend()const;
// Kapazität
bool empty()const;
size_type size()const;
size_type max_size()const;
// Modifizierer
pair<iterator,bool> insert(value_type const& x);
iterator insert(iterator position, value_type const& x);
template <typename InputIterator>
void insert(InputIterator first, InputIterator last);
void erase(iterator position);
size_type erase(key_type const& x);
void erase(iterator first, iterator last);
void swap(set<Key,Compare,Allocator>&);
void clear();
// Betrachter
key_compare key_comp()const;
value_compare value_comp()const;
// set-Operationen
iterator find(key_type const& x)const;
size_type count(key_type const& x)const;
iterator lower_bound(key_type const& x)const;
iterator upper_bound(key_type const& x)const;
pair<iterator,iterator> equal_range(key_type const& x)const;
};
// Vergleiche
template <typename Key, typename Compare, typename Allocator>
bool operator==(set<Key,Compare,Allocator> const& x, set<Key,Compare,Allocator> const& y);
template <typename Key, typename Compare, typename Allocator>
bool operator< (set<Key,Compare,Allocator> const& x, set<Key,Compare,Allocator> const& y);
template <typename Key, typename Compare, typename Allocator>
bool operator!=(set<Key,Compare,Allocator> const& x, set<Key,Compare,Allocator> const& y);
template <typename Key, typename Compare, typename Allocator>
bool operator> (set<Key,Compare,Allocator> const& x, set<Key,Compare,Allocator> const& y);
template <typename Key, typename Compare, typename Allocator>
bool operator>=(set<Key,Compare,Allocator> const& x, set<Key,Compare,Allocator> const& y);
template <typename Key, typename Compare, typename Allocator>
bool operator<=(set<Key,Compare,Allocator> const& x, set<Key,Compare,Allocator> const& y);
// Spezialisierte Algorithmen
template <typename Key, typename Compare, typename Allocator>
void swap(set<Key,Compare,Allocator>& x, set<Key,Compare,Allocator>& y);