ADS
Algorithms and Data Structures
Loading...
Searching...
No Matches
ADS::DiskFile< T > Class Template Reference

a file of items on the disk of the model, in blocks of \( B \) items More...

#include <ADS/external/TwoLevelMemory.h>

Public types

using value_type = T
 the type of the items
using size_type = std::size_t
 the type of the sizes

Public member functions

 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
 the file moved, no I/O
DiskFile & operator= (DiskFile &&other)
 a rename on the disk, no I/O
 DiskFile (const DiskFile &)=delete
 no copy, which would duplicate the file without paying its I/Os
DiskFile & operator= (const DiskFile &)=delete
 no copy, which would duplicate the file without paying its I/Os
TwoLevelMemory & memory (void) const
 the memory of the model that the file is on
std::size_t size (void) const
 the number of items of the file
bool empty (void) const
 whether the file has no item
std::size_t blocks (void) const
 the blocks of the file, \( \lceil \mathrm{size}() / B \rceil \)
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
void appendBlock (const T *src, std::size_t n)
 one write: the \( n \) items of src appended as a new block
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

Detailed description

template<class T>
class ADS::DiskFile< T >

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

Member typedef documentation

◆ size_type

template<class T>
using ADS::DiskFile< T >::size_type = std::size_t

the type of the sizes

◆ value_type

template<class T>
using ADS::DiskFile< T >::value_type = T

the type of the items

Constructor and destructor documentation

◆ DiskFile() [1/4]

template<class T>
ADS::DiskFile< T >::DiskFile ( TwoLevelMemory & mem)
explicit

an empty file

◆ DiskFile() [2/4]

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

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

◆ DiskFile() [3/4]

template<class T>
ADS::DiskFile< T >::DiskFile ( DiskFile< T > && )
defaultnoexcept

the file moved, no I/O

◆ DiskFile() [4/4]

template<class T>
ADS::DiskFile< T >::DiskFile ( const DiskFile< T > & )
delete

no copy, which would duplicate the file without paying its I/Os

Member function documentation

◆ appendBlock()

template<class T>
void ADS::DiskFile< T >::appendBlock ( const T * src,
std::size_t n )

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

Precondition
\( 1 \le n \le B \), and size() a multiple of \( B \)

◆ blocks()

template<class T>
std::size_t ADS::DiskFile< T >::blocks ( void ) const
nodiscard

the blocks of the file, \( \lceil \mathrm{size}() / B \rceil \)

◆ clear()

template<class T>
void ADS::DiskFile< T >::clear ( void )

empties the file, no I/O

◆ contents()

template<class T>
const std::vector< T > & ADS::DiskFile< T >::contents ( void ) const
nodiscard

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

◆ empty()

template<class T>
bool ADS::DiskFile< T >::empty ( void ) const
nodiscard

whether the file has no item

◆ memory()

template<class T>
TwoLevelMemory & ADS::DiskFile< T >::memory ( void ) const
nodiscard

the memory of the model that the file is on

◆ operator=() [1/2]

template<class T>
DiskFile & ADS::DiskFile< T >::operator= ( const DiskFile< T > & )
delete

no copy, which would duplicate the file without paying its I/Os

◆ operator=() [2/2]

template<class T>
DiskFile & ADS::DiskFile< T >::operator= ( DiskFile< T > && other)

a rename on the disk, no I/O

Precondition
the two files share the memory

◆ readBlock()

template<class T>
std::size_t ADS::DiskFile< 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

Precondition
\( b \) is below blocks()

◆ size()

template<class T>
std::size_t ADS::DiskFile< T >::size ( void ) const
nodiscard

the number of items of the file


The documentation for this class was generated from the following file: