]> git.lyx.org Git - lyx.git/blob - src/support/block.h
fix lyxalgo.h, dra pagebreak with text on line, change the math_deco_search a bit
[lyx.git] / src / support / block.h
1 // -*- C++ -*-
2
3 #ifndef BLOCK_H
4 #define BLOCK_H
5
6 #include "LAssert.h"
7
8 template <class T, size_t s>
9 class block {
10 public:
11         typedef T value_type;
12         typedef size_t size_type;
13         typedef T * pointer;
14         typedef T const * const_pointer;
15         typedef T & reference;
16         typedef T const & const_reference;
17         typedef T * iterator;
18         typedef T const * const_iterator;
19         size_type size() const { return s; }
20         reference at(int i) {
21                 Assert(i >= 0 && i < s);
22                 return arr[i];
23         }
24         const_reference at(int i) const {
25                 Assert(i >= 0 && i < s);
26                 return arr[i];
27         }
28         reference operator[](int i) { return arr[i]; }
29         const_reference operator[](int i) const { return arr[i]; }
30         void operator=(block const & b) {
31                 Assert(b.size() == size());
32                 for (size_t i = 0; i < size(); ++i) {
33                         arr[i] == b[i];
34                 }
35         }
36         bool operator==(block const & b) const {
37                 Assert(b.size() == size());
38                 for (size_t i = 0; i < size(); ++i) {
39                         if (arr[i] != b[i]) return false;
40                 }
41                 return true;
42         }
43         iterator begin() { return arr[0]; }
44         iterator end() { return arr[s]; }
45         const_iterator begin() const { return arr[0]; }
46         const_iterator end() const { return arr[s]; }
47 private:
48         T arr[s];
49 };
50
51 #endif // BLOCK_H_