2 full-storage.cc -- implement Full_storage
4 source file of the Flower Library
6 (c) 1996, 1997--1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
9 #include "full-storage.hh"
13 Full_storage::operator=(Full_storage
const &fs
)
15 resize (fs
.height_i_
, fs
.width_i_
);
18 for (int i
=0; i
<height_i_
; i
++)
19 for (int j
=0; j
<width_i_
; j
++)
20 els_p_p_
[i
][j
]= fs
.els_p_p_
[i
][j
];
25 Full_storage::OK() const
28 assert (max_height_i_
>= height_i_
&& max_width_i_
>= width_i_
);
29 assert (height_i_
>= 0 && width_i_
>= 0);
30 assert (els_p_p_
||!max_height_i_
);
37 Full_storage::~Full_storage()
39 for (int i
=0; i
< max_height_i_
; i
++)
40 delete [] els_p_p_
[i
];
45 Full_storage::resize (int rows
, int cols
)
50 band_i_
= rows
>? cols
;
54 Full_storage::delete_column (int k
)
56 assert (0 <= k
&&k
<width_i_
);
57 for (int i
=0; i
< height_i_
; i
++)
58 for (int j
=k
+1; j
<width_i_
; j
++)
59 els_p_p_
[i
][j
-1]=els_p_p_
[i
][j
];
65 Full_storage::delete_row (int k
)
67 assert (0 <= k
&&k
<height_i_
);
68 for (int i
=k
+1; i
< height_i_
; i
++)
69 for (int j
=0; j
< width_i_
; j
++)
70 els_p_p_
[i
-1][j
]=els_p_p_
[i
][j
];
77 Full_storage::insert_row (int k
)
79 assert (0 <= k
&& k
<=height_i_
);
80 resize_cols (height_i_
+1);
81 for (int i
=height_i_
-1; i
> k
; i
--)
82 for (int j
=0; j
<width_i_
; j
++)
83 els_p_p_
[i
][j
]=els_p_p_
[i
-1][j
];
87 Full_storage::row (int n
) const
90 for (int j
= 0; j
< cols(); j
++)
96 Full_storage::column (int n
) const
99 for (int i
= 0; i
< rows(); i
++)
105 Full_storage::set_size (int rows
, int cols
)
111 Full_storage::set_size (int rows
)
120 Full_storage::resize_cols (int newh
)
122 if (newh
<= max_height_i_
)
128 Real
** newa
=new Real
*[newh
];
130 for (; j
< height_i_
; j
++)
131 newa
[j
] = els_p_p_
[j
];
132 for (; j
< newh
; j
++)
133 newa
[j
] = new Real
[max_width_i_
];
137 height_i_
= max_height_i_
= newh
;
143 Full_storage::resize_rows (int neww
)
145 if (neww
<= max_width_i_
)
150 for (int i
=0; i
< max_height_i_
; i
++)
152 Real
* newa
= new Real
[neww
];
153 for (int k
=0; k
< width_i_
; k
++)
154 newa
[k
] = els_p_p_
[i
][k
];
156 delete[] els_p_p_
[i
];
159 width_i_
= max_width_i_
= neww
;
168 #include "full-storage.icc"