]> git.donarmstrong.com Git - lilypond.git/blob - flower/include/full-storage.icc
partial: 1.0.1.jcn
[lilypond.git] / flower / include / full-storage.icc
1 /*
2   full-storage.icc -- implement Full_storage inline functions
3
4   source file of the Flower Library
5
6   (c)  1997--1998 Han-Wen Nienhuys <hanwen@stack.nl>
7 */
8
9
10 #ifndef FULL_STORAGE_ICC
11 #define FULL_STORAGE_ICC
12
13
14 INLINE void
15 Full_storage::init()
16 {
17   els_p_p_=0;
18   band_i_ = 0;    
19   height_i_=width_i_=max_height_i_=max_width_i_=0;
20 }
21
22 INLINE bool
23 Full_storage::valid (int i, int j) const
24 {
25   return (i>=0 && i < height_i_)
26     && (j < width_i_ && j >=0);
27 }
28
29
30 INLINE
31 Full_storage::Full_storage (Full_storage const&s)
32 {
33   init();
34   (*this) = s;
35 }
36
37 INLINE Real& 
38 Full_storage::elem (int i,int j)
39 {
40   assert (valid (i,j));
41   return els_p_p_[i][j];
42 }
43
44 INLINE Real
45 Full_storage::elem (int i, int j) const {
46   assert (valid (i,j));
47   return els_p_p_[i][j];
48 }
49
50 INLINE
51 Full_storage::Full_storage() {
52   init();
53 }
54
55
56 INLINE int
57 Full_storage::rows() const
58 {
59   return height_i_;
60 }
61
62 INLINE int
63 Full_storage::cols() const
64 {
65   return width_i_;
66 }
67
68 INLINE int
69 Full_storage::dim() const
70 {
71   assert (rows()==cols ());
72   return rows();
73 }
74
75 INLINE void
76 Full_storage::resize (int i)
77 {
78   resize (i,i);
79 }
80
81 INLINE   
82 Full_storage::Full_storage (int i,int j)
83 {
84   init();
85   set_size (i,j);
86 }
87
88 INLINE 
89 Full_storage::Full_storage (int i)
90 {
91   init();
92   set_size (i);
93 }
94
95
96 INLINE
97 bool
98 Full_storage::mult_ok (int i, int ) const
99 {
100   return i < height_i_;
101 }
102
103 INLINE
104 bool
105 Full_storage::trans_ok (int , int j) const
106 {
107   return j < width_i_;
108
109
110
111 INLINE
112 void
113 Full_storage::trans_next (int &i, int &j) const
114 {
115   assert (trans_ok (i,j));
116   i++;
117   if (i >= height_i_) 
118     {
119       i= (0 >? j - band_i_);
120       j ++;
121     }
122 }
123
124 INLINE
125 void
126 Full_storage::mult_next (int &i, int &j) const
127 {
128   assert (mult_ok (i,j));
129   j++;
130   if (j >= width_i_) 
131     {
132       j= 0 >? (i - band_i_);
133       i++;
134     }
135 }
136 #endif // FULL_STORAGE_ICC