TPIE

2362a60
tpie::ami::Internal_Sorter_Base< T > Class Template Reference

The base class for internal sorters. More...

#include <tpie/internal_sort.h>

Inherited by tpie::ami::Internal_Sorter_Obj< T, Compare >.

Public Member Functions

 Internal_Sorter_Base (void)
 Constructor. More...
 
void allocate (TPIE_OS_SIZE_T nItems)
 Allocate ItemArray as array that can hold nItems. More...
 
void deallocate (void)
 Clean up internal array ItemArray. More...
 
TPIE_OS_SIZE_T MaxItemCount (TPIE_OS_SIZE_T memSize)
 Returns maximum number of items that can be sorted using memSize bytes. More...
 
TPIE_OS_SIZE_T space_per_item ()
 Returns memory usage in bytes per sort item. More...
 
TPIE_OS_SIZE_T space_overhead ()
 Returns fixed memory usage overhead in bytes per class instantiation. More...
 

Protected Attributes

array< T > ItemArray
 Array that holds items to be sorted. More...
 
TPIE_OS_SIZE_T len
 length of ItemArray More...
 

Detailed Description

template<class T>
class tpie::ami::Internal_Sorter_Base< T >

The base class for internal sorters.

This class does not have a sort() function, so it cannot be used directly.

Template Parameters
TThe type of elements to sort.

Definition at line 79 of file internal_sort.h.

Constructor & Destructor Documentation

template<class T>
tpie::ami::Internal_Sorter_Base< T >::Internal_Sorter_Base ( void  )
inline

Constructor.

Definition at line 90 of file internal_sort.h.

90  : len(0) {
91  // No code in this constructor.
92  };
TPIE_OS_SIZE_T len
length of ItemArray
Definition: internal_sort.h:84

Member Function Documentation

template<class T >
void tpie::ami::Internal_Sorter_Base< T >::allocate ( TPIE_OS_SIZE_T  nItems)
inline

Allocate ItemArray as array that can hold nItems.

Definition at line 128 of file internal_sort.h.

128  {
129  len=nitems;
131 }
array< T > ItemArray
Array that holds items to be sorted.
Definition: internal_sort.h:82
void resize(size_t size, const T &elm)
Change the size of the array.
Definition: array.h:485
TPIE_OS_SIZE_T len
length of ItemArray
Definition: internal_sort.h:84
template<class T >
void tpie::ami::Internal_Sorter_Base< T >::deallocate ( void  )
inline

Clean up internal array ItemArray.

Definition at line 134 of file internal_sort.h.

134  {
135  ItemArray.resize(0);
136  len=0;
137 }
array< T > ItemArray
Array that holds items to be sorted.
Definition: internal_sort.h:82
void resize(size_t size, const T &elm)
Change the size of the array.
Definition: array.h:485
TPIE_OS_SIZE_T len
length of ItemArray
Definition: internal_sort.h:84
template<class T >
TPIE_OS_SIZE_T tpie::ami::Internal_Sorter_Base< T >::MaxItemCount ( TPIE_OS_SIZE_T  memSize)
inline

Returns maximum number of items that can be sorted using memSize bytes.

Definition at line 140 of file internal_sort.h.

140  {
141  //Space available for items
142  TPIE_OS_SIZE_T memAvail=memSize-space_overhead();
143 
144  if (memAvail < space_per_item()) return 0;
145  return memAvail/space_per_item();
146 }
TPIE_OS_SIZE_T space_overhead()
Returns fixed memory usage overhead in bytes per class instantiation.
TPIE_OS_SIZE_T space_per_item()
Returns memory usage in bytes per sort item.
template<class T >
TPIE_OS_SIZE_T tpie::ami::Internal_Sorter_Base< T >::space_overhead ( void  )
inline

Returns fixed memory usage overhead in bytes per class instantiation.

Definition at line 150 of file internal_sort.h.

150  {
151  // Space usage independent of space_per_item
152  // accounts MM_manager space overhead on "new" call
153  return 0;
154 }
template<class T >
TPIE_OS_SIZE_T tpie::ami::Internal_Sorter_Base< T >::space_per_item ( void  )
inline

Returns memory usage in bytes per sort item.

Definition at line 157 of file internal_sort.h.

157  {
158  return sizeof(T);
159 }

Member Data Documentation

template<class T>
array<T> tpie::ami::Internal_Sorter_Base< T >::ItemArray
protected

Array that holds items to be sorted.

Definition at line 82 of file internal_sort.h.

template<class T>
TPIE_OS_SIZE_T tpie::ami::Internal_Sorter_Base< T >::len
protected

length of ItemArray

Definition at line 84 of file internal_sort.h.


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