BDE 4.14.0 Production release
Loading...
Searching...
No Matches
bslalg::RangeCompare Struct Reference

#include <bslalg_rangecompare.h>

Public Types

typedef std::size_t size_type
 

Static Public Member Functions

template<class INPUT_ITER >
static bool equal (INPUT_ITER start1, INPUT_ITER end1, INPUT_ITER start2)
 
template<class INPUT_ITER >
static bool equal (INPUT_ITER start1, INPUT_ITER end1, INPUT_ITER start2, INPUT_ITER end2)
 
template<class INPUT_ITER >
static bool equal (INPUT_ITER start1, INPUT_ITER end1, size_type length1, INPUT_ITER start2, INPUT_ITER end2, size_type length2)
 
template<class INPUT_ITER >
static int lexicographical (INPUT_ITER start1, INPUT_ITER end1, INPUT_ITER start2, INPUT_ITER end2)
 
template<class INPUT_ITER >
static int lexicographical (INPUT_ITER start1, INPUT_ITER end1, size_type length1, INPUT_ITER start2, INPUT_ITER end2, size_type length2)
 

Detailed Description

This utility struct provides two static class methods, equal and lexicographical, for comparing two ranges of values. equal returns true if each element in one range has the same value as the corresponding element in the other range, and false otherwise. lexicographical returns 0 if the two ranges are equal, a positive value if the first range is greater than the second, and a negative value if the second range is greater than the first. A range is specified by a pair of beginning and ending iterators, with an optional length parameter. Additionally, an overload is provided for the equal class method that allows the end iterator for one range to be omitted.

equal requires that the elements in the ranges can be compared with operator==.

lexicographical requires that the elements in the ranges can be compared with operator<.

Member Typedef Documentation

◆ size_type

typedef std::size_t bslalg::RangeCompare::size_type

size_type is an alias for an unsigned value representing the size of an object or the number of elements in a range.

Member Function Documentation

◆ equal() [1/3]

template<class INPUT_ITER >
bool bslalg::RangeCompare::equal ( INPUT_ITER  start1,
INPUT_ITER  end1,
INPUT_ITER  start2 
)
inlinestatic

Compare each element in the range beginning at the specified start1 position and ending immediately before the specified end1 position to the corresponding element in the range of the same length beginning at the specified start2 position, as if using operator== element-by-element. Return true if every pair of corresponding elements compares equal, and false otherwise. Note that this implementation uses operator== to perform the comparisons, or bit-wise comparison if the value type has the bit-wise equality-comparable trait.

◆ equal() [2/3]

template<class INPUT_ITER >
bool bslalg::RangeCompare::equal ( INPUT_ITER  start1,
INPUT_ITER  end1,
INPUT_ITER  start2,
INPUT_ITER  end2 
)
inlinestatic

Compare each element in the range beginning at the specified start1 position and ending immediately before the specified end1 position, to the corresponding element in the range beginning at the specified start2 position and ending immediately before the specified end2 position, as if by using operator== element-by-element. Optionally specify the length of each range, length1 and length2. Return true if the ranges have the same length and every element in the first range compares equal with the corresponding element in the second, and false otherwise. The behavior is undefined unless length1 is either unspecified or equals the length of the range [start1, end1), and length2 is either unspecified or equals the length of the range [start2, end2). Note that this implementation uses operator== to perform the comparisons, or bit-wise comparison if the value type has the bit-wise equality-comparable trait. Also note that providing lengths may reduce the runtime cost of this operation.

◆ equal() [3/3]

template<class INPUT_ITER >
bool bslalg::RangeCompare::equal ( INPUT_ITER  start1,
INPUT_ITER  end1,
size_type  length1,
INPUT_ITER  start2,
INPUT_ITER  end2,
size_type  length2 
)
inlinestatic

◆ lexicographical() [1/2]

template<class INPUT_ITER >
int bslalg::RangeCompare::lexicographical ( INPUT_ITER  start1,
INPUT_ITER  end1,
INPUT_ITER  start2,
INPUT_ITER  end2 
)
static

Compare each element in the range beginning at the specified start1 position and ending immediately before the specified end1 position, to the corresponding element in the range beginning at the specified start2 position and ending immediately before the specified end2 position. Optionally specify the length of each range, length1 and length2. Return a negative value if the first range compares lexicographically less than the second range, 0 if they are the same length and compare lexicographically equal, and a positive value if the first range compares lexicographically greater than the second range. The behavior is undefined unless length1 is either unspecified or equals the length of the range [start1, end1), and length2 is either unspecified or equals the length of the range [start2, end2). Note that this implementation uses std::memcmp for unsigned character comparisons, std::wmemcmp for wide character comparisons, and operator< for all other types.

◆ lexicographical() [2/2]

template<class INPUT_ITER >
int bslalg::RangeCompare::lexicographical ( INPUT_ITER  start1,
INPUT_ITER  end1,
size_type  length1,
INPUT_ITER  start2,
INPUT_ITER  end2,
size_type  length2 
)
static

The documentation for this struct was generated from the following file: