STXXL  1.4.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
stxxl::vector_bufreader< VectorIteratorType > Class Template Reference

Detailed Description

template<typename VectorIteratorType>
class stxxl::vector_bufreader< VectorIteratorType >

Buffered sequential reader from a vector using overlapped I/O.

This buffered reader can be used to read a large sequential region of a vector using overlapped I/O. The object is created from an iterator range, which can then be read to using operator<<(), or with operator*() and operator++().

The interface also fulfills all requirements of a stream. Actually most of the code is identical to stream::vector_iterator2stream.

Note that this buffered reader is inefficient for reading small ranges. This is intentional, as one can just use operator[] on the vector for that.

See Efficient Sequential Reading and Writing to Vectors

Definition at line 262 of file vector.h.

+ Inheritance diagram for stxxl::vector_bufreader< VectorIteratorType >:
+ Collaboration diagram for stxxl::vector_bufreader< VectorIteratorType >:

Public Types

typedef
vector_iterator::bids_container_iterator 
bids_container_iterator
 block identifier iterator of the vector More...
 
typedef vector_iterator::block_type block_type
 block type used in the vector More...
 
typedef buf_istream
< block_type,
bids_container_iterator
buf_istream_type
 construct output buffered stream used for overlapped reading More...
 
typedef
vector_bufreader_iterator
< vector_bufreader
bufreader_iterator
 construct an iterator for vector_bufreader (for C++11 range-based for loop) More...
 
typedef vector_type::size_type size_type
 size of remaining data More...
 
typedef vector_iterator::value_type value_type
 value type of the output vector More...
 
typedef VectorIterator vector_iterator
 template parameter: the vector iterator type More...
 
typedef
vector_iterator::vector_type 
vector_type
 type of the input vector More...
 

Public Member Functions

 vector_bufreader (vector_iterator begin, vector_iterator end, unsigned_type nbuffers=0)
 Create overlapped reader for the given iterator range. More...
 
 vector_bufreader (const vector_type &vec, unsigned_type nbuffers=0)
 Create overlapped reader for the whole vector's content. More...
 
 ~vector_bufreader ()
 Finish reading and free buffered reader. More...
 
bufreader_iterator begin ()
 Return vector_bufreader_iterator for C++11 range-based for loop. More...
 
bool empty () const
 Returns true once the whole range has been read. More...
 
bufreader_iterator end ()
 Return vector_bufreader_iterator for C++11 range-based for loop. More...
 
const value_typeoperator* () const
 Return constant reference to current item. More...
 
vector_bufreaderoperator++ ()
 Advance to next item (asserts if !empty()). More...
 
const value_typeoperator-> () const
 Return constant pointer to current item. More...
 
vector_bufreaderoperator>> (value_type &v)
 Read current item into variable and advance to next one. More...
 
void rewind ()
 Rewind stream back to begin. Note that this recreates the buffered reader and is thus not cheap. More...
 
size_type size () const
 Return remaining size. More...
 

Protected Attributes

vector_iterator m_begin
 iterator to the beginning of the range. More...
 
buf_istream_typem_bufin
 buffered input stream used to overlapped I/O. More...
 
vector_iterator m_end
 iterator to the end of the range. More...
 
vector_iterator m_iter
 internal "current" iterator into the vector. More...
 
unsigned_type m_nbuffers
 number of blocks to use as buffers. More...
 

Additional Inherited Members

- Protected Member Functions inherited from stxxl::noncopyable
 noncopyable ()
 

Member Typedef Documentation

template<typename VectorIteratorType >
typedef vector_iterator::bids_container_iterator stxxl::vector_bufreader< VectorIteratorType >::bids_container_iterator

block identifier iterator of the vector

Definition at line 1936 of file vector.h.

template<typename VectorIteratorType >
typedef vector_iterator::block_type stxxl::vector_bufreader< VectorIteratorType >::block_type

block type used in the vector

Definition at line 1930 of file vector.h.

template<typename VectorIteratorType >
typedef buf_istream<block_type, bids_container_iterator> stxxl::vector_bufreader< VectorIteratorType >::buf_istream_type

construct output buffered stream used for overlapped reading

Definition at line 1939 of file vector.h.

template<typename VectorIteratorType >
typedef vector_bufreader_iterator<vector_bufreader> stxxl::vector_bufreader< VectorIteratorType >::bufreader_iterator

construct an iterator for vector_bufreader (for C++11 range-based for loop)

Definition at line 1942 of file vector.h.

template<typename VectorIteratorType >
typedef vector_type::size_type stxxl::vector_bufreader< VectorIteratorType >::size_type

size of remaining data

Definition at line 1945 of file vector.h.

template<typename VectorIteratorType >
typedef vector_iterator::value_type stxxl::vector_bufreader< VectorIteratorType >::value_type

value type of the output vector

Definition at line 1927 of file vector.h.

template<typename VectorIteratorType >
typedef VectorIterator stxxl::vector_bufreader< VectorIteratorType >::vector_iterator

template parameter: the vector iterator type

Definition at line 1924 of file vector.h.

template<typename VectorIteratorType >
typedef vector_iterator::vector_type stxxl::vector_bufreader< VectorIteratorType >::vector_type

type of the input vector

Definition at line 1933 of file vector.h.

Constructor & Destructor Documentation

template<typename VectorIteratorType >
stxxl::vector_bufreader< VectorIteratorType >::vector_bufreader ( vector_iterator  begin,
vector_iterator  end,
unsigned_type  nbuffers = 0 
)
inline

Create overlapped reader for the given iterator range.

Parameters
beginiterator to position were to start reading in vector
enditerator to position were to end reading in vector
nbuffersnumber of buffers used for overlapped I/O (>= 2*D recommended)

Definition at line 1971 of file vector.h.

template<typename VectorIteratorType >
stxxl::vector_bufreader< VectorIteratorType >::vector_bufreader ( const vector_type vec,
unsigned_type  nbuffers = 0 
)
inline

Create overlapped reader for the whole vector's content.

Parameters
vecvector to read
nbuffersnumber of buffers used for overlapped I/O (>= 2*D recommended)

Definition at line 1988 of file vector.h.

template<typename VectorIteratorType >
stxxl::vector_bufreader< VectorIteratorType >::~vector_bufreader ( )
inline

Finish reading and free buffered reader.

Definition at line 2024 of file vector.h.

Member Function Documentation

template<typename VectorIteratorType >
bufreader_iterator stxxl::vector_bufreader< VectorIteratorType >::begin ( )
inline

Return vector_bufreader_iterator for C++11 range-based for loop.

Definition at line 2079 of file vector.h.

template<typename VectorIteratorType >
bool stxxl::vector_bufreader< VectorIteratorType >::empty ( ) const
inline

Returns true once the whole range has been read.

Definition at line 2073 of file vector.h.

template<typename VectorIteratorType >
bufreader_iterator stxxl::vector_bufreader< VectorIteratorType >::end ( )
inline

Return vector_bufreader_iterator for C++11 range-based for loop.

Definition at line 2085 of file vector.h.

template<typename VectorIteratorType >
const value_type& stxxl::vector_bufreader< VectorIteratorType >::operator* ( ) const
inline

Return constant reference to current item.

Definition at line 2030 of file vector.h.

template<typename VectorIteratorType >
vector_bufreader& stxxl::vector_bufreader< VectorIteratorType >::operator++ ( )
inline

Advance to next item (asserts if !empty()).

Definition at line 2042 of file vector.h.

References UNLIKELY.

template<typename VectorIteratorType >
const value_type* stxxl::vector_bufreader< VectorIteratorType >::operator-> ( ) const
inline

Return constant pointer to current item.

Definition at line 2036 of file vector.h.

template<typename VectorIteratorType >
vector_bufreader& stxxl::vector_bufreader< VectorIteratorType >::operator>> ( value_type v)
inline

Read current item into variable and advance to next one.

Definition at line 2057 of file vector.h.

References operator++().

template<typename VectorIteratorType >
void stxxl::vector_bufreader< VectorIteratorType >::rewind ( )
inline

Rewind stream back to begin. Note that this recreates the buffered reader and is thus not cheap.

Definition at line 2003 of file vector.h.

template<typename VectorIteratorType >
size_type stxxl::vector_bufreader< VectorIteratorType >::size ( ) const
inline

Return remaining size.

Definition at line 2066 of file vector.h.

Member Data Documentation

template<typename VectorIteratorType >
vector_iterator stxxl::vector_bufreader< VectorIteratorType >::m_begin
protected

iterator to the beginning of the range.

Definition at line 1949 of file vector.h.

template<typename VectorIteratorType >
buf_istream_type* stxxl::vector_bufreader< VectorIteratorType >::m_bufin
protected

buffered input stream used to overlapped I/O.

Definition at line 1958 of file vector.h.

template<typename VectorIteratorType >
vector_iterator stxxl::vector_bufreader< VectorIteratorType >::m_end
protected

iterator to the end of the range.

Definition at line 1955 of file vector.h.

template<typename VectorIteratorType >
vector_iterator stxxl::vector_bufreader< VectorIteratorType >::m_iter
protected

internal "current" iterator into the vector.

Definition at line 1952 of file vector.h.

template<typename VectorIteratorType >
unsigned_type stxxl::vector_bufreader< VectorIteratorType >::m_nbuffers
protected

number of blocks to use as buffers.

Definition at line 1961 of file vector.h.


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