Template Class DiskFile

Class Documentation

template<class T>
class DiskFile

a file of items on the disk of the model, in blocks of B items

Public Types

using value_type = T
using size_type = std::size_t

Public Functions

explicit DiskFile(TwoLevelMemory &mem)

an empty file

DiskFile(TwoLevelMemory &mem, std::vector<T> items)

the file of the items, laid out with no I/O: the input of a problem

DiskFile(DiskFile&&) noexcept = default
DiskFile &operator=(DiskFile &&other)

a rename on the disk, no I/O

Pre:

the two files share the memory

DiskFile(const DiskFile&) = delete
DiskFile &operator=(const DiskFile&) = delete
TwoLevelMemory &memory(void) const
std::size_t size(void) const
bool empty(void) const
std::size_t blocks(void) const

the blocks of the file, ceil( size() / B )

std::size_t readBlock(std::size_t b, T *dest) const

one read: the block b copied to dest, which has room for B items; the number of its items

Pre:

b < blocks()

void appendBlock(const T *src, std::size_t n)

one write: the n items of src appended as a new block

Pre:

1 <= n <= B and size() a multiple of B

void clear(void)

empties the file, no I/O

const std::vector<T> &contents(void) const

the items, no I/O: for the checks, not for the algorithms