7template <
typename Iterator>
8void reverse(Iterator first, Iterator last) {
9 while ((first != last) && (first != --last)) {
10 swap(*first++, *last);
14template <
typename Iterator>
20 Iterator max_iter = first;
23 while (first != last) {
24 if (*max_iter < *first) {
33template <
typename Iterator,
typename Compare>
34Iterator
max_element(Iterator first, Iterator last, Compare comp) {
39 Iterator max_iter = first;
42 while (first != last) {
43 if (comp(*max_iter, *first)) {
52template <
typename Iterator>
58 Iterator min_iter = first;
61 while (first != last) {
62 if (*first < *min_iter) {
71template <
typename Iterator,
typename Compare>
72Iterator
min_element(Iterator first, Iterator last, Compare comp) {
77 Iterator min_iter = first;
80 while (first != last) {
81 if (comp(*first, *min_iter)) {
92template <
typename Iterator1,
typename Iterator2>
93bool equal(Iterator1 first1, Iterator1 last1, Iterator2 first2) {
94 while (first1 != last1) {
95 if (*first1 != *first2) {
104template <
typename Iterator1,
typename Iterator2,
typename BinaryPredicate>
105bool equal(Iterator1 first1, Iterator1 last1, Iterator2 first2, BinaryPredicate pred) {
106 while (first1 != last1) {
107 if (!pred(*first1, *first2)) {
116template <
typename Iterator1,
typename Iterator2>
117bool equal(Iterator1 first1, Iterator1 last1, Iterator2 first2, Iterator2 last2) {
118 while (first1 != last1 && first2 != last2) {
119 if (*first1 != *first2) {
125 return first1 == last1 && first2 == last2;
128template <
typename Iterator1,
typename Iterator2,
typename BinaryPredicate>
129bool equal(Iterator1 first1, Iterator1 last1, Iterator2 first2, Iterator2 last2, BinaryPredicate pred) {
130 while (first1 != last1 && first2 != last2) {
131 if (!pred(*first1, *first2)) {
137 return first1 == last1 && first2 == last2;
140template <
typename Container1,
typename Container2>
142 size_t size1 = c1.size();
143 size_t size2 = c2.size();
144 if (size1 != size2) {
147 return equal(c1.begin(), c1.end(), c2.begin(), c2.end());
150template <
typename Container1,
typename Container2,
typename BinaryPredicate>
151bool equal_container(
const Container1& c1,
const Container2& c2, BinaryPredicate pred) {
152 size_t size1 = c1.size();
153 size_t size2 = c2.size();
154 if (size1 != size2) {
157 return equal(c1.begin(), c1.end(), c2.begin(), c2.end(), pred);
161template <
typename Iterator,
typename T>
162void fill(Iterator first, Iterator last,
const T& value) {
163 while (first != last) {
void swap(array< T, N > &lhs, array< T, N > &rhs) noexcept(noexcept(lhs.swap(rhs)))
Iterator min_element(Iterator first, Iterator last)
void reverse(Iterator first, Iterator last)
Iterator max_element(Iterator first, Iterator last)
bool equal(Iterator1 first1, Iterator1 last1, Iterator2 first2)
bool equal_container(const Container1 &c1, const Container2 &c2)
void fill(Iterator first, Iterator last, const T &value)
Implements a simple red square effect for 2D LED grids.