]> git.donarmstrong.com Git - lilypond.git/blob - lily/include/drul-array.hh
efc611f76fb1d916757d8dbef443694623b507a3
[lilypond.git] / lily / include / drul-array.hh
1 /*
2   drul-array.hh -- declare Drul_array
3
4   source file of the GNU LilyPond music typesetter
5
6   (c)  1997--1998 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7 */
8
9
10 #ifndef DRUL_ARRAY_HH
11 #define DRUL_ARRAY_HH
12
13 #include "direction.hh"
14
15 #include <assert.h>
16
17 /**
18   Left/right or Up/down arrays. Drul is nicer sounding than udlr
19  */
20 template<class T>
21 struct Drul_array
22 {
23   T array_[2];
24   T &operator[] (Direction d)
25   {
26     assert (d==1 || d== -1);
27     return array_[(d+1)/2];
28   }
29   T operator[]  (Direction d) const
30   {
31     assert (d==1 || d== -1);
32     return array_[(d+1)/2];
33   }
34 };
35
36 #endif // DRUL_ARRAY_HH