Quick Links:

bal | bbl | bdl | bsl

Namespaces

Component bslstl_iteratorutil
[Package bslstl]

Provide utilities operating on iterators and iterator ranges. More...

Namespaces

namespace  bslstl

Detailed Description

Outline
Purpose:
Provide utilities operating on iterators and iterator ranges.
Classes:
bslstl::IteratorUtil:
See also:
Component bslstl_hashtable
Description:
This component provides a namespace, bslstl::IteratorUtil, containing utility functions for iterator types. In particular, this component includes a function insertDistance that returns the number of elements that should be accounted for when range-inserting in a container, given a pair of iterator a and b describing a half-open range [a .. b).
Usage:
This section illustrates intended use of this component.
Example 1: Finding the Distance Between Two Random Access Iterators:
Suppose we want to find the number of elements between two random access iterators.
First, we create an array of integer values and two pointers (which are considered random access iterators) referring to the beginning and end of a range within that array:
  int values[] = { 1, 2, 3, 4, 5 };
  int *begin = &values[0];
  int *end   = &values[3];
Now, we use the IteratorUtil::insertDistance class method to calculate the distance of the open range [begin .. end):
  std::size_t distance = IteratorUtil::insertDistance(begin, end);
  assert(3 == distance);