6.55 ABA_BUFFER< Type > Class Template Reference

class implements a buffer by an array and storing the number of already buffered elements.

#include <buffer.h>

Inheritance diagram for ABA_BUFFER< Type >::


PIC


Public Member Functions

Private Attributes

Friends

6.55.1 Detailed Description

template<class Type> class ABA_BUFFER< Type >

class implements a buffer by an array and storing the number of already buffered elements.

Definition at line 61 of file buffer.h.

6.55.2 Constructor & Destructor Documentation

6.55.2.1 template<class Type> ABA_BUFFER< Type >::ABA_BUFFER (ABA_GLOBAL * glob, int size)

The constructor generates an empty buffer.

Parameters:

glob
The corresponding global object.
size
The size of the buffer.

6.55.2.2 template<class Type> ABA_BUFFER< Type >::ABA_BUFFER (const ABA_BUFFER< Type > & rhs)

The copy constructor.

Parameters:

rhs
The buffer being copied.

6.55.2.3 template<class Type> ABA_BUFFER< Type >::~ABA_BUFFER ()

The destructor.

6.55.3 Member Function Documentation

6.55.3.1 template<class Type> const ABA_BUFFER<Type>& ABA_BUFFER< Type >::operator= (const ABA_BUFFER< Type > & rhs)

The assignment operator is only allowed between buffers having equal size.

Returns:

A reference to the buffer on the left hand side of the assignment operator.

Parameters:

rhs
The buffer being assigned.

6.55.3.2 ]

template<class Type> Type& ABA_BUFFER< Type >::operator[ ] (int i)

The operator [] can be used to access an element of the buffer.

It is only allowed to access buffered elements. Otherwise, if the function is compiled with -DABACUSSAFE the program stops with an error message.

Returns:

The i-th element of the buffer.

Parameters:

i
The number of the component which should be returned.

6.55.3.3 ]

template<class Type> const Type& ABA_BUFFER< Type >::operator[ ] (int i) const

The operator [] is overloaded that it can be also used to access elements of constant buffers.

6.55.3.4 template<class Type> int ABA_BUFFER< Type >::size () const

Returns:

The maximal number of elements which can be stored in the buffer.

6.55.3.5 template<class Type> int ABA_BUFFER< Type >::number () const

Returns:

The number of buffered elements.

6.55.3.6 template<class Type> bool ABA_BUFFER< Type >::full () const

Returns:

true If no more elements can be inserted into the buffer,

false otherwise.

6.55.3.7 template<class Type> bool ABA_BUFFER< Type >::empty () const

Returns:

true If no items are buffered,

false otherwise.

6.55.3.8 template<class Type> void ABA_BUFFER< Type >::push (Type item)

Inserts an item into the buffer.

It is a fatal error to perform this operation if the buffer is full.

In this case the program stops with an error message if this function is compiled with -DABACUSSAFE.

Parameters:

item
The item that should be inserted into the buffer.

6.55.3.9 template<class Type> Type ABA_BUFFER< Type >::pop ()

Removes and returns the last inserted item from the buffer.

It is a fatal error to perform this operation on an empty buffer.

In this case the program stops with an error message if this function is compiled with -DABACUSSAFE.

Returns:

The last item that has been inserted into the buffer.

6.55.3.10 template<class Type> void ABA_BUFFER< Type >::clear ()

Sets the number of buffered items to 0 such that the buffer is empty.

6.55.3.11 template<class Type> void ABA_BUFFER< Type >::leftShift (ABA_BUFFER< int > & ind)

Removes the components listed in the buffer ind by shifting the remaining components to the left.

The values stored in ind have to be upward sorted. Memory management of the removed components must be carefully implemented by the user of this function to avoid memory leaks.

If this function is compiled with -DABACUSSAFE then it is checked if each value of ind is in the range 0„ number()-1.

Parameters:

ind
The numbers of the components being removed.

6.55.3.12 template<class Type> void ABA_BUFFER< Type >::realloc (int newSize)

The length of a buffer can be changed with the function realloc(). If the size of the buffer is increased all buffered elements are copied. If the size is decreased the number of buffered elements is updated if necessary.

Parameters:

newSize
The new length of the buffer.

6.55.4 Friends And Related Function Documentation

6.55.4.1 template<class Type> ostream& operator<< (ostream & out, const ABA_BUFFER< Type > & buffer) [friend]

The output operator writes all buffered elements line by line to an output stream in the format { number\/}{ : }{ value\/}.

Returns:

A reference to the stream the buffer is written to.

Parameters:

out
The output stream.
buffer
The buffer being output.

6.55.5 Member Data Documentation

6.55.5.1 template<class Type> ABA_GLOBAL*ABA_BUFFER< Type >::glob_ [private]

A pointer to the corresponding global object.

Definition at line 219 of file buffer.h.

6.55.5.2 template<class Type> int ABA_BUFFER< Type >::size_ [private]

The maximal number of elements which can be stored in the buffer.

Definition at line 223 of file buffer.h.

6.55.5.3 template<class Type> int ABA_BUFFER< Type >::n_ [private]

The number of buffered elements.

Definition at line 227 of file buffer.h.

6.55.5.4 template<class Type> Type*ABA_BUFFER< Type >::buf_ [private]

The /-style array storing the buffered elements.

Definition at line 231 of file buffer.h.

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