STXXL
1.4.1
|
stxxl::ksort is a specialization of external memory sorting optimized for records having integer keys.
stxxl::ksort sorts the elements in [first, last) into ascending order, meaning that if i
and j
are any two valid iterators in [first, last) such that i
precedes j
, then *j
is not less than *i
. Note: as std::sort and stxxl::sort, stxxl::ksort is not guaranteed to be stable. That is, suppose that *i
and *j
are equivalent: neither one is less than the other. It is not guaranteed that the relative order of these two elements will be preserved by stxxl::ksort.
The two versions of stxxl::ksort differ in how they define whether one element is less than another. The first version assumes that the elements have key()
member function that returns an integral key (32 or 64 bit), as well as the minimum and the maximum element values. The second version compares objects extracting the keys using keyobj
object, that is in turn provides min and max element values.
The sorter's internal memory consumption is bounded by M
bytes.
first | object of model of ext_random_access_iterator concept |
last | object of model of ext_random_access_iterator concept |
keyobj | key extractor object |
M | amount of memory for internal use (in bytes) |
ExtIterator
is a model of External Random Access Iterator. (In STXXL currently only stxxl::vector provides iterators that are models of External Random Access Iterator.)ExtIterator
is mutable.KeyExtractor
must implement operator()
that extracts the key of an element and provide min and max values for the elements in the input, see Key Extractor Concept.ExtIterator's
value type is convertible to KeyExtractor's
argument type.ExtIterator's
value type has a typedef key_type
.ExtIterator's
value type must have a key()
function that returns the key value of the element, and the min_value()
and max_value()
member functions that return minimum and maximum element values respectively. A model of the Key Extractor concept must:
operator >
, operator <
, operator ==
and operator !=
on type key_type must be defined.min_value
.min_value
and max_value
can not be present in the input sequence.A key extractor object for ordering elements having 64 bit integer keys:
A key extractor class GetWeight, that extracts weight from an Edge:
The same as for stxxl::sort.
The same as for stxxl::sort.
The same as for stxxl::sort.
The same as for stxxl::sort.