#include <buffer.h>
Inheritance diagram for ABA_BUFFER< Type >:
Public Member Functions | |
ABA_BUFFER (ABA_GLOBAL *glob, int size) | |
ABA_BUFFER (const ABA_BUFFER< Type > &rhs) | |
~ABA_BUFFER () | |
The destructor. | |
const ABA_BUFFER< Type > & | operator= (const ABA_BUFFER< Type > &rhs) |
Type & | operator[] (int i) |
const Type & | operator[] (int i) const |
int | size () const |
int | number () const |
bool | full () const |
bool | empty () const |
void | push (Type item) |
Type | pop () |
void | clear () |
void | leftShift (ABA_BUFFER< int > &ind) |
Removes the components listed in the buffer ind by shifting the remaining components to the left. | |
void | 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. | |
Private Attributes | |
ABA_GLOBAL * | glob_ |
int | size_ |
int | n_ |
Type * | buf_ |
Friends | |
ostream & | operator<< (ostream &out, const ABA_BUFFER< Type > &buffer) |
The output operator writes all buffered elements line by line to an output stream in the format { number\/}{ : }{ value\/}. |
Definition at line 61 of file buffer.h.
ABA_BUFFER< Type >::ABA_BUFFER | ( | ABA_GLOBAL * | glob, | |
int | size | |||
) |
The constructor generates an empty buffer.
glob | The corresponding global object. | |
size | The size of the buffer. |
ABA_BUFFER< Type >::ABA_BUFFER | ( | const ABA_BUFFER< Type > & | rhs | ) |
The copy constructor.
rhs | The buffer being copied. |
ABA_BUFFER< Type >::~ABA_BUFFER | ( | ) |
The destructor.
const ABA_BUFFER<Type>& ABA_BUFFER< Type >::operator= | ( | const ABA_BUFFER< Type > & | rhs | ) |
The assignment operator is only allowed between buffers having equal size.
rhs | The buffer being assigned. |
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.
i | The number of the component which should be returned. |
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.
int ABA_BUFFER< Type >::size | ( | ) | const |
int ABA_BUFFER< Type >::number | ( | ) | const |
bool ABA_BUFFER< Type >::full | ( | ) | const |
false otherwise.
bool ABA_BUFFER< Type >::empty | ( | ) | const |
false otherwise.
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.
item | The item that should be inserted into the buffer. |
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.
void ABA_BUFFER< Type >::clear | ( | ) |
Sets the number of buffered items to 0 such that the buffer is empty.
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.
ind | The numbers of the components being removed. |
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.
newSize | The new length of the buffer. |
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\/}.
out | The output stream. | |
buffer | The buffer being output. |
ABA_GLOBAL* ABA_BUFFER< Type >::glob_ [private] |
int ABA_BUFFER< Type >::size_ [private] |
int ABA_BUFFER< Type >::n_ [private] |
Type* ABA_BUFFER< Type >::buf_ [private] |