Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members

PLearn::Storage< T > Class Template Reference

#include <Storage.h>

Inheritance diagram for PLearn::Storage< T >:

Inheritance graph
[legend]
Collaboration diagram for PLearn::Storage< T >:

Collaboration graph
[legend]
List of all members.

Public Types

typedef T value_type
typedef int size_type
typedef T * iterator
typedef const T * const_iterator

Public Member Functions

 Storage (const Storage &other)
 Storage (int the_length, T *dataptr)
int length () const
int size () const
iterator begin () const
iterator end () const
void mem_alloc (int len)
 Storage (int the_length=0)
 data is initially filled with zeros

 Storage (const char *filename, bool readonly)
void pointTo (int the_length, T *dataptr)
 ~Storage ()
void resize (int newlength)
Storage< T > * deepCopy (map< const void *, void * > &copies) const
 Deep copying.

T & operator[] (int idx) const
void push_back (const T &x)

Public Attributes

int length_
T * data
bool dont_delete_data
 if true, the destructor won't delete[] data, because it will assume it is somebody else's responsibility

tFileHandle fd
 The descriptor for the memory-mapped file (-1 if there is no memory mapping).

template<class T>
class PLearn::Storage< T >


Member Typedef Documentation

template<class T>
typedef const T* PLearn::Storage< T >::const_iterator
 

Definition at line 69 of file Storage.h.

template<class T>
typedef T* PLearn::Storage< T >::iterator
 

Definition at line 68 of file Storage.h.

template<class T>
typedef int PLearn::Storage< T >::size_type
 

Definition at line 67 of file Storage.h.

template<class T>
typedef T PLearn::Storage< T >::value_type
 

Definition at line 66 of file Storage.h.


Constructor & Destructor Documentation

template<class T>
PLearn::Storage< T >::Storage const Storage< T > &  other  )  [inline]
 

Definition at line 77 of file Storage.h.

template<class T>
PLearn::Storage< T >::Storage int  the_length,
T *  dataptr
[inline]
 

Definition at line 94 of file Storage.h.

template<class T>
PLearn::Storage< T >::Storage int  the_length = 0  )  [inline]
 

data is initially filled with zeros

Definition at line 124 of file Storage.h.

template<class T>
PLearn::Storage< T >::Storage const char *  filename,
bool  readonly
[inline]
 

Constructor for memory-mapped file The file is supposed to exist and have the correct size length() of the storage will be set to the size of the file divided by sizeof(T)

< read-write

Definition at line 143 of file Storage.h.

template<class T>
PLearn::Storage< T >::~Storage  )  [inline]
 

Definition at line 199 of file Storage.h.


Member Function Documentation

template<class T>
iterator PLearn::Storage< T >::begin  )  const [inline]
 

Definition at line 106 of file Storage.h.

template<class T>
Storage<T>* PLearn::Storage< T >::deepCopy map< const void *, void * > &  copies  )  const [inline]
 

Deep copying.

< a copy already exists, so return it

Otherwise call the copy constructor to obtain a copy

Put the copy in the map

return the completed deep_copy

Definition at line 296 of file Storage.h.

template<class T>
iterator PLearn::Storage< T >::end  )  const [inline]
 

Definition at line 109 of file Storage.h.

template<class T>
int PLearn::Storage< T >::length  )  const [inline]
 

Definition at line 100 of file Storage.h.

Referenced by PLearn::Storage< pair< real, real > >::mem_alloc(), PLearn::Storage< pair< real, real > >::pointTo(), PLearn::Storage< pair< real, real > >::resize(), PLearn::Storage< pair< real, real > >::Storage(), and PLearn::Storage< pair< real, real > >::~Storage().

template<class T>
void PLearn::Storage< T >::mem_alloc int  len  )  [inline]
 

Definition at line 114 of file Storage.h.

template<class T>
T& PLearn::Storage< T >::operator[] int  idx  )  const [inline]
 

Definition at line 314 of file Storage.h.

template<class T>
void PLearn::Storage< T >::pointTo int  the_length,
T *  dataptr
[inline]
 

< allocated elsewhere

Definition at line 177 of file Storage.h.

template<class T>
void PLearn::Storage< T >::push_back const T &  x  )  [inline]
 

Definition at line 316 of file Storage.h.

template<class T>
void PLearn::Storage< T >::resize int  newlength  )  [inline]
 

Grow or shrink data memory If newlength==length() this call does nothing If newlength<=0 it outputs an PLERROR(i.e. cannot shrink memory to 0) Otherwise this call ALWAYS: -> allocates a new block of exactly the given size -> copies all the possible the data of the old block to the new one -> fills the remaining of the new block (if any) with 0.0 -> frees the old block It is the job of the CALLER (Mat and Vec) to have an appropriate policy to minimize the number of calls to Storage::resize

< we are using a memory-mapped file

< growing

< newlength<length() (shrinking)

Definition at line 228 of file Storage.h.

template<class T>
int PLearn::Storage< T >::size  )  const [inline]
 

Definition at line 103 of file Storage.h.

Referenced by PLearn::Storage< pair< real, real > >::deepCopy(), and PLearn::Storage< pair< real, real > >::push_back().


Member Data Documentation

template<class T>
T* PLearn::Storage< T >::data
 

Definition at line 73 of file Storage.h.

Referenced by PLearn::Storage< pair< real, real > >::deepCopy(), and PLearn::Storage< pair< real, real > >::Storage().

template<class T>
bool PLearn::Storage< T >::dont_delete_data
 

if true, the destructor won't delete[] data, because it will assume it is somebody else's responsibility

Definition at line 74 of file Storage.h.

template<class T>
tFileHandle PLearn::Storage< T >::fd
 

The descriptor for the memory-mapped file (-1 if there is no memory mapping).

Definition at line 75 of file Storage.h.

template<class T>
int PLearn::Storage< T >::length_
 

Definition at line 72 of file Storage.h.


The documentation for this class was generated from the following file:
Generated on Tue Aug 17 16:22:44 2004 for PLearn by doxygen 1.3.7