Quick Links:

bal | bbl | bdl | bsl

Namespaces

Component bdlc_packedintarrayutil
[Package bdlc]

Provide common non-primitive operations on bdlc::PackedIntArray. More...

Namespaces

namespace  bdlc

Detailed Description

Outline
Purpose:
Provide common non-primitive operations on bdlc::PackedIntArray.
Classes:
bdlc::PackedIntArrayUtil non-primitive bdlc::PackedIntArray operations
See also:
Component bdlc_packedintarray
Description:
This component provides a struct, bdlc::PackedIntArrayUtil, that serves as a namespace for utility functions that operate on bdlc::PackedIntArray objects.
The following list of methods are provided by bdlc::PackedIntArrayUtil:
  'isSorted'         Returns 'true' if the range from a
                     'bdlc::PackedIntArray' is sorted, and 'false' otherwise.

  'lowerBound'       Returns an iterator to the first element in a sorted
                     range from a 'bdlc::PackedIntArray' that compares
                     greater than or equal to a specified value.

  'upperBound'       Returns an iterator to the first element in a sorted
                     range from a 'bdlc::PackedIntArray' that compares
                     greater than a specified value.
Usage:
This section illustrates intended use of this component.
Example 1: lowerBound:
Suppose that given a sorted bdlc::PackedIntArray, we want to find the first value greater than or equal to the value 17. First, create and populate with sorted data the bdlc::PackedIntArray to be searched:
  bdlc::PackedIntArray<int> array;

  array.push_back( 5);
  array.push_back( 9);
  array.push_back(15);
  array.push_back(19);
  array.push_back(23);
  array.push_back(36);
  assert(6 == array.length());
Then, verify the array's data has sorted values:
  assert(bdlc::PackedIntArrayUtil::isSorted(array.begin(), array.end()));
Finally, use bdlc::PackedIntArrayUtil::lowerBound to find the desired value:
  bdlc::PackedIntArrayConstIterator<int> iterator =
                          bdlc::PackedIntArrayUtil::lowerBound(array.begin(),
                                                               array.end(),
                                                               17);
  assert(iterator != array.end() && 19 == *iterator);