TRF Language Model
wb::Vector< T > Class Template Reference

this is the basic class of Array/Stack/Queue. Realize the dynamic memory management More...

#include <wb-vector.h>

Inheritance diagram for wb::Vector< T >:
wb::Array< T > wb::CirQueue< T > wb::DArray< T > wb::Queue< T > wb::Stack< T >

Public Member Functions

 Vector (int size=DEFAULE_VECTOR_SIZE)
 constructor, do not init the memeory to zero. More...
 
 ~Vector ()
 desturctor More...
 
int Size () const
 get the memory size More...
 
T * GetBuffer (int i=0) const
 get the buffer pointer More...
 
T & Get (int i)
 get the value at position i More...
 
int Size2Bits (int size)
 Transform the size to bit. More...
 
void Fill (T m)
 set all the values to m More...
 
void Zero ()
 Fill all the memory to ZERO. call 'memset'. More...
 
void Copy (const Vector< T > &vector)
 Copy a vector to another, using '=' to set values. More...
 
void MemCopy (Vector< T > &vector)
 Copy a vector to another, using 'memcpy' to set values. More...
 
void BufferOutside (T *&p_pt)
 Set the buffer pointer to p_pt, and re-init the vector. More...
 

Protected Attributes

T * m_pBuffer
 buffer pointer More...
 
int m_nBits
 bit number of memory size More...
 

Detailed Description

template<typename T>
class wb::Vector< T >

this is the basic class of Array/Stack/Queue. Realize the dynamic memory management

Date
2016-04-28
Author
Wangbin If the size is full, then we re-new a new memory with double current memory size.

Definition at line 73 of file wb-vector.h.

Constructor & Destructor Documentation

§ Vector()

template<typename T>
wb::Vector< T >::Vector ( int  size = DEFAULE_VECTOR_SIZE)
inline

constructor, do not init the memeory to zero.

Definition at line 80 of file wb-vector.h.

§ ~Vector()

template<typename T>
wb::Vector< T >::~Vector ( )
inline

desturctor

Definition at line 87 of file wb-vector.h.

Member Function Documentation

§ BufferOutside()

template<typename T>
void wb::Vector< T >::BufferOutside ( T *&  p_pt)
inline

Set the buffer pointer to p_pt, and re-init the vector.

Definition at line 186 of file wb-vector.h.

§ Copy()

template<typename T>
void wb::Vector< T >::Copy ( const Vector< T > &  vector)
inline

Copy a vector to another, using '=' to set values.

Definition at line 155 of file wb-vector.h.

§ Fill()

template<typename T>
void wb::Vector< T >::Fill ( m)
inline

set all the values to m

using '=' to set values. This may avoid the error caused by 'memcopy'

Definition at line 139 of file wb-vector.h.

§ Get()

template<typename T>
T& wb::Vector< T >::Get ( int  i)
inline

get the value at position i

Definition at line 99 of file wb-vector.h.

§ GetBuffer()

template<typename T>
T* wb::Vector< T >::GetBuffer ( int  i = 0) const
inline

get the buffer pointer

Definition at line 97 of file wb-vector.h.

§ MemCopy()

template<typename T>
void wb::Vector< T >::MemCopy ( Vector< T > &  vector)
inline

Copy a vector to another, using 'memcpy' to set values.

Definition at line 171 of file wb-vector.h.

§ Size()

template<typename T>
int wb::Vector< T >::Size ( ) const
inline

get the memory size

Definition at line 95 of file wb-vector.h.

§ Size2Bits()

template<typename T>
int wb::Vector< T >::Size2Bits ( int  size)
inline

Transform the size to bit.

Definition at line 128 of file wb-vector.h.

§ Zero()

template<typename T>
void wb::Vector< T >::Zero ( )
inline

Fill all the memory to ZERO. call 'memset'.

Definition at line 145 of file wb-vector.h.

Member Data Documentation

§ m_nBits

template<typename T>
int wb::Vector< T >::m_nBits
protected

bit number of memory size

Definition at line 77 of file wb-vector.h.

§ m_pBuffer

template<typename T>
T* wb::Vector< T >::m_pBuffer
protected

buffer pointer

Definition at line 76 of file wb-vector.h.


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