Standard Template Library Programmer's Guide

Здесь есть возможность читать онлайн «Standard Template Library Programmer's Guide» весь текст электронной книги совершенно бесплатно (целиком полную версию без сокращений). В некоторых случаях можно слушать аудио, скачать через торрент в формате fb2 и присутствует краткое содержание. Жанр: Программирование, Справочники, на английском языке. Описание произведения, (предисловие) а так же отзывы посетителей доступны на портале библиотеки ЛибКат.

Standard Template Library Programmer's Guide: краткое содержание, описание и аннотация

Предлагаем к чтению аннотацию, описание, краткое содержание или предисловие (зависит от того, что написал сам автор книги «Standard Template Library Programmer's Guide»). Если вы не нашли необходимую информацию о книге — напишите в комментариях, мы постараемся отыскать её.

This document contains reference on SGI STL implementation

Standard Template Library Programmer's Guide — читать онлайн бесплатно полную книгу (весь текст) целиком

Ниже представлен текст книги, разбитый по страницам. Система сохранения места последней прочитанной страницы, позволяет с удобством читать онлайн бесплатно книгу «Standard Template Library Programmer's Guide», без необходимости каждый раз заново искать на чём Вы остановились. Поставьте закладку, и сможете в любой момент перейти на страницу, на которой закончили чтение.

Тёмная тема
Сбросить

Интервал:

Закладка:

Сделать
Definition

Defined in the standard header algorithm, and in the nonstandard backward-compatibility header algo.h.

Requirements on types

For the first version:

• T is a model of LessThan Comparable.

For the second version:

• BinaryPredicate is a model of Binary Predicate.

• T is convertible to BinaryPredicate 's first argument type and to its second argument type.

Example

const int x = max(3, 9);

assert(x == 9);

See also

min , min_element , max_element , LessThan Comparable

min_element

Category: algorithms

Component type: function

Prototype

Min_element is an overloaded name; there are actually two min_element functions.

template

ForwardIterator min_element(ForwardIterator first, ForwardIterator last);

template

ForwardIterator min_element(ForwardIterator first, ForwardIterator last, BinaryPredicate comp);

Description

Min_element finds the smallest element in the range [first, last) . It returns the first iterator i in [first, last) such that no other iterator in [first, last) points to a value smaller than *i . The return value is last if and only if [first, last) is an empty range.

The two versions of min_element differ in how they define whether one element is less than another. The first version compares objects using operator< , and the second compares objects using a function object comp .

The first version of min_element returns the first iterator i in [first, last) such that, for every iterator j in [first, last) , *j < *i is false . The second version returns the first iterator i in [first, last) such that, for every iterator j in [first, last) , comp(*j, *i) is false .

Definition

Defined in the standard header algorithm, and in the nonstandard backward-compatibility header algo.h.

Requirements on types

For the first version:

• ForwardIterator is a model of Forward Iterator.

• ForwardIterator 's value type is LessThan Comparable.

For the second version:

• ForwardIterator is a model of Forward Iterator.

• BinaryPredicate is a model of Binary Predicate.

• ForwardIterator 's value type is convertible to BinaryPredicate 's first argument type and second argument type.

Preconditions

• [first, last) is a valid range.

Complexity

Linear. Zero comparisons if [first, last) is an empty range, otherwise exactly (last – first) – 1 comparisons.

Example

int main() {

list L;

generate_n(front_inserter(L), 1000, rand);

list::const_iterator it = min_element(L.begin(), L.end());

cout << "The smallest element is " << *it << endl;

}

See also

min , max max_element , LessThan Comparable, sort , nth_element

max_element

Category: algorithms

Component type: function

Prototype

Max_element is an overloaded name; there are actually two max_element functions.

template

ForwardIterator max_element(ForwardIterator first, ForwardIterator last);

template

ForwardIterator max_element(ForwardIterator first, ForwardIterator last, BinaryPredicate comp);

Description

Max_element finds the largest element in the range [first, last) . It returns the first iterator i in [first, last) such that no other iterator in [first, last) points to a value greater than *i . The return value is last if and only if [first, last) is an empty range.

The two versions of max_element differ in how they define whether one element is less than another. The first version compares objects using operator< , and the second compares objects using a function object comp .

The first version of max_element returns the first iterator i in [first, last) such that, for every iterator j in [first, last) , *i < *j is false . The second version returns the first iterator i in [first, last) such that, for every iterator j in [first, last) , comp(*i, *j) is false .

Definition

Defined in the standard header algorithm, and in the nonstandard backward-compatibility header algo.h.

Requirements on types

For the first version:

• ForwardIterator is a model of Forward Iterator.

• ForwardIterator 's value type is LessThan Comparable.

For the second version:

• ForwardIterator is a model of Forward Iterator.

• BinaryPredicate is a model of Binary Predicate.

• ForwardIterator 's value type is convertible to BinaryPredicate 's first argument type and second argument type.

Preconditions

• [first, last) is a valid range.

Complexity

Linear. Zero comparisons if [first, last) is an empty range, otherwise exactly (last – first) – 1 comparisons.

Example

int main() {

list L;

generate_n(front_inserter(L), 1000, rand);

list::const_iterator it = max_element(L.begin(), L.end());

cout << "The largest element is " << *it << endl;

}

See also

min , max , min_element , LessThan Comparable, sort , nth_element

lexicographical_compare

Category: algorithms

Component type: function

Prototype

Lexicographical_compare is an overloaded name; there are actually two lexicographical_compare functions.

template

bool lexicographical_compare(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2);

template

bool lexicographical_compare(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2, BinaryPredicate comp);

Читать дальше
Тёмная тема
Сбросить

Интервал:

Закладка:

Сделать

Похожие книги на «Standard Template Library Programmer's Guide»

Представляем Вашему вниманию похожие книги на «Standard Template Library Programmer's Guide» списком для выбора. Мы отобрали схожую по названию и смыслу литературу в надежде предоставить читателям больше вариантов отыскать новые, интересные, ещё непрочитанные произведения.


Отзывы о книге «Standard Template Library Programmer's Guide»

Обсуждение, отзывы о книге «Standard Template Library Programmer's Guide» и просто собственные мнения читателей. Оставьте ваши комментарии, напишите, что Вы думаете о произведении, его смысле или главных героях. Укажите что конкретно понравилось, а что нет, и почему Вы так считаете.

x