|
ADS
Algorithms and Data Structures
|
The store of blocks of section 14.1 of Morin's book, beyond the book: a disk simulated in memory, an array of blocks of type T addressed by their index, on which readBlock( i ) and writeBlock( i , b ) are the I/Os of the external memory model [see TwoLevelMemory.h], counted one each; placeBlock( b ) writes a new block where a block freed by freeBlock( i ) was, or at the end, so that the indices of the blocks in use stay below their largest number. More...
#include "ADS/Contract.h"#include "ADS/external/TwoLevelMemory.h"#include <cstddef>#include <cstdint>#include <vector>#include "ADS/external/impl/BlockStore.tpp"Go to the source code of this file.
Classes | |
| class | ADS::BlockStore< T > |
| a disk of blocks of type T, read and written one at a time More... | |
Namespaces | |
| namespace | ADS |
The store of blocks of section 14.1 of Morin's book, beyond the book: a disk simulated in memory, an array of blocks of type T addressed by their index, on which readBlock( i ) and writeBlock( i , b ) are the I/Os of the external memory model [see TwoLevelMemory.h], counted one each; placeBlock( b ) writes a new block where a block freed by freeBlock( i ) was, or at the end, so that the indices of the blocks in use stay below their largest number.
A block is copied when it is read and when it is written, as it would be between the disk and the memory, so that what a structure keeps of a block between two I/Os is its own copy, which a test of the internal memory can count. If a TwoLevelMemory is given, its counters count the I/Os too, so that the structures on the blocks and the algorithms on the files of DiskFile share one count.
Against the code of Morin's book: the blocks are values, where the book keeps pointers to the nodes, so that a node changed after its read is changed on the disk with no write, which hides the I/Os that a test of the model would count; the I/Os are counted; and placeBlock() writes the block also in a free place, where the code of the book takes the free index by remove( size() ), one past the last of its stack, and does not store the block there. peek() reads a block with no I/O, for the checks of the contracts only.
The contracts [see Contract.h]: a block read, written, freed or peeked is in use. The operations are defined in BlockStore.tpp.