TPIE

v1.1rc1-6-g0c97303
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 78 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 89 of file internal_sort.h.

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

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 127 of file internal_sort.h.

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

Clean up internal array ItemArray.

Definition at line 133 of file internal_sort.h.

133  {
134  ItemArray.resize(0);
135  len=0;
136 }
array< T > ItemArray
Array that holds items to be sorted.
Definition: internal_sort.h:81
void resize(size_t size, const T &elm)
Change the size of the array.
Definition: array.h:431
TPIE_OS_SIZE_T len
length of ItemArray
Definition: internal_sort.h:83
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 139 of file internal_sort.h.

139  {
140  //Space available for items
141  TPIE_OS_SIZE_T memAvail=memSize-space_overhead();
142 
143  if (memAvail < space_per_item()) return 0;
144  return memAvail/space_per_item();
145 }
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 149 of file internal_sort.h.

149  {
150  // Space usage independent of space_per_item
151  // accounts MM_manager space overhead on "new" call
152  return 0;
153 }
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 156 of file internal_sort.h.

156  {
157  return sizeof(T);
158 }

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 81 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 83 of file internal_sort.h.


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