Книга: Standard Template Library Programmer
Generalized numeric algorithms
Разделы на этой странице:
iota
Category: algorithms
Component type: function
Prototype
template <class ForwardIterator, class T>
void iota(ForwardIterator first, ForwardIterator last, T value);
Description
Iota assigns sequentially increasing values to a range. That is, it assigns value to *first, value + 1 to *(first + 1) and so on. In general, each iterator i in the range [first, last) is assigned value + (i – first). [1]
Definition
Defined in the standard header numeric, and in the nonstandard backward-compatibility header algo.h. This function is an SGI extension; it is not part of the C++ standard.
Requirements on types
• ForwardIterator is a model of Forward Iterator.
• ForwardIterator is mutable.
• T is Assignable.
• If x is an object of type T, then x++ is defined.
• T is convertible to ForwardIterator's value type.
Preconditions
• [first, last) is a valid range.
Complexity
Linear. Exactly last – first assignments.
Example
int main() {
vector<int> V(10);
iota(V.begin(), V.end(), 7);
copy(V.begin(), V.end(), ostream_iterator<int>(cout, " "));
cout << endl;
}
Notes
[1] The name iota is taken from the programming language APL.
See also
fill, generate, partial_sum
- Algorithms
- BIGINT, NUMERIC(18,0)
- 3.3. ELECTION ALGORITHMS
- 3.1.3. Clock Synchronization Algorithms
- 3.2.4. A Comparison of the Three Algorithms
- 4.3.2. Design Issues for Processor Allocation Algorithms
- 4.3.3. Implementation Issues for Processor Allocation Algorithms
- 4.3.4. Example Processor Allocation Algorithms
- 4.4.5 Scheduling Algorithms
- Generalized identity operations
- Элемент NumericUpDown
- Generalized Assignment