ADC Home > Reference Library > Reference > Darwin > Miscellaneous User Space API Reference

 


stl_iterator_base_funcs.h

Includes:

Introduction

This is an internal header file, included by other library headers. You should not attempt to use it directly.

This file contains all of the general iterator-related utility functions, such as distance() and advance().



Functions

advance
distance

advance


template<typename _InputIterator, typename _Distance> inline void advance(
    _InputIterator& __i,
    _Distance __n) 
Parameters
i
An input iterator.
n
The "delta" by which to change @p i.
Return Value

Nothing.

This increments @p i by @p n. For bidirectional and random access iterators, @p n may be negative, in which case @p i is decremented.

For random access iterators, this uses their @c + and @c - operations and are constant time. For other %iterator classes they are linear time.

Discussion

@brief A generalization of pointer arithmetic.


distance


template<typename _InputIterator> inline typename iterator_traits<_InputIterator>::difference_type distance(
    _InputIterator __first,
    _InputIterator __last) 
Parameters
first
An input iterator.
last
An input iterator.
Return Value

The distance between them.

Returns @c n such that first + n == last. This requires that @p last must be reachable from @p first. Note that @c n may be negative.

For random access iterators, this uses their @c + and @c - operations and are constant time. For other %iterator classes they are linear time.

Discussion

@brief A generalization of pointer arithmetic.

Last Updated: 2006-06-20