MCPcopy Create free account
hub / github.com/boostorg/compute / prev_permutation

Function prev_permutation

include/boost/compute/algorithm/prev_permutation.hpp:135–165  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

133///
134template<class InputIterator>
135inline bool prev_permutation(InputIterator first,
136 InputIterator last,
137 command_queue &queue = system::default_queue())
138{
139 typedef typename std::iterator_traits<InputIterator>::value_type value_type;
140
141 if(first == last) return false;
142
143 InputIterator first_element =
144 detail::prev_permutation_helper(first, last, queue);
145
146 if(first_element == last)
147 {
148 reverse(first, last, queue);
149 return false;
150 }
151
152 value_type first_value = first_element.read(queue);
153
154 InputIterator ceiling_element =
155 detail::pp_floor(first_element + 1, last, first_value, queue);
156
157 value_type ceiling_value = ceiling_element.read(queue);
158
159 first_element.write(ceiling_value, queue);
160 ceiling_element.write(first_value, queue);
161
162 reverse(first_element + 1, last, queue);
163
164 return true;
165}
166
167} // end compute namespace
168} // end boost namespace

Callers 5

BOOST_AUTO_TEST_CASEFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85

Calls 5

prev_permutation_helperFunction · 0.85
reverseFunction · 0.85
pp_floorFunction · 0.85
readMethod · 0.45
writeMethod · 0.45

Tested by 1

BOOST_AUTO_TEST_CASEFunction · 0.68