lilypond-1.4.3
[lilypond.git] / flower / include / drul-array.hh
blob4e193667f0d6d8b39c35d7d74011c4d7a18a0ab7
1 /*
2 drul-array.hh -- declare Drul_array
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--2000 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7 */
10 #ifndef DRUL_ARRAY_HH
11 #define DRUL_ARRAY_HH
13 #include "direction.hh"
15 #include <assert.h>
17 /**
18 Left/right or Up/down arrays. Drul is nicer sounding than udlr
20 template<class T>
21 struct Drul_array
23 T array_[2];
24 T &elem (Direction d)
26 assert (d==1 || d== -1);
27 return array_[ (d+1)/2];
30 T &operator[] (Direction d)
32 return elem (d);
34 T elem (Direction d) const
36 assert (d==1 || d== -1);
37 return array_[ (d+1)/2];
40 T operator[] (Direction d) const
42 return elem (d);
44 Drul_array ()
46 Drul_array (T t1, T t2)
48 array_[0] = t1;
49 array_[1] = t2;
53 #endif // DRUL_ARRAY_HH