Utilities used by coveo::enumerable
.
More...
Go to the source code of this file.
|
template<typename C , typename Seq > |
auto | coveo::try_reserve (C &cnt, const Seq &seq) -> typename std::enable_if< is_enumerable< Seq >::value, bool >::type |
| Helper function to quickly reserve space in a container if possible. More...
|
|
template<typename Seq > |
auto | coveo::try_get_size_delegate (const Seq &seq) -> typename std::enable_if< is_enumerable< Seq >::value, std::function< std::size_t()>>::type |
| Helper function to get a fast size delegate if possible. More...
|
|
template<typename It > |
auto | coveo::try_get_size_delegate_for_iterators (const It &beg, const It &end) -> typename std::enable_if< std::is_base_of< std::random_access_iterator_tag, typename std::iterator_traits< It >::iterator_category >::value, std::function< std::size_t()>>::type |
| Helper function to get a fast size delegate from iterators if possible. More...
|
|
- Copyright
- 2016-2019, Coveo Solutions Inc. Distributed under the Apache License, Version 2.0 (see LICENSE).
◆ try_reserve()
template<typename C , typename Seq >
auto coveo::try_reserve |
( |
C & |
cnt, |
|
|
const Seq & |
seq |
|
) |
| -> typename std::enable_if<is_enumerable<Seq>::value, bool>::type
|
Attempts to reserve
space in container cnt
to hold as many elements as found in sequence seq
. This is performed only if it's possible to do so "quickly".
- Parameters
-
cnt | Container in which to reserve space. |
seq | Sequence to use to try to reserve space for. |
- Returns
true
if space has actually been reserved in cnt
.
◆ try_get_size_delegate()
template<typename Seq >
auto coveo::try_get_size_delegate |
( |
const Seq & |
seq | ) |
-> typename std::enable_if<is_enumerable<Seq>::value,
std::function<std::size_t()>>::type
|
Attempts to create a coveo::enumerable::size_delegate
that can quickly calculate the number of elements found in sequence seq
. A size delegate is returned only if it's possible to calculate the number of elements "quickly".
- If
seq
is a coveo::enumerable
, its coveo::enumerable::size()
method is used to produce the size delegate if coveo::enumerable::has_fast_size()
returns true
.
- If
seq
is a container with a size()
method, a size delegate is produced using that method.
- If
seq
is a sequence that uses random-access iterators, a size delegate is produced by using std::distance()
.
- Otherwise, no size delegate is produced.
- Parameters
-
seq | Sequence to calculate the number of elements of in order to produce the size delegate. |
- Returns
coveo::enumerable::size_delegate
instance, or nullptr
if it's not possible to quickly calculate the number of elements in seq
.
- See also
- coveo::enumerable::size_delegate
◆ try_get_size_delegate_for_iterators()
template<typename It >
auto coveo::try_get_size_delegate_for_iterators |
( |
const It & |
beg, |
|
|
const It & |
end |
|
) |
| -> typename std::enable_if<std::is_base_of<std::random_access_iterator_tag,
typename std::iterator_traits<It>::iterator_category>::value,
std::function<std::size_t()>>::type
|
Attempts to create a coveo::enumerable::size_delegate
that can quickly calculate the number of elements in range [beg, end[
. A size delegate is returned only if it's possible to calculate the number of elements "quickly".
- If
beg
and end
are random-access iterators, a size delegate is produced by using std::distance()
.
- Otherwise, no size delegate is produced.
- Parameters
-
beg | Iterator pointing at beginning of range. |
end | Iterator pointing at end of range. |
- Returns
coveo::enumerable::size_delegate
instance, or nullptr
if it's not possible to quickly calculate the number of elements in [beg, end[
- See also
- coveo::enumerable::size_delegate