]> git.lyx.org Git - lyx.git/blob - src/support/lyxalgo.h
some using changes small changes in lyxfont and some other things, read the Changelog
[lyx.git] / src / support / lyxalgo.h
1 // -*- C++ -*-
2
3 #ifndef LYX_ALGO_H
4 #define LYX_ALGO_H
5
6 //namespace lyx {
7
8 /// Returns true if the sequence first,last is sorted, false if not.
9 template <class For>
10 bool sorted(For first, For last)
11 {
12         if (first == last) return true;
13         For tmp = first;
14         while (++tmp != last) {
15                 if (*tmp < *first++) return false;
16         }
17         return true;
18 }
19
20 /// Cmp is the same Cmp as you would pass to std::sort.
21 template <class For, class Cmp>
22 bool sorted(For first, For last, Cmp cmp)
23 {
24         if (first == last) return true;
25         For tmp = first;
26         while (++tmp != last) {
27                 if (cmp(*tmp, *first++)) return false;
28         }
29         return true;
30 }
31
32 // }  // end of namespace lyx
33 #endif