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», без необходимости каждый раз заново искать на чём Вы остановились. Поставьте закладку, и сможете в любой момент перейти на страницу, на которой закончили чтение.

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

Интервал:

Закладка:

Сделать
Type requirements

There exist some types U and V such that Pair provides the same interface as a pair . [1]

Public base classes

unary_function

Members
Member Where defined Description
argument_type Adaptable Unary Function The type of select2nd 's argument: Pair
result_type Adaptable Unary Function The type of the result: Pair::second_type
const Pair::second_type& operator()(const Pair& p) const Adaptable Unary Function Function call. The return value is p.second .
New members

All of select2nd 's members are defined in the Adaptable Unary Function requirements. Select2nd does not introduce any new members.

Notes

[1] Pair is not actually required to be a pair , but merely to support the same interface as pair . In almost all cases the template parameter will be a pair , but it is occasionally useful for it to be something else. One example is a struct that has the members first , second , and third .

See also

identity , select1st , project1st , project2nd

subtractive_rng

Category: functors

Component type: type

Description

Subtractive_rng is a Random Number Generator based on the subtractive method [1]. It is a Unary Function: it takes a single argument N , an unsigned int , and returns an unsigned int that is less than N . Successive calls to the same subtractive_rng object [2] yield a pseudo-random sequence.

Example

int main() {

subtractive_rng R;

for (int i = 0; i < 20; ++i) cout << R(5) << ' ';

cout << endl;

}

// The output is 3 2 3 2 4 3 1 1 2 2 0 3 4 4 4 4 2 1 0 0

Definition

Defined in the standard header functional, and in the nonstandard backward-compatibility header function.h. This function object is an SGI extension; it is not part of the C++ standard.

Template parameters

None.

Model of

Random Number Generator, Adaptable Unary Function

Type requirements

None.

Public base classes

unary_function

Members
Parameter Description Default
argument_type Adaptable Unary Function The type of a subtractive_rng 's argument: unsigned int .
result_type Adaptable Unary Function The type of the result: unsigned int .
subtractive_rng(unsigned int seed) subtractive_rng See below.
subtractive_rng() subtractive_rng See below.
unsigned int operator()(unsigned int N) Adaptable Unary Function Function call. Returns a pseudo-random number in the range [0, N) .
void initialize(unsigned int seed) subtractive_rng See below.
New members

These members are not defined in the Adaptable Unary Function requirements, but are specific to subtractive_rng .

Member Description
subtractive_rng(unsigned int seed) The constructor. Creates a subtractive_rng whose internal state is initialized using seed .
subtractive_rng() The default constructor. Creates a subtractive_rng initialized using a default value.
void initialize(unsigned int seed) Re-initializes the internal state of the subtractive_rng , using the value seed .
Notes

[1] See section 3.6 of Knuth for an implementation of the subtractive method in FORTRAN. Section 3.2.2 of Knuth analyzes this class of algorithms. (D. E. Knuth, The Art of Computer Programming. Volume 2: Seminumerical Algorithms , second edition. Addison-Wesley, 1981.)

[2] Note that the sequence produced by a subtractive_rng is completely deterministic, and that the sequences produced by two different subtractive_rng objects are independent of each other. That is: if R1 is a subtractive_rng , then the values returned when R1 is called depend only on R1 's seed and on the number of times that R1 has been called. Calls to other subtractive_rng objects are irrelevant. In implementation terms, this is because the class subtractive_rng contains no static members.

See also

Random Number Generator

Function object adaptors

binder1st

Categories: functors, adaptors

Component type: type

Description

Binder1st is a function object adaptor: it is used to transform an adaptable binary function into an adaptable unary function. Specifically, if f is an object of class binder1st , then f(x) returns F(c, x) , where F is an object of class AdaptableBinaryFunction and where c is a constant. Both F and c are passed as arguments to binder1st 's constructor. [1]

The easiest way to create a binder1st is not to call the constructor explicitly, but instead to use the helper function bind1st .

Example

Finds the first nonzero element in a list.

list L;

list::iterator first_nonzero = find_if(L.begin(), L.end(), bind1st(not_equal_to(), 0));

assert(first_nonzero == L.end() || *first_nonzero != 0);

Definition

Defined in the standard header functional, and in the nonstandard backward-compatibility header function.h.

Template parameters
Parameter Description
AdaptableBinaryFunction The type of the binary function whose first argument is being bound to a constant.
Model of

Adaptable Unary Function

Type requirements

AdaptableBinaryFunction must be a model of Adaptable Binary Function.

Public base classes

unary_function

Members
Member Where defined Description
argument_type Adaptable Unary Function The type of the function object's argument, which is AdaptableBinaryFunction::second_argument_type
result_type Adaptable Unary Function The type of the result: AdaptableBinaryFunction::result_type
result_type operator()(const argument_type& x) const Adaptable Unary Function Function call. Returns F(c, x) , where F and c are the arguments with which this binder1st was constructed.
binder1st(const AdaptableBinaryFunction& F, AdaptableBinaryFunction::first_argument_type c) binder1st See below
template binder1st bind1st(const AdaptableBinaryFunction& F, const T& c); binder1st See below
New members

These members are not defined in the Adaptable Unary Function requirements, but are specific to binder1st .

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

Интервал:

Закладка:

Сделать

Похожие книги на «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