50 template<
class LIST,
class COMPARER>
53 const int n = L.size();
57 for (
const typename LIST::value_type &x : L)
63 for (
typename LIST::value_type &x : L)
74 template<
typename CONTAINER,
typename TYPE,
typename ITERATOR>
77 std::function<
bool(
const TYPE &)> includeElement) {
80 for(
const auto &e : container) {
81 nElements += includeElement(e) ? 1 : 0;
84 ITERATOR result = container.end();
90 for (ITERATOR it = container.begin(); result == container.end(); it++) {
91 if(includeElement(*it)) {
94 if(elemCounter == chosenElement) {
109 template<
typename CONTAINER,
typename TYPE,
typename ITERATOR>
111 CONTAINER &container,
112 std::function<
bool(
const TYPE &)> includeElement,
117 for (ITERATOR it = container.begin(); it != container.end(); it++) {
124 ITERATOR result = container.end();
126 for (
auto it : other) {
127 if (includeElement(*it)) {
155 template<
typename CONTAINER,
typename TYPE,
typename ITERATOR>
157 CONTAINER &container,
158 std::function<
bool(
const TYPE &)> includeElement,
160 ITERATOR result = container.begin();
161 int size = container.size();
167 for (
int i = 0; i < index; i++) {
172 if (!includeElement(*result)) {
174 result = chooseIteratorByFastTest<CONTAINER, TYPE, ITERATOR>(container, includeElement);
176 result = chooseIteratorBySlowTest<CONTAINER, TYPE, ITERATOR>(container, includeElement, size);
188 template<
typename CONTAINER,
typename TYPE>
190 CONTAINER &container,
191 std::function<
bool(
const TYPE&)> includeElement = [](
const TYPE&) {
return true; },
192 bool isFastTest =
true) {
194 <CONTAINER, TYPE,
typename CONTAINER::iterator>(container, includeElement, isFastTest);
198 template<
typename CONTAINER,
typename TYPE>
200 const CONTAINER &container,
201 std::function<
bool(
const TYPE&)> includeElement = [](
const TYPE&) {
return true; },
202 bool isFastTest =
true) {
204 <
const CONTAINER, TYPE,
typename CONTAINER::const_iterator>(container, includeElement, isFastTest);
ITERATOR chooseIteratorByFastTest(CONTAINER &container, std::function< bool(const TYPE &)> includeElement)
The parameterized class Array implements dynamic arrays of type E.
void quicksortTemplate(LIST &L)
int randomNumber(int low, int high)
Returns random integer between low and high (including).
ITERATOR chooseIteratorFrom(CONTAINER &container, std::function< bool(const TYPE &)> includeElement, bool isFastTest)
Returns an iterator to a random element in the container.
Declaration and implementation of Array class and Array algorithms.
void permute(INDEX l, INDEX r)
Randomly permutes the subarray with index set [l..r].
Standard comparer (valid as a static comparer).
ITERATOR chooseIteratorBySlowTest(CONTAINER &container, std::function< bool(const TYPE &)> includeElement, int size)
void quicksort()
Sorts array using Quicksort.
The namespace for all OGDF objects.