/usr/include/polymake/internal/extend_algo.h is in libpolymake-dev-common 3.2r2-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 | /* Copyright (c) 1997-2018
Ewgenij Gawrilow, Michael Joswig (Technische Universitaet Berlin, Germany)
http://www.polymake.org
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2, or (at your option) any
later version: http://www.gnu.org/licenses/gpl.txt.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
--------------------------------------------------------------------------------
*/
#ifndef POLYMAKE_INTERNAL_EXTEND_ALGO_H
#define POLYMAKE_INTERNAL_EXTEND_ALGO_H
namespace pm {
template <typename Iterator1, typename Iterator2> inline
void copy_range_impl(Iterator1&& src, Iterator2&& dst, std::true_type, std::false_type)
{
for (; !src.at_end(); ++src, ++dst) *dst=*src;
}
template <typename Iterator1, typename Iterator2> inline
void copy_range_impl(Iterator1&& src, Iterator2&& dst, std::false_type, std::true_type)
{
for (; !dst.at_end(); ++src, ++dst) *dst=*src;
}
template <typename Iterator1, typename Iterator2> inline
void copy_range_impl(Iterator1&& src, Iterator2&& dst, std::true_type, std::true_type)
{
for (; !src.at_end() && !dst.at_end(); ++src, ++dst) *dst=*src;
}
template <typename Iterator1, typename Iterator2,
typename=typename std::enable_if<check_iterator_feature<Iterator1, end_sensitive>::value ||
check_iterator_feature<Iterator2, end_sensitive>::value>::type>
inline
private_mutable_t<Iterator2> copy_range(Iterator1&& src, Iterator2&& dst)
{
private_mutable_t<Iterator2> dst_it=ensure_private_mutable(std::forward<Iterator2>(dst));
copy_range_impl(ensure_private_mutable(std::forward<Iterator1>(src)), dst_it,
bool_constant<check_iterator_feature<Iterator1, end_sensitive>::value>(),
bool_constant<check_iterator_feature<Iterator2, end_sensitive>::value>());
return std::move(dst_it);
}
template <typename Iterator1, typename Iterator2> inline
bool equal_ranges_impl(Iterator1&& it1, Iterator2&& it2, std::true_type, std::false_type)
{
for (; !it1.at_end(); ++it1, ++it2)
if (*it1 != *it2) return false;
return true;
}
template <typename Iterator1, typename Iterator2> inline
bool equal_ranges_impl(Iterator1&& it1, Iterator2&& it2, std::false_type, std::true_type)
{
for (; !it2.at_end(); ++it1, ++it2)
if (*it1 != *it2) return false;
return true;
}
template <typename Iterator1, typename Iterator2> inline
bool equal_ranges_impl(Iterator1&& it1, Iterator2&& it2, std::true_type, std::true_type)
{
for (; !it1.at_end() && !it2.at_end(); ++it1, ++it2)
if (*it1 != *it2) return false;
return it1.at_end() && it2.at_end();
}
template <typename Iterator1, typename Iterator2,
typename=typename std::enable_if<check_iterator_feature<Iterator1, end_sensitive>::value ||
check_iterator_feature<Iterator2, end_sensitive>::value>::type>
inline
bool equal_ranges(Iterator1&& it1, Iterator2&& it2)
{
return equal_ranges_impl(ensure_private_mutable(std::forward<Iterator1>(it1)),
ensure_private_mutable(std::forward<Iterator2>(it2)),
bool_constant<check_iterator_feature<Iterator1, end_sensitive>::value>(),
bool_constant<check_iterator_feature<Iterator2, end_sensitive>::value>());
}
template <typename Iterator1, typename Iterator2> inline
void swap_ranges_impl(Iterator1&& it1, Iterator2&& it2, std::true_type, std::false_type)
{
for (; !it1.at_end(); ++it1, ++it2) std::swap(*it1, *it2);
}
template <typename Iterator1, typename Iterator2> inline
void swap_ranges_impl(Iterator1&& it1, Iterator2&& it2, std::false_type, std::true_type)
{
for (; !it2.at_end(); ++it1, ++it2) std::swap(*it1, *it2);
}
template <typename Iterator1, typename Iterator2> inline
void swap_ranges_impl(Iterator1&& it1, Iterator2&& it2, std::true_type, std::true_type)
{
for (; !it1.at_end() && !it2.at_end(); ++it1, ++it2) std::swap(*it1, *it2);
}
template <typename Iterator1, typename Iterator2,
typename=typename std::enable_if<check_iterator_feature<Iterator1, end_sensitive>::value ||
check_iterator_feature<Iterator2, end_sensitive>::value>::type>
inline
void swap_ranges(Iterator1&& it1, Iterator2&& it2)
{
swap_ranges_impl(ensure_private_mutable(std::forward<Iterator1>(it1)),
ensure_private_mutable(std::forward<Iterator2>(it2)),
bool_constant<check_iterator_feature<Iterator1, end_sensitive>::value>(),
bool_constant<check_iterator_feature<Iterator2, end_sensitive>::value>());
}
template <typename Iterator,
typename=typename std::enable_if<check_iterator_feature<Iterator, end_sensitive>::value>::type>
inline
typename iterator_traits<Iterator>::value_type
first_differ_in_range(Iterator&& src, const typename iterator_traits<Iterator>::value_type& from)
{
auto&& it=ensure_private_mutable(std::forward<Iterator>(src));
for (; !it.at_end(); ++it) {
const typename iterator_traits<Iterator>::value_type v=*it;
if (v != from) return v;
}
return from;
}
template <typename Iterator, typename Value,
typename=typename std::enable_if<check_iterator_feature<Iterator, end_sensitive>::value>::type>
inline
void fill_range(Iterator&& dst, const Value& x)
{
auto&& it=ensure_private_mutable(std::forward<Iterator>(dst));
for (; !it.at_end(); ++it) *it=x;
}
template <typename Iterator, typename Value,
typename=typename std::enable_if<check_iterator_feature<Iterator, end_sensitive>::value>::type>
inline
private_mutable_t<Iterator>
find_in_range(Iterator&& src, const Value& x)
{
private_mutable_t<Iterator> it=ensure_private_mutable(std::forward<Iterator>(src));
while (!it.at_end() && *it != x) ++it;
return std::move(it);
}
template <typename Iterator, typename Predicate,
typename=typename std::enable_if<check_iterator_feature<Iterator, end_sensitive>::value>::type>
inline
private_mutable_t<Iterator>
find_in_range_if(Iterator&& src, const Predicate& pred_arg)
{
typedef pm::unary_helper<pure_type_t<Iterator>, Predicate> helper;
const typename helper::operation& pred=helper::create(pred_arg);
private_mutable_t<Iterator> it=ensure_private_mutable(std::forward<Iterator>(src));
while (!it.at_end() && !pred(*helper::get(it))) ++it;
return std::move(it);
}
} // end namespace pm
#endif // POLYMAKE_INTERNAL_EXTEND_ALGO_H
// Local Variables:
// mode:C++
// c-basic-offset:3
// indent-tabs-mode:nil
// End:
|