Пример #1
0
buffer& buffer::put(const char content, Boolean exp_buf)
{
    //return put((char*)&content, sizeof(content));

    if ( v_bufsz == content_sz() )
    {
        if ( exp_buf == true )
            expand_chunk(v_bufsz + 10);
        else {
            MESSAGE( cerr, "buffer::put(const char): overflow");
            throw ( CASTBNDEXCEPT boundaryException(content_sz(), v_bufsz, 1) );
        }
    }

    *v_eptr = content;
    v_eptr++;
    return *this;
}
Пример #2
0
Boolean heap::insert(voidPtr elm) 
{
   if ( buf_sz() < content_sz() + 2*sizeof(voidPtr) ) 
      buffer::expand_chunk(2*buf_sz()) ;

   long x = long(elm);
   buffer::put(x);

   v_updated = true;

   return true;
}
Пример #3
0
void heap::delete_max(call_back_func_ptr_t call_back)
{
//MESSAGE(cerr, "delete max");
   voidPtr *heap_space = (voidPtr*)buffer::get_base();

   int ct = count();

   heap_space[1] = heap_space[ct];
   set_content_sz(content_sz() - sizeof(voidPtr));

   ct--;

   adjust(1, call_back);
}
Пример #4
0
buffer& buffer::put(const char* content, int sz, Boolean exp_buf)
{
    if ( sz > v_bufsz - content_sz() ) {
        if ( exp_buf == true )
            expand_chunk(v_bufsz + sz);
        else {
            MESSAGE( cerr, "buffer::put(char*, int): overflow");
            throw ( CASTBNDEXCEPT boundaryException(content_sz(), v_bufsz, sz) );
        }
    }

    //memcpy(v_eptr, content, sz);

//debug(cerr, int(v_base));
//debug(cerr, int(v_eptr));

    for ( int i=0; i<sz; i++ ) {
        v_eptr[i] = content[i];
//debug(cerr, int(v_eptr[i]));
    }

    v_eptr += sz;
    return *this;
}