|
ADS
Algorithms and Data Structures
|
reads a file through a buffer of one block, \( B \) items of the memory More...
#include <ADS/external/TwoLevelMemory.h>
Public member functions | |
| DiskReader (const DiskFile< T > &f) | |
| the reader of f, its buffer taken from the memory of f | |
| DiskReader (const DiskReader &)=delete | |
| no copy, since the buffer is leased from the memory | |
| DiskReader & | operator= (const DiskReader &)=delete |
| no copy, since the buffer is leased from the memory | |
| bool | hasNext (void) const |
| whether some items are not yet scanned | |
| const T & | peek (void) |
| the next item of the scan, its block read if not in the buffer | |
| T | next (void) |
| the next item of the scan, and the scan moves past it | |
| std::size_t | position (void) const |
| the place of the scan | |
| const T & | at (std::size_t i) |
| the item \( i \), its block read if not in the buffer; the scan goes on from \( i + 1 \) | |
reads a file through a buffer of one block, \( B \) items of the memory
|
explicit |
the reader of f, its buffer taken from the memory of f
|
delete |
no copy, since the buffer is leased from the memory
| const T & ADS::DiskReader< T >::at | ( | std::size_t | i | ) |
the item \( i \), its block read if not in the buffer; the scan goes on from \( i + 1 \)
In pseudocode (chapter 1, Introduction, of Ferragina's book, beyond the book), \( \beta \) the number of the block in the buffer:
\[\class{pseudocode}{\begin{array}{r@{\quad}l} 1 & \textbf{function}\ \mathrm{at}( i ) \cr 2 & \quad \textbf{if}\ \lfloor i / B \rfloor \ne \beta\ \textbf{then} \ \text{read the block } \lfloor i / B \rfloor \text{ into the } \text{buffer};\ \beta \gets \lfloor i / B \rfloor \cr 3 & \quad \mathit{pos} \gets i + 1 \cr 4 & \quad \textbf{return}\ \text{the item } i \bmod B \text{ of the } \text{buffer} \end{array}} \]
|
nodiscard |
whether some items are not yet scanned
| T ADS::DiskReader< T >::next | ( | void | ) |
the next item of the scan, and the scan moves past it
|
delete |
no copy, since the buffer is leased from the memory
| const T & ADS::DiskReader< T >::peek | ( | void | ) |
the next item of the scan, its block read if not in the buffer
|
nodiscard |
the place of the scan