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<AdaptableBinaryFunction>

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<AdaptableBinaryFunction>, 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<int> L;

list<int>::iterator first_nonzero = find_if(L.begin(), L.end(), bind1st(not_equal_to<int>(), 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<AdaptableBinaryFunction::second_argument_type, AdaptableBinaryFunction::result_type>

Members
Member Where defined Description
argument_type Adaptable Unary Function The type of the function object's argument, which is
Добавить отзыв
ВСЕ ОТЗЫВЫ О КНИГЕ В ИЗБРАННОЕ

0

Вы можете отметить интересные вам фрагменты текста, которые будут доступны по уникальной ссылке в адресной строке браузера.

Отметить Добавить цитату