15namespace layer2_discreta {
17#undef MEMORY_COPY_VERBOSE
19#undef DEBUG_WRITE_CHAR
22#define MEM_OVERSIZE 32
23#define MEM_OVERSIZE1 512
87 cout <<
"memory::freeself(): kind != MEM" << endl;
109#ifdef MEMORY_COPY_VERBOSE
110 cout <<
"in memory::copyobject_to()\n";
114#ifdef MEMORY_CHANGE_KIND_VERBOSE
115 cout <<
"warning: memory::copyobject_to x not a memory\n";
130 ost <<
"memory not allocated";
143 for (i = 0; i < length; i++) {
153 int size, mem_oversize;
157 cout <<
"memory::alloc()" << endl;
166 size = length + mem_oversize + 3 *
sizeof(int);
168 cout <<
"memory::alloc() allocating " << size <<
" chars" << endl;
171 pi = (
int *)
new char[size];
173 cout <<
"memoy::alloc() out of memory" << endl;
178 cout <<
"memory::alloc() setting alloc_length()" << endl;
185 cout <<
"memory::alloc() " <<
used_length() <<
" chars allocated." << endl;
192 int i, old_length, new_length;
195 new_length = old_length + length;
203 for (i = 0; i < length; i++) {
204 pc[old_length + i] = d[i];
217 old_pi = (
int *)old_pc - 3;
220 if (new_length < old_length) {
221 cout <<
"memory::realloc() warning: new_length < old_length" << endl;
227 i <
MINIMUM(old_length, new_length);
231 for (i = old_length; i < new_length; i++) {
237 cout <<
"memory::realloc() to " <<
used_length() <<
" chars" << endl;
243#ifdef DEBUG_WRITE_CHAR
244 cout <<
"memory::write_char(), at " <<
used_length() <<
", writing char " << (int) c << endl;
258 cout <<
"memory::read_char() error: l1 < 1" << endl;
263#ifdef DEBUG_WRITE_CHAR
264 cout <<
"memory::read_char(), at " <<
cur_pointer() <<
", reading char " << (int) c << endl;
274#ifdef DEBUG_WRITE_int
275 cout <<
"memory::write_int(), at " <<
used_length() <<
", writing int " << i1 << endl;
292 cout <<
"memory::read_int() error: l1 < 4" << endl;
297 for (j = 0; j < 4; j++) {
304#ifdef DEBUG_WRITE_int
305 cout <<
"memory::read_int(), at " <<
cur_pointer() <<
", reading " << i1 << endl;
315 int f_v = (verbose_level >= 1);
324 fp = fopen(fname,
"r");
325 if ((
int) fread(pc, 1 , fsize , fp) != fsize) {
326 cout <<
"memory::read_file() error in fread" << endl;
332 cout <<
"memory::read_file() read file "
333 << fname <<
" of size " << fsize << endl;
339 int f_v = (verbose_level >= 1);
348 fp = fopen(fname,
"wb");
350 fwrite(pc, 1 , size , fp);
354 cout <<
"memory::write_file() error: file_size(fname) != size" << endl;
358 cout <<
"memory::write_file() wrote file "
359 << fname <<
" of size " << size << endl;
370 for (i = 0; i < len; i++)
383 int pos = 0, pos2 = 0, pos2h = 0, i;
389 if ((posf % 100000) == 0) {
390 cout << posf << endl;
393 for (i = 0; i < 8; i++) {
396 if (pc[pos] == code_char)
415 int pos = 0, pos2 = 0, i = 8;
419 if (pos2 >= l2 && i >= 8)
426 if (cc & (
uchar) 128U) {
457 cout <<
"compressing from " << l <<
" to ";
460 l2 = l - l_c + ((l + 7) >> 3);
466 cout <<
"memory::compress() warning: l2 = " << l2 <<
" != l3 = " << l3 << endl;
471 cout << l2 <<
" chars." << endl;
485 cout <<
"decompressing from " << l2 <<
" to ";
487 l = decode((
uchar *) pc2, l2, NULL, (
uchar) 0);
493 cout << l <<
" chars." << endl;
514 for (i = 0; i < l; i++) {
529 for (i = 0; i < l; i++) {
a collection of functions related to file io
long int file_size(std::string &fname)
interface to system functions
void block_swap_chars(char *ptr, int size, int no)
DISCRETA base class. All DISCRETA classes are derived from this class.
void swap(discreta_base &a)
void copyobject(discreta_base &x)
DISCRETA class to serialize data structures.
void copyobject_to(discreta_base &x)
int multiplicity_of_character(char c)
void realloc(int new_length)
void append(int length, char *d)
void read_mem(memory &M, int debug_depth)
void write_mem(memory &M, int debug_depth)
memory & operator=(const discreta_base &x)
void read_file(char *fname, int verbose_level)
std::ostream & print(std::ostream &ost)
void write_file(char *fname, int verbose_level)
void init(int length, char *d)
the orbiter library for the classification of combinatorial objects