An array that keeps track of the number of inserted elements; also usable as an efficient stack. More...
#include <ogdf/basic/ArrayBuffer.h>
Public Member Functions | |
| ArrayBuffer () | |
| Constructs an empty ArrayBuffer, without initial memory allocation. | |
| ArrayBuffer (INDEX size) | |
| Constructs an empty ArrayBuffer, allocating memory for up to size elements. | |
| void | init () |
| Reinitializes the array, clearing it, and without initial memory allocation. | |
| void | init (INDEX size) |
| Reinitializes the array, clearing it, and allocating memory for up to size elements. | |
| void | clear () |
| Clears the buffer. | |
| const E & | top () const |
| Returns the newest element of the buffer. | |
| E & | top () |
| Returns the newest element of the buffer. | |
| void | push (E e) |
| Puts a new element in the buffer. | |
| void | pop () |
| Removes the newest element from the buffer. | |
| E | popRet () |
| Removes the newest element from the buffer and returns it. | |
| bool | empty () const |
| Returns true if the buffer is empty, false otherwise. | |
| INDEX | size () const |
| Returns number of elements in the buffer. | |
| const E & | operator[] (INDEX i) const |
| Returns a reference to the element at position i. | |
| E & | operator[] (INDEX i) |
| Returns a reference to the element at position i. | |
| void | compactCopy (Array< E, INDEX > &A2) const |
| Generates a compact copy holding the current elements. | |
| void | compactCpycon (Array< E, INDEX > &A2) const |
| Generates a compact copy holding the current elements. | |
| void | compactMemcpy (Array< E, INDEX > &A2) const |
| Generates a compact copy holding the current elements. | |
| INDEX | linearSearch (const E &x) const |
| Performs a linear search for element x. | |
| template<class COMPARER > | |
| INDEX | linearSearch (const E &x, const COMPARER &comp) const |
| Performs a linear search for element x with comparer comp. | |
Private Attributes | |
| INDEX | num |
| The number of elements in te buffer. | |
An array that keeps track of the number of inserted elements; also usable as an efficient stack.
This is a growable array (with some initial size s) which starts out being empty. Using stack functions you can put elements into and out of it. The initial array size is automatically expanded if neccessary, but never automatically shrunken. You may also access the elements it contains using the []-operator. Tha valid indices are 0..(s - 1).
Definition at line 71 of file ArrayBuffer.h.
| ogdf::ArrayBuffer< E, INDEX >::ArrayBuffer | ( | ) | [inline] |
Constructs an empty ArrayBuffer, without initial memory allocation.
Definition at line 75 of file ArrayBuffer.h.
| ogdf::ArrayBuffer< E, INDEX >::ArrayBuffer | ( | INDEX | size | ) | [inline, explicit] |
Constructs an empty ArrayBuffer, allocating memory for up to size elements.
Definition at line 77 of file ArrayBuffer.h.
| void ogdf::ArrayBuffer< E, INDEX >::clear | ( | ) | [inline] |
Clears the buffer.
Definition at line 85 of file ArrayBuffer.h.
| void ogdf::ArrayBuffer< E, INDEX >::compactCopy | ( | Array< E, INDEX > & | A2 | ) | const [inline] |
Generates a compact copy holding the current elements.
Creates a copy of the ArrayBuffer and stores it into the given Array A. A has exactly the neccessary size to hold all elements in the buffer.
This method uses an elementwise operator=. If you need a bitcopy of the buffer, use compactMemcpy instead; if you need a traditional array copy (using the Array's copy-constructor) use compactCpyCon instead.
Definition at line 133 of file ArrayBuffer.h.
| void ogdf::ArrayBuffer< E, INDEX >::compactCpycon | ( | Array< E, INDEX > & | A2 | ) | const [inline] |
Generates a compact copy holding the current elements.
Creates a copy of the ArrayBuffer and stores it into the given Array A. A has exactly the neccessary size to hold all elements in the buffer.
This method uses the Array's copy constructur. If you need a bitcopy of the buffer, use compactMemcpy instead; if you neeed a elementwise operator=-copy, use compactCopy instead.
Definition at line 155 of file ArrayBuffer.h.
| void ogdf::ArrayBuffer< E, INDEX >::compactMemcpy | ( | Array< E, INDEX > & | A2 | ) | const [inline] |
Generates a compact copy holding the current elements.
Creates a copy of the ArrayBuffer and stores it into the given Array A. A has exactly the neccessary size to hold all elements in the buffer.
This method uses memcpy. If you need a traditional arraycopy using a copy constructur, use compactCopy instead; if you neeed a elementwise operator=-copy, use compactCopy instead.
Definition at line 178 of file ArrayBuffer.h.
| bool ogdf::ArrayBuffer< E, INDEX >::empty | ( | ) | const [inline] |
Returns true if the buffer is empty, false otherwise.
Definition at line 105 of file ArrayBuffer.h.
| void ogdf::ArrayBuffer< E, INDEX >::init | ( | INDEX | size | ) | [inline] |
Reinitializes the array, clearing it, and allocating memory for up to size elements.
Reimplemented from ogdf::Array< E, INDEX >.
Definition at line 82 of file ArrayBuffer.h.
| void ogdf::ArrayBuffer< E, INDEX >::init | ( | ) | [inline] |
Reinitializes the array, clearing it, and without initial memory allocation.
Reimplemented from ogdf::Array< E, INDEX >.
Definition at line 80 of file ArrayBuffer.h.
| INDEX ogdf::ArrayBuffer< E, INDEX >::linearSearch | ( | const E & | x | ) | const [inline] |
Performs a linear search for element x.
Warning: linear running time! Note that the linear search runs from back to front.
Reimplemented from ogdf::Array< E, INDEX >.
Definition at line 193 of file ArrayBuffer.h.
| INDEX ogdf::ArrayBuffer< E, INDEX >::linearSearch | ( | const E & | x, | |
| const COMPARER & | comp | |||
| ) | const [inline] |
Performs a linear search for element x with comparer comp.
Warning: linear running time! Note that the linear search runs from back to front.
Reimplemented from ogdf::Array< E, INDEX >.
Definition at line 207 of file ArrayBuffer.h.
| const E& ogdf::ArrayBuffer< E, INDEX >::operator[] | ( | INDEX | i | ) | const [inline] |
Returns a reference to the element at position i.
Reimplemented from ogdf::Array< E, INDEX >.
Definition at line 111 of file ArrayBuffer.h.
| E& ogdf::ArrayBuffer< E, INDEX >::operator[] | ( | INDEX | i | ) | [inline] |
Returns a reference to the element at position i.
Reimplemented from ogdf::Array< E, INDEX >.
Definition at line 116 of file ArrayBuffer.h.
| void ogdf::ArrayBuffer< E, INDEX >::pop | ( | ) | [inline] |
Removes the newest element from the buffer.
Definition at line 100 of file ArrayBuffer.h.
| E ogdf::ArrayBuffer< E, INDEX >::popRet | ( | ) | [inline] |
Removes the newest element from the buffer and returns it.
Definition at line 102 of file ArrayBuffer.h.
| void ogdf::ArrayBuffer< E, INDEX >::push | ( | E | e | ) | [inline] |
Puts a new element in the buffer.
Definition at line 93 of file ArrayBuffer.h.
| INDEX ogdf::ArrayBuffer< E, INDEX >::size | ( | ) | const [inline] |
Returns number of elements in the buffer.
Reimplemented from ogdf::Array< E, INDEX >.
Definition at line 108 of file ArrayBuffer.h.
| E& ogdf::ArrayBuffer< E, INDEX >::top | ( | ) | [inline] |
Returns the newest element of the buffer.
Definition at line 90 of file ArrayBuffer.h.
| const E& ogdf::ArrayBuffer< E, INDEX >::top | ( | ) | const [inline] |
Returns the newest element of the buffer.
Definition at line 88 of file ArrayBuffer.h.
INDEX ogdf::ArrayBuffer< E, INDEX >::num [private] |
The number of elements in te buffer.
Definition at line 72 of file ArrayBuffer.h.