Outline
Purpose
Provide common non-primitive operations on bdlc::PackedIntArray
.
Classes
- See also
- 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:
Definition bdlc_packedintarray.h:1048
bsl::size_t length() const
Return number of elements in this array.
Definition bdlc_packedintarray.h:2586
void push_back(TYPE value)
Definition bdlc_packedintarray.h:2377
Then, verify the array's data has sorted values:
const_iterator end() const
Definition bdlc_packedintarray.h:2556
const_iterator begin() const
Definition bdlc_packedintarray.h:2535
static bool isSorted(PackedIntArrayConstIterator< TYPE > first, PackedIntArrayConstIterator< TYPE > last)
Definition bdlc_packedintarrayutil.h:167
Finally, use bdlc::PackedIntArrayUtil::lowerBound
to find the desired value:
17);
assert(iterator != array.
end() && 19 == *iterator);
Definition bdlc_packedintarray.h:770
static PackedIntArrayConstIterator< TYPE > lowerBound(PackedIntArrayConstIterator< TYPE > first, PackedIntArrayConstIterator< TYPE > last, TYPE value)
Definition bdlc_packedintarrayutil.h:186