Stxxl  1.4.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Public Types | Public Member Functions | Private Member Functions | Private Attributes
stxxl::stream::basic_runs_merger< RunsType_, CompareType_, AllocStr_ > Class Template Reference

Merges sorted runs. More...

#include <sort_stream.h>

Inheritance diagram for stxxl::stream::basic_runs_merger< RunsType_, CompareType_, AllocStr_ >:
Inheritance graph
[legend]
Collaboration diagram for stxxl::stream::basic_runs_merger< RunsType_, CompareType_, AllocStr_ >:
Collaboration graph
[legend]

List of all members.

Public Types

typedef RunsType_ sorted_runs_type
typedef CompareType_ value_cmp
typedef AllocStr_ alloc_strategy
typedef
sorted_runs_type::element_type 
sorted_runs_data_type
typedef
sorted_runs_data_type::size_type 
size_type
typedef
sorted_runs_data_type::run_type 
run_type
typedef
sorted_runs_data_type::block_type 
block_type
typedef block_type out_block_type
typedef run_type::value_type trigger_entry_type
typedef block_prefetcher
< block_type, typename
run_type::iterator > 
prefetcher_type
typedef run_cursor2
< block_type, prefetcher_type
run_cursor_type
typedef
sort_helper::run_cursor2_cmp
< block_type, prefetcher_type,
value_cmp
run_cursor2_cmp_type
typedef loser_tree
< run_cursor_type,
run_cursor2_cmp_type
loser_tree_type
typedef stxxl::int64 diff_type
typedef std::pair< typename
block_type::iterator, typename
block_type::iterator
sequence
typedef std::vector< sequence >
::size_type 
seqs_size_type
typedef
sorted_runs_data_type::value_type 
value_type
 Standard stream typedef.

Public Member Functions

 basic_runs_merger (value_cmp c, unsigned_type memory_to_use)
 Creates a runs merger object.
void set_memory_to_use (unsigned_type memory_to_use)
 Set memory amount to use for the merger in bytes.
void initialize (const sorted_runs_type &sruns)
 Initialize the runs merger object with a new round of sorted_runs.
void deallocate ()
 Deallocate temporary structures freeing memory prior to next initialize()
bool empty () const
 Standard stream method.
size_type size () const
 Standard size method.
const value_typeoperator* () const
 Standard stream method.
const value_typeoperator-> () const
 Standard stream method.
basic_runs_mergeroperator++ ()
 Standard stream method.
virtual ~basic_runs_merger ()
 Destructor.

Private Member Functions

void merge_recursively ()
void deallocate_prefetcher ()
void fill_buffer_block ()

Private Attributes

value_cmp m_cmp
 comparator object to sort runs
unsigned_type m_memory_to_use
 memory size in bytes to use
sorted_runs_type m_sruns
 smart pointer to sorted_runs object
size_type m_elements_remaining
 items remaining in input
out_block_typem_buffer_block
 memory buffer for merging from external streams
const value_typem_current_ptr
 pointer into current memory buffer: this is either m_buffer_block or the small_runs vector
const value_typem_current_end
 pointer into current memory buffer: end after range of current values
run_type m_consume_seq
 sequence of block needed for merging
int_typem_prefetch_seq
 precalculated order of blocks in which they are prefetched
prefetcher_typem_prefetcher
 prefetcher object
loser_tree_typem_losers
 loser tree used for native merging

Detailed Description

template<class RunsType_, class CompareType_, class AllocStr_ = STXXL_DEFAULT_ALLOC_STRATEGY>
class stxxl::stream::basic_runs_merger< RunsType_, CompareType_, AllocStr_ >

Merges sorted runs.

Template Parameters:
RunsType_type of the sorted runs, available as runs_creator::sorted_runs_type ,
CompareType_type of comparison object used for merging
AllocStr_allocation strategy used to allocate the blocks for storing intermediate results if several merge passes are required

Definition at line 914 of file sort_stream.h.


Member Typedef Documentation

template<class RunsType_, class CompareType_, class AllocStr_ = STXXL_DEFAULT_ALLOC_STRATEGY>
typedef AllocStr_ stxxl::stream::basic_runs_merger< RunsType_, CompareType_, AllocStr_ >::alloc_strategy

Definition at line 919 of file sort_stream.h.

template<class RunsType_, class CompareType_, class AllocStr_ = STXXL_DEFAULT_ALLOC_STRATEGY>
typedef sorted_runs_data_type::block_type stxxl::stream::basic_runs_merger< RunsType_, CompareType_, AllocStr_ >::block_type
template<class RunsType_, class CompareType_, class AllocStr_ = STXXL_DEFAULT_ALLOC_STRATEGY>
typedef stxxl::int64 stxxl::stream::basic_runs_merger< RunsType_, CompareType_, AllocStr_ >::diff_type

Definition at line 931 of file sort_stream.h.

template<class RunsType_, class CompareType_, class AllocStr_ = STXXL_DEFAULT_ALLOC_STRATEGY>
typedef loser_tree<run_cursor_type, run_cursor2_cmp_type> stxxl::stream::basic_runs_merger< RunsType_, CompareType_, AllocStr_ >::loser_tree_type

Definition at line 930 of file sort_stream.h.

template<class RunsType_, class CompareType_, class AllocStr_ = STXXL_DEFAULT_ALLOC_STRATEGY>
typedef block_type stxxl::stream::basic_runs_merger< RunsType_, CompareType_, AllocStr_ >::out_block_type

Definition at line 925 of file sort_stream.h.

template<class RunsType_, class CompareType_, class AllocStr_ = STXXL_DEFAULT_ALLOC_STRATEGY>
typedef block_prefetcher<block_type, typename run_type::iterator> stxxl::stream::basic_runs_merger< RunsType_, CompareType_, AllocStr_ >::prefetcher_type

Definition at line 927 of file sort_stream.h.

template<class RunsType_, class CompareType_, class AllocStr_ = STXXL_DEFAULT_ALLOC_STRATEGY>
typedef sort_helper::run_cursor2_cmp<block_type, prefetcher_type, value_cmp> stxxl::stream::basic_runs_merger< RunsType_, CompareType_, AllocStr_ >::run_cursor2_cmp_type

Definition at line 929 of file sort_stream.h.

template<class RunsType_, class CompareType_, class AllocStr_ = STXXL_DEFAULT_ALLOC_STRATEGY>
typedef run_cursor2<block_type, prefetcher_type> stxxl::stream::basic_runs_merger< RunsType_, CompareType_, AllocStr_ >::run_cursor_type

Definition at line 928 of file sort_stream.h.

template<class RunsType_, class CompareType_, class AllocStr_ = STXXL_DEFAULT_ALLOC_STRATEGY>
typedef sorted_runs_data_type::run_type stxxl::stream::basic_runs_merger< RunsType_, CompareType_, AllocStr_ >::run_type

Definition at line 923 of file sort_stream.h.

template<class RunsType_, class CompareType_, class AllocStr_ = STXXL_DEFAULT_ALLOC_STRATEGY>
typedef std::vector<sequence>::size_type stxxl::stream::basic_runs_merger< RunsType_, CompareType_, AllocStr_ >::seqs_size_type

Definition at line 933 of file sort_stream.h.

template<class RunsType_, class CompareType_, class AllocStr_ = STXXL_DEFAULT_ALLOC_STRATEGY>
typedef std::pair<typename block_type::iterator, typename block_type::iterator> stxxl::stream::basic_runs_merger< RunsType_, CompareType_, AllocStr_ >::sequence

Definition at line 932 of file sort_stream.h.

template<class RunsType_, class CompareType_, class AllocStr_ = STXXL_DEFAULT_ALLOC_STRATEGY>
typedef sorted_runs_data_type::size_type stxxl::stream::basic_runs_merger< RunsType_, CompareType_, AllocStr_ >::size_type

Definition at line 922 of file sort_stream.h.

template<class RunsType_, class CompareType_, class AllocStr_ = STXXL_DEFAULT_ALLOC_STRATEGY>
typedef sorted_runs_type::element_type stxxl::stream::basic_runs_merger< RunsType_, CompareType_, AllocStr_ >::sorted_runs_data_type

Definition at line 921 of file sort_stream.h.

template<class RunsType_, class CompareType_, class AllocStr_ = STXXL_DEFAULT_ALLOC_STRATEGY>
typedef RunsType_ stxxl::stream::basic_runs_merger< RunsType_, CompareType_, AllocStr_ >::sorted_runs_type
template<class RunsType_, class CompareType_, class AllocStr_ = STXXL_DEFAULT_ALLOC_STRATEGY>
typedef run_type::value_type stxxl::stream::basic_runs_merger< RunsType_, CompareType_, AllocStr_ >::trigger_entry_type

Definition at line 926 of file sort_stream.h.

template<class RunsType_, class CompareType_, class AllocStr_ = STXXL_DEFAULT_ALLOC_STRATEGY>
typedef CompareType_ stxxl::stream::basic_runs_merger< RunsType_, CompareType_, AllocStr_ >::value_cmp
template<class RunsType_, class CompareType_, class AllocStr_ = STXXL_DEFAULT_ALLOC_STRATEGY>
typedef sorted_runs_data_type::value_type stxxl::stream::basic_runs_merger< RunsType_, CompareType_, AllocStr_ >::value_type

Standard stream typedef.

Definition at line 937 of file sort_stream.h.


Constructor & Destructor Documentation

template<class RunsType_, class CompareType_, class AllocStr_ = STXXL_DEFAULT_ALLOC_STRATEGY>
stxxl::stream::basic_runs_merger< RunsType_, CompareType_, AllocStr_ >::basic_runs_merger ( value_cmp  c,
unsigned_type  memory_to_use 
) [inline]

Creates a runs merger object.

Parameters:
ccomparison object
memory_to_useamount of memory available for the merger in bytes

Definition at line 1079 of file sort_stream.h.

template<class RunsType_, class CompareType_, class AllocStr_ = STXXL_DEFAULT_ALLOC_STRATEGY>
virtual stxxl::stream::basic_runs_merger< RunsType_, CompareType_, AllocStr_ >::~basic_runs_merger ( ) [inline, virtual]

Destructor.

Remarks:
Deallocates blocks of the input sorted runs object

Definition at line 1302 of file sort_stream.h.


Member Function Documentation

template<class RunsType_, class CompareType_, class AllocStr_ = STXXL_DEFAULT_ALLOC_STRATEGY>
void stxxl::stream::basic_runs_merger< RunsType_, CompareType_, AllocStr_ >::deallocate ( ) [inline]

Deallocate temporary structures freeing memory prior to next initialize()

Definition at line 1239 of file sort_stream.h.

template<class RunsType_, class CompareType_, class AllocStr_ = STXXL_DEFAULT_ALLOC_STRATEGY>
void stxxl::stream::basic_runs_merger< RunsType_, CompareType_, AllocStr_ >::deallocate_prefetcher ( ) [inline, private]

Definition at line 988 of file sort_stream.h.

template<class RunsType_, class CompareType_, class AllocStr_ = STXXL_DEFAULT_ALLOC_STRATEGY>
bool stxxl::stream::basic_runs_merger< RunsType_, CompareType_, AllocStr_ >::empty ( ) const [inline]

Standard stream method.

Definition at line 1247 of file sort_stream.h.

Referenced by main(), and stxxl::stream::basic_runs_merger< RunsType_, CompareType_, AllocStr_ >::merge_recursively().

template<class RunsType_, class CompareType_, class AllocStr_ = STXXL_DEFAULT_ALLOC_STRATEGY>
void stxxl::stream::basic_runs_merger< RunsType_, CompareType_, AllocStr_ >::fill_buffer_block ( ) [inline, private]

Definition at line 1003 of file sort_stream.h.

template<class RunsType_, class CompareType_, class AllocStr_ = STXXL_DEFAULT_ALLOC_STRATEGY>
void stxxl::stream::basic_runs_merger< RunsType_, CompareType_, AllocStr_ >::initialize ( const sorted_runs_type sruns) [inline]

Initialize the runs merger object with a new round of sorted_runs.

Definition at line 1105 of file sort_stream.h.

Referenced by stxxl::stream::basic_runs_merger< RunsType_, CompareType_, AllocStr_ >::merge_recursively().

template<class RunsType_, class CompareType_, class AllocStr_ = STXXL_DEFAULT_ALLOC_STRATEGY>
const value_type& stxxl::stream::basic_runs_merger< RunsType_, CompareType_, AllocStr_ >::operator* ( ) const [inline]

Standard stream method.

Definition at line 1259 of file sort_stream.h.

template<class RunsType_, class CompareType_, class AllocStr_ = STXXL_DEFAULT_ALLOC_STRATEGY>
basic_runs_merger& stxxl::stream::basic_runs_merger< RunsType_, CompareType_, AllocStr_ >::operator++ ( ) [inline]

Standard stream method.

Definition at line 1272 of file sort_stream.h.

template<class RunsType_, class CompareType_, class AllocStr_ = STXXL_DEFAULT_ALLOC_STRATEGY>
const value_type* stxxl::stream::basic_runs_merger< RunsType_, CompareType_, AllocStr_ >::operator-> ( ) const [inline]

Standard stream method.

Definition at line 1266 of file sort_stream.h.

template<class RunsType_, class CompareType_, class AllocStr_ = STXXL_DEFAULT_ALLOC_STRATEGY>
void stxxl::stream::basic_runs_merger< RunsType_, CompareType_, AllocStr_ >::set_memory_to_use ( unsigned_type  memory_to_use) [inline]

Set memory amount to use for the merger in bytes.

Definition at line 1099 of file sort_stream.h.

template<class RunsType_, class CompareType_, class AllocStr_ = STXXL_DEFAULT_ALLOC_STRATEGY>
size_type stxxl::stream::basic_runs_merger< RunsType_, CompareType_, AllocStr_ >::size ( ) const [inline]

Standard size method.

Definition at line 1253 of file sort_stream.h.


Member Data Documentation

template<class RunsType_, class CompareType_, class AllocStr_ = STXXL_DEFAULT_ALLOC_STRATEGY>
out_block_type* stxxl::stream::basic_runs_merger< RunsType_, CompareType_, AllocStr_ >::m_buffer_block [private]

memory buffer for merging from external streams

Definition at line 953 of file sort_stream.h.

template<class RunsType_, class CompareType_, class AllocStr_ = STXXL_DEFAULT_ALLOC_STRATEGY>
value_cmp stxxl::stream::basic_runs_merger< RunsType_, CompareType_, AllocStr_ >::m_cmp [private]

comparator object to sort runs

Definition at line 941 of file sort_stream.h.

template<class RunsType_, class CompareType_, class AllocStr_ = STXXL_DEFAULT_ALLOC_STRATEGY>
run_type stxxl::stream::basic_runs_merger< RunsType_, CompareType_, AllocStr_ >::m_consume_seq [private]

sequence of block needed for merging

Definition at line 962 of file sort_stream.h.

template<class RunsType_, class CompareType_, class AllocStr_ = STXXL_DEFAULT_ALLOC_STRATEGY>
const value_type* stxxl::stream::basic_runs_merger< RunsType_, CompareType_, AllocStr_ >::m_current_end [private]

pointer into current memory buffer: end after range of current values

Definition at line 959 of file sort_stream.h.

template<class RunsType_, class CompareType_, class AllocStr_ = STXXL_DEFAULT_ALLOC_STRATEGY>
const value_type* stxxl::stream::basic_runs_merger< RunsType_, CompareType_, AllocStr_ >::m_current_ptr [private]

pointer into current memory buffer: this is either m_buffer_block or the small_runs vector

Definition at line 956 of file sort_stream.h.

template<class RunsType_, class CompareType_, class AllocStr_ = STXXL_DEFAULT_ALLOC_STRATEGY>
size_type stxxl::stream::basic_runs_merger< RunsType_, CompareType_, AllocStr_ >::m_elements_remaining [private]

items remaining in input

Definition at line 950 of file sort_stream.h.

template<class RunsType_, class CompareType_, class AllocStr_ = STXXL_DEFAULT_ALLOC_STRATEGY>
loser_tree_type* stxxl::stream::basic_runs_merger< RunsType_, CompareType_, AllocStr_ >::m_losers [private]

loser tree used for native merging

Definition at line 971 of file sort_stream.h.

template<class RunsType_, class CompareType_, class AllocStr_ = STXXL_DEFAULT_ALLOC_STRATEGY>
unsigned_type stxxl::stream::basic_runs_merger< RunsType_, CompareType_, AllocStr_ >::m_memory_to_use [private]

memory size in bytes to use

Definition at line 944 of file sort_stream.h.

template<class RunsType_, class CompareType_, class AllocStr_ = STXXL_DEFAULT_ALLOC_STRATEGY>
int_type* stxxl::stream::basic_runs_merger< RunsType_, CompareType_, AllocStr_ >::m_prefetch_seq [private]

precalculated order of blocks in which they are prefetched

Definition at line 965 of file sort_stream.h.

template<class RunsType_, class CompareType_, class AllocStr_ = STXXL_DEFAULT_ALLOC_STRATEGY>
prefetcher_type* stxxl::stream::basic_runs_merger< RunsType_, CompareType_, AllocStr_ >::m_prefetcher [private]

prefetcher object

Definition at line 968 of file sort_stream.h.

template<class RunsType_, class CompareType_, class AllocStr_ = STXXL_DEFAULT_ALLOC_STRATEGY>
sorted_runs_type stxxl::stream::basic_runs_merger< RunsType_, CompareType_, AllocStr_ >::m_sruns [private]

smart pointer to sorted_runs object

Definition at line 947 of file sort_stream.h.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines