All pastes #9745 Raw Edit

Hashing med fil

public cpp v1 · immutable
#9745 ·published 2005-04-18 10:47 UTC
rendered paste body
void HashTabell::nyPost( long nokkel ){int hashAdresse, inx;long filPos;bool fullFil = false, funnet = false;hFil.open( filNavn, ios::in | ios::binary );if ( !hFil.is_open() ) {ShowMessage( "Filen kan ikke °apnes." );return;}hFil.close();//°Apner eksisterende filhFil.open( filNavn, ios::Lin | ios::out | ios::binary );finnPlass( nokkel, hashAdresse, inx, funnet, fullFil );Post * blokk = new Post[ antallIBlokk ];if ( !fullFil && !funnet ) {filPos = hashAdresse * sizeof( Post ) * antallIBlokk;hFil.seekg( filPos, ios::beg );hFil.read( ( char * ) blokk, sizeof( Post ) * antallIBlokk );blokk[ inx ].nokkel = nokkel;blokk[ inx ].tilstand = IBRUK;hFil.seekg( filPos, ios::beg );hFil.write( ( char * ) blokk, sizeof( Post ) * antallIBlokk );}hFil.close();delete blokk;}