STXXL
1.4-dev
|
External sequence or deque container without random access.
Introduction to sequence container: see STXXL Sequence tutorial.
Design and Internals of sequence container: see Queue.
Sequence is a primitive container consisting of only a sequence of blocks in external memory. The sequence provides appending methods similar to a deque: push_back and push_front; and also the corresponding pop functions. However, different from stxxl::deque (which is a vector in disguise), the sequence does not allow random access. Instead, the sequence can only be iterated using streams: either from front to back or in reverse.
As with queue and stack, sequences of pushes and pops are made efficient using overlapping or read-ahead via block pools. The stream access likewise uses overlapped I/O, just like stream::vector_iterator2stream.
ValueType | type of the contained objects (POD with no references to internal memory) |
BlockSize | size of the external memory block in bytes, default is STXXL_DEFAULT_BLOCK_SIZE(ValTp) |
AllocStr | parallel disk allocation strategy, default is STXXL_DEFAULT_ALLOC_STRATEGY |
SizeType | size data type, default is stxxl::uint64 |
Definition at line 62 of file sequence.h.
Classes | |
class | reverse_stream |
class | stream |
Public Types | |
enum | { block_size = BlockSize } |
typedef AllocStr | alloc_strategy_type |
typedef std::deque< bid_type > | bid_deque_type |
typedef BID< block_size > | bid_type |
typedef typed_block < block_size, value_type > | block_type |
typedef SizeType | size_type |
typedef ValueType | value_type |
Public Member Functions | |
Constructors/Destructors | |
sequence (int_type D=-1) | |
Constructs empty sequence with own write and prefetch block pool. More... | |
sequence (unsigned_type w_pool_size, unsigned_type p_pool_size, int blocks2prefetch=-1) | |
Constructs empty sequence with own write and prefetch block pool. More... | |
sequence (pool_type &pool, int blocks2prefetch=-1) | |
Constructs empty sequence. More... | |
~sequence () | |
Modifiers | |
void | swap (sequence &obj) |
void | push_front (const value_type &val) |
Adds an element to the front of the sequence. More... | |
void | push_back (const value_type &val) |
Adds an element to the end of the sequence. More... | |
void | pop_front () |
Removes element from the front of the sequence. More... | |
void | pop_back () |
Removes element from the back of the sequence. More... | |
Miscellaneous | |
void | set_prefetch_aggr (int_type blocks2prefetch) |
Defines the number of blocks to prefetch (front side). This method should be called whenever the prefetch pool is resized. More... | |
unsigned_type | get_prefetch_aggr () const |
Returns the number of blocks prefetched from the front side. More... | |
stream | get_stream () |
construct a forward stream from this sequence More... | |
reverse_stream | get_reverse_stream () |
construct a reverse stream from this sequence More... | |
Capacity | |
size_type | size () const |
Returns the size of the sequence. More... | |
bool | empty () const |
Returns true if sequence is empty. More... | |
Operators | |
value_type & | back () |
Returns a mutable reference at the back of the sequence. More... | |
const value_type & | back () const |
Returns a const reference at the back of the sequence. More... | |
value_type & | front () |
Returns a mutable reference at the front of the sequence. More... | |
const value_type & | front () const |
Returns a const reference at the front of the sequence. More... | |
Private Types | |
typedef read_write_pool < block_type > | pool_type |
Private Member Functions | |
void | init (int blocks2prefetch=-1) |
Private Member Functions inherited from stxxl::noncopyable | |
noncopyable () | |
Private Attributes | |
unsigned_type | m_alloc_count |
block allocation counter More... | |
alloc_strategy_type | m_alloc_strategy |
block allocation strategy More... | |
block_type * | m_back_block |
current back block of sequence More... | |
value_type * | m_back_element |
pointer to current back element in m_back_block More... | |
bid_deque_type | m_bids |
allocated block identifiers More... | |
unsigned_type | m_blocks2prefetch |
number of blocks to prefetch More... | |
block_manager * | m_bm |
block manager used More... | |
block_type * | m_front_block |
current front block of sequence More... | |
value_type * | m_front_element |
pointer to current front element in m_front_block More... | |
bool | m_owns_pool |
whether the m_pool object is own and should be deleted. More... | |
pool_type * | m_pool |
read_write_pool of blocks More... | |
size_type | m_size |
current number of items in the sequence More... | |
typedef AllocStr stxxl::sequence< ValueType, BlockSize, AllocStr, SizeType >::alloc_strategy_type |
Definition at line 66 of file sequence.h.
typedef std::deque<bid_type> stxxl::sequence< ValueType, BlockSize, AllocStr, SizeType >::bid_deque_type |
Definition at line 75 of file sequence.h.
typedef BID<block_size> stxxl::sequence< ValueType, BlockSize, AllocStr, SizeType >::bid_type |
Definition at line 73 of file sequence.h.
typedef typed_block<block_size, value_type> stxxl::sequence< ValueType, BlockSize, AllocStr, SizeType >::block_type |
Definition at line 72 of file sequence.h.
|
private |
Definition at line 78 of file sequence.h.
typedef SizeType stxxl::sequence< ValueType, BlockSize, AllocStr, SizeType >::size_type |
Definition at line 67 of file sequence.h.
typedef ValueType stxxl::sequence< ValueType, BlockSize, AllocStr, SizeType >::value_type |
Definition at line 65 of file sequence.h.
anonymous enum |
Enumerator | |
---|---|
block_size |
Definition at line 68 of file sequence.h.
|
inlineexplicit |
Constructs empty sequence with own write and prefetch block pool.
D | number of parallel disks, defaulting to the configured number of scratch disks, memory consumption will be 2 * D + 2 blocks (first and last block, D blocks as write cache, D block for prefetching) |
Definition at line 125 of file sequence.h.
References STXXL_VERBOSE_SEQUENCE.
|
inlineexplicit |
Constructs empty sequence with own write and prefetch block pool.
w_pool_size | number of blocks in the write pool, must be at least 2, recommended at least 3 |
p_pool_size | number of blocks in the prefetch pool, recommended at least 1 |
blocks2prefetch | defines the number of blocks to prefetch (front side), default is number of block in the prefetch pool |
Definition at line 143 of file sequence.h.
References STXXL_VERBOSE_SEQUENCE.
|
inline |
Constructs empty sequence.
pool | block write/prefetch pool |
blocks2prefetch | defines the number of blocks to prefetch (front side), default is number of blocks in the prefetch pool |
Definition at line 160 of file sequence.h.
References STXXL_VERBOSE_SEQUENCE.
|
inline |
Definition at line 548 of file sequence.h.
|
inline |
Returns a mutable reference at the back of the sequence.
Definition at line 516 of file sequence.h.
|
inline |
Returns a const reference at the back of the sequence.
Definition at line 523 of file sequence.h.
|
inline |
Returns true
if sequence is empty.
Definition at line 505 of file sequence.h.
|
inline |
Returns a mutable reference at the front of the sequence.
Definition at line 530 of file sequence.h.
|
inline |
Returns a const reference at the front of the sequence.
Definition at line 537 of file sequence.h.
|
inline |
Returns the number of blocks prefetched from the front
side.
Definition at line 235 of file sequence.h.
|
inline |
construct a reverse stream from this sequence
Definition at line 819 of file sequence.h.
|
inline |
construct a forward stream from this sequence
Definition at line 688 of file sequence.h.
|
inlineprivate |
initialize empty sequence
Definition at line 195 of file sequence.h.
References STXXL_ERRMSG, and STXXL_MSG.
|
inline |
Removes element from the back of the sequence.
Definition at line 435 of file sequence.h.
References FMT_BID, STXXL_VERBOSE1, STXXL_VERBOSE_SEQUENCE, and UNLIKELY.
|
inline |
Removes element from the front of the sequence.
Definition at line 377 of file sequence.h.
References FMT_BID, STXXL_VERBOSE1, STXXL_VERBOSE_SEQUENCE, and UNLIKELY.
|
inline |
Adds an element to the end of the sequence.
Definition at line 316 of file sequence.h.
References FMT_BID, STXXL_VERBOSE1, STXXL_VERBOSE_SEQUENCE, and UNLIKELY.
|
inline |
Adds an element to the front of the sequence.
Definition at line 246 of file sequence.h.
References FMT_BID, STXXL_VERBOSE1, STXXL_VERBOSE_SEQUENCE, and UNLIKELY.
|
inline |
Defines the number of blocks to prefetch (front
side). This method should be called whenever the prefetch pool is resized.
blocks2prefetch | defines the number of blocks to prefetch (front side), a negative value means to use the number of blocks in the prefetch pool |
Definition at line 226 of file sequence.h.
|
inline |
Returns the size of the sequence.
Definition at line 499 of file sequence.h.
|
inline |
Definition at line 176 of file sequence.h.
References stxxl::sequence< ValueType, BlockSize, AllocStr, SizeType >::m_alloc_count, stxxl::sequence< ValueType, BlockSize, AllocStr, SizeType >::m_alloc_strategy, stxxl::sequence< ValueType, BlockSize, AllocStr, SizeType >::m_back_block, stxxl::sequence< ValueType, BlockSize, AllocStr, SizeType >::m_back_element, stxxl::sequence< ValueType, BlockSize, AllocStr, SizeType >::m_bids, stxxl::sequence< ValueType, BlockSize, AllocStr, SizeType >::m_blocks2prefetch, stxxl::sequence< ValueType, BlockSize, AllocStr, SizeType >::m_bm, stxxl::sequence< ValueType, BlockSize, AllocStr, SizeType >::m_front_block, stxxl::sequence< ValueType, BlockSize, AllocStr, SizeType >::m_front_element, stxxl::sequence< ValueType, BlockSize, AllocStr, SizeType >::m_owns_pool, stxxl::sequence< ValueType, BlockSize, AllocStr, SizeType >::m_pool, and stxxl::sequence< ValueType, BlockSize, AllocStr, SizeType >::m_size.
|
private |
block allocation counter
Definition at line 105 of file sequence.h.
Referenced by stxxl::sequence< ValueType, BlockSize, AllocStr, SizeType >::swap().
|
private |
block allocation strategy
Definition at line 102 of file sequence.h.
Referenced by stxxl::sequence< ValueType, BlockSize, AllocStr, SizeType >::swap().
|
private |
current back block of sequence
Definition at line 93 of file sequence.h.
Referenced by stxxl::sequence< ValueType, BlockSize, AllocStr, SizeType >::reverse_stream::reverse_stream(), and stxxl::sequence< ValueType, BlockSize, AllocStr, SizeType >::swap().
|
private |
pointer to current back element in m_back_block
Definition at line 99 of file sequence.h.
Referenced by stxxl::sequence< ValueType, BlockSize, AllocStr, SizeType >::reverse_stream::reverse_stream(), and stxxl::sequence< ValueType, BlockSize, AllocStr, SizeType >::swap().
|
private |
allocated block identifiers
Definition at line 108 of file sequence.h.
Referenced by stxxl::sequence< ValueType, BlockSize, AllocStr, SizeType >::reverse_stream::reverse_stream(), stxxl::sequence< ValueType, BlockSize, AllocStr, SizeType >::stream::stream(), and stxxl::sequence< ValueType, BlockSize, AllocStr, SizeType >::swap().
|
private |
number of blocks to prefetch
Definition at line 114 of file sequence.h.
Referenced by stxxl::sequence< ValueType, BlockSize, AllocStr, SizeType >::swap().
|
private |
block manager used
Definition at line 111 of file sequence.h.
Referenced by stxxl::sequence< ValueType, BlockSize, AllocStr, SizeType >::swap().
|
private |
current front block of sequence
Definition at line 90 of file sequence.h.
Referenced by stxxl::sequence< ValueType, BlockSize, AllocStr, SizeType >::stream::stream(), and stxxl::sequence< ValueType, BlockSize, AllocStr, SizeType >::swap().
|
private |
pointer to current front element in m_front_block
Definition at line 96 of file sequence.h.
Referenced by stxxl::sequence< ValueType, BlockSize, AllocStr, SizeType >::stream::stream(), and stxxl::sequence< ValueType, BlockSize, AllocStr, SizeType >::swap().
|
private |
whether the m_pool object is own and should be deleted.
Definition at line 84 of file sequence.h.
Referenced by stxxl::sequence< ValueType, BlockSize, AllocStr, SizeType >::swap().
|
private |
read_write_pool of blocks
Definition at line 87 of file sequence.h.
Referenced by stxxl::sequence< ValueType, BlockSize, AllocStr, SizeType >::swap().
|
private |
current number of items in the sequence
Definition at line 81 of file sequence.h.
Referenced by stxxl::sequence< ValueType, BlockSize, AllocStr, SizeType >::swap().