Silicon Graphics, Inc.

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 algo.h.

Requirements on types

Preconditions

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
[Silicon Surf] [STL Home]
Copyright © 1996 Silicon Graphics, Inc. All Rights Reserved. TrademarkInformation