13namespace layer1_foundations {
14namespace data_structures {
65 int page_length_log,
int verbose_level)
67 int f_v = (verbose_level >= 1);
72 cout <<
"page_storage::init "
73 "verbose_level=" << verbose_level << endl;
87 cout <<
"warning: raising entry_size to sizeof(int) = "
98 cout <<
"page_storage::entry_size="
100 cout <<
"(int)sizeof(int)="
101 << (int)
sizeof(
int) << endl;
102 cout <<
"page_length_log = "
104 cout <<
"page_length = "
106 cout <<
"page_size = "
111 cout <<
"page_storage::init page_size "
112 "too big (arithmetic overflow)" << endl;
119 cout <<
"page_storage::init page_size too big" << endl;
120 cout <<
"the maximum page size in char is "
127 cout <<
"page_size is OK" << endl;
137 cout <<
"allocation_table_length="
139 cout <<
"allocating pages / allocation_tables" << endl;
147 cout <<
"allocating page[0] of size " <<
page_size << endl;
151 cout <<
"allocating allocation_tables[0] "
159 cout <<
"pages[0]/allocation_tables[0] allocated" << endl;
165 void (* elt_print)(
void *p,
void *data, ostream &ost),
166 void *elt_print_data)
175 cout <<
"page_storage:" << endl;
179 cout <<
"page_size (in char )=" <<
page_size << endl;
181 cout <<
"allocation_table_length (in char)="
199 cout <<
"page_storage::s_i_and_allocate "
200 "page >= page_ptr_used" << endl;
201 cout <<
"i=" << i << endl;
208 cout <<
"page_idx * entry_size >= page_size" << endl;
214 int word = page_idx >> 3;
215 int bit = page_idx & 7;
220 cout <<
"page_storage::s_i_and_allocate "
221 "word >= allocation_table_length" << endl;
222 cout <<
"word=" << word << endl;
223 cout <<
"allocation_table_length="
229 cout <<
"page_idx=" << page_idx <<
" word=" << word
230 <<
" bit=" << bit <<
" ";
236 uchar_print_bitwise(cout, q[word + j]);
241 if (q[word] & mask) {
242 cout <<
"page_storage::s_i_and_allocate "
243 "allocating entry which is currently in use" << endl;
244 cout <<
"i=" << i << endl;
245 cout <<
"page=" << page << endl;
246 cout <<
"word=" << word << endl;
247 cout <<
"bit=" << bit << endl;
248 cout <<
"mask=" << (int)mask << endl;
249 for (j = 0; j < 10; j++) {
250 cout << (int)q[word + j] <<
" ";
253 for (j = 0; j < 10; j++) {
263 cout <<
"page_idx=" << page_idx <<
" word="
264 << word <<
" bit=" << bit <<
" ";
270 uchar_print_bitwise(cout, q[word + j]);
283 cout <<
"page_storage::s_i_and_deallocate "
284 "i >= overall_length" << endl;
285 cout <<
"i=" << i << endl;
292 cout <<
"page_storage::s_i_and_deallocate "
293 "page >= page_ptr_used" << endl;
294 cout <<
"i=" << i << endl;
301 int word = page_idx >> 3;
302 int bit = page_idx & 7;
304 uchar not_mask = ~mask;
306 cout <<
"page_storage::s_i_and_deallocate "
307 "deallocating entry which is currently not in use" << endl;
308 cout <<
"i=" << i << endl;
319 cout <<
"page_storage::s_i "
320 "i >= overall_length" << endl;
321 cout <<
"i=" << i << endl;
329 cout <<
"page_storage::s_i "
330 "page >= page_ptr_used" << endl;
331 cout <<
"i=" << i << endl;
335 int word = page_idx >> 3;
336 int bit = page_idx & 7;
339 cout <<
"page_storage::s_i "
340 "access to entry which is currently not used" << endl;
341 cout <<
"i=" << i << endl;
353 cout <<
"page_storage::s_i "
354 "i >= overall_length" << endl;
355 cout <<
"i=" << i << endl;
363 cout <<
"page_storage::s_i "
364 "page >= page_ptr_used" << endl;
365 cout <<
"i=" << i << endl;
369 int word = page_idx >> 3;
370 int bit = page_idx & 7;
389 cout <<
"check_allocation_table::s_i "
390 "page >= page_ptr_used" << endl;
394 int word = page_idx >> 3;
401 cout <<
"page_storage::check_allocation_table "
402 "allocation_tables[page][word]" << endl;
403 cout <<
"page_idx >> 3 = " << (page_idx >> 3) << endl;
404 cout <<
"word = " << word << endl;
405 for (j = 0; j < 10; j++) {
409 for (j = 0; j < 10; j++) {
431 long int next_next_free_entry;
435 if (next_next_free_entry < 0 ||
437 cout <<
"page_storage::store "
438 "next_next_free_entry illegal" << endl;
443 if (next_next_free_entry != -1) {
444 cout <<
"page_storage::store "
445 "next_next_free_entry should be -1" << endl;
454#ifdef DEBUG_PAGE_STORAGE
455 cout <<
"page_storage: " << hdl <<
" reused" << endl;
464 cout <<
"page_storage::store "
465 "overall_length > page_ptr_used * page_length" << endl;
472 cout <<
"\npage_storage::store "
478 uchar **allocation_tables1 =
481 pages1[i] =
pages[i];
503#ifdef DEBUG_PAGE_STORAGE
504 cout <<
"calling s_i_and_allocate" << endl;
505 cout <<
"calling s_i_and_allocate "
513#ifdef DEBUG_PAGE_STORAGE
514 cout <<
"page_storage: " << hdl <<
" allocated" << endl;
536#ifdef DEBUG_PAGE_STORAGE
537 cout <<
"page_storage: " << hdl <<
" deallocated" << endl;
544 long int nb = 0, nfe;
556 cout <<
"page_storage::check_free_list "
557 "inconsistency: empty entry marked "
558 "as allocated" << endl;
560 cout <<
"entry = " << nfe << endl;
569 cout <<
"page_storage::check_free_list "
570 "inconsistency" << endl;
572 cout <<
"nb = " << nb << endl;
587void test_page_storage(
int verbose_level)
589 int f_v = (verbose_level >= 1);
592 cout <<
"test_page_storage" << endl;
598 int char_per_elt = 20;
601 Elts->init(char_per_elt , page_length_log, verbose_level - 1);
602 cout <<
"destroying Elts" << endl;
606 cout <<
"test_page_storage done" << endl;
catch all class for algorithms
void uchar_print_bitwise(std::ostream &ost, uchar u)
void uchar_move(uchar *p, uchar *q, int len)
void dispose(long int hdl)
uchar * s_i_and_deallocate(long int i)
void print_storage_used()
long int store(uchar *elt)
long int page_ptr_allocated
void(* elt_print)(void *p, void *data, std::ostream &ost)
uchar ** allocation_tables
void init(int entry_size, int page_length_log, int verbose_level)
long int allocation_table_length
void add_elt_print_function(void(*elt_print)(void *p, void *data, std::ostream &ost), void *elt_print_data)
uchar * s_i_and_allocate(long int i)
void check_allocation_table()
uchar * s_i_and_allocation_bit(long int i, int &f_allocated)
long int page_ptr_oversize
#define MAX_PAGE_SIZE_IN_charS
the orbiter library for the classification of combinatorial objects