The parameterized class Array<E,INDEX> implements dynamic arrays of type E. More...
#include <ogdf/basic/Array.h>
Public Member Functions | |
| Array () | |
| Creates an array with empty index set. | |
| Array (INDEX s) | |
| Creates an array with index set [0..s-1]. | |
| Array (INDEX a, INDEX b) | |
| Creates an array with index set [a..b]. | |
| Array (INDEX a, INDEX b, const E &x) | |
| Creates an array with index set [a..b] and initializes each element with x. | |
| Array (const Array< E > &A) | |
| Creates an array that is a copy of A. | |
| ~Array () | |
| INDEX | low () const |
| Returns the minimal array index. | |
| INDEX | high () const |
| Returns the maximal array index. | |
| INDEX | size () const |
| Returns the size (number of elements) of the array. | |
| E * | begin () |
| Returns a pointer to the first element. | |
| const E * | begin () const |
| Returns a pointer to the first element. | |
| E * | end () |
| Returns a pointer to one past the last element. | |
| const E * | end () const |
| Returns a pointer to one past the last element. | |
| E * | rbegin () |
| Returns a pointer to the last element. | |
| const E * | rbegin () const |
| Returns a pointer to the last element. | |
| E * | rend () |
| Returns a pointer to one before the first element. | |
| const E * | rend () const |
| Returns a pointer to one before the first element. | |
| 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 | swap (INDEX i, INDEX j) |
| Swaps the elements at position i and j. | |
| void | init () |
| Reinitializes the array to an array with empty index set. | |
| void | init (INDEX s) |
| Reinitializes the array to an array with index set [0..s-1]. | |
| void | init (INDEX a, INDEX b) |
| Reinitializes the array to an array with index set [a..b]. | |
| void | init (INDEX a, INDEX b, const E &x) |
| Reinitializes the array to an array with index set [a..b] and sets all entries to x. | |
| Array< E, INDEX > & | operator= (const Array< E, INDEX > &array2) |
| Assignment operator. | |
| void | fill (const E &x) |
| Sets all elements to x. | |
| void | fill (INDEX i, INDEX j, const E &x) |
| Sets elements in the intervall [i..j] to x. | |
| void | grow (INDEX add, const E &x) |
| Enlarges the array by add elements and sets new elements to x. | |
| void | grow (INDEX add) |
| Enlarges the array by add elements. | |
| void | permute (INDEX l, INDEX r) |
| Randomly permutes the subarray with index set [l..r]. | |
| void | permute () |
| Randomly permutes the array. | |
| int | binarySearch (const E &x) const |
| Performs a binary search for element x. | |
| template<class COMPARER > | |
| int | binarySearch (const E &e, const COMPARER &comp) const |
| Performs a binary search for element x with comparer comp. | |
| int | linearSearch (const E &e) const |
| Performs a linear search for element x. | |
| template<class COMPARER > | |
| int | linearSearch (const E &e, const COMPARER &comp) const |
| Performs a linear search for element x with comparer comp. | |
| void | quicksort () |
| Sorts array using Quicksort. | |
| void | quicksort (INDEX l, INDEX r) |
| Sorts subarray with index set [l..r] using Quicksort. | |
| template<class COMPARER > | |
| void | quicksort (const COMPARER &comp) |
| Sorts array using Quicksort and a user-defined comparer comp. | |
| template<class COMPARER > | |
| void | quicksort (INDEX l, INDEX r, const COMPARER &comp) |
| Sorts the subarray with index set [l..r] using Quicksort and a user-defined comparer comp. | |
| void * | operator new (size_t nBytes) |
| void * | operator new (size_t, void *p) |
| void | operator delete (void *p, size_t nBytes) |
Private Member Functions | |
| void | construct (INDEX a, INDEX b) |
| Allocates new array with index set [a..b]. | |
| void | initialize () |
| Initializes elements with default constructor. | |
| void | initialize (const E &x) |
| Initializes elements with x. | |
| void | deconstruct () |
| Deallocates array. | |
| void | copy (const Array< E, INDEX > &A) |
| Constructs a new array which is a copy of A. | |
Static Private Member Functions | |
| template<class COMPARER > | |
| static void | quicksortInt (E *pL, E *pR, const COMPARER &comp) |
| Internal Quicksort implementation with comparer template. | |
Private Attributes | |
| E * | m_vpStart |
| The virtual start of the array (address of A[0]). | |
| E * | m_pStart |
| The real start of the array (address of A[m_low]). | |
| E * | m_pStop |
| Successor of last element (address of A[m_high+1]). | |
| INDEX | m_low |
| The lowest index. | |
| INDEX | m_high |
| The highest index. | |
Friends | |
| class | ArrayBuffer |
The parameterized class Array<E,INDEX> implements dynamic arrays of type E.
The template parameter E denotes the element type and the parameter INDEX denotes the index type. The index type must be chosen such that it can express the whole index range of the array instance, as well as its size. The default index type is int, other possible types are short and long long (on 64-bit systems).
Definition at line 120 of file Array.h.
| ogdf::Array< E, INDEX >::Array | ( | ) | [inline] |
| ogdf::Array< E, INDEX >::Array | ( | INDEX | s | ) | [inline, explicit] |
| ogdf::Array< E, INDEX >::Array | ( | INDEX | a, | |
| INDEX | b | |||
| ) | [inline] |
| ogdf::Array< E, INDEX >::Array | ( | INDEX | a, | |
| INDEX | b, | |||
| const E & | x | |||
| ) | [inline] |
| ogdf::Array< E, INDEX >::Array | ( | const Array< E > & | A | ) | [inline] |
| ogdf::Array< E, INDEX >::~Array | ( | ) | [inline] |
| E* ogdf::Array< E, INDEX >::begin | ( | ) | [inline] |
| const E* ogdf::Array< E, INDEX >::begin | ( | ) | const [inline] |
| int ogdf::Array< E, INDEX >::binarySearch | ( | const E & | x | ) | const [inline] |
| int ogdf::Array< E, INDEX >::binarySearch | ( | const E & | e, | |
| const COMPARER & | comp | |||
| ) | const [inline] |
| void ogdf::Array< E, INDEX >::construct | ( | INDEX | a, | |
| INDEX | b | |||
| ) | [private] |
| void ogdf::Array< E, INDEX >::copy | ( | const Array< E, INDEX > & | A | ) | [private] |
| void ogdf::Array< E, INDEX >::deconstruct | ( | ) | [private] |
| E* ogdf::Array< E, INDEX >::end | ( | ) | [inline] |
| const E* ogdf::Array< E, INDEX >::end | ( | ) | const [inline] |
| void ogdf::Array< E, INDEX >::fill | ( | const E & | x | ) | [inline] |
| void ogdf::Array< E, INDEX >::fill | ( | INDEX | i, | |
| INDEX | j, | |||
| const E & | x | |||
| ) | [inline] |
| void ogdf::Array< E, INDEX >::grow | ( | INDEX | add, | |
| const E & | x | |||
| ) |
Enlarges the array by add elements and sets new elements to x.
Note: address of array entries in memory may change!
| add | is the number of additional elements; add can be negative in order to shrink the array. | |
| x | is the inital value of all new elements. |
| void ogdf::Array< E, INDEX >::grow | ( | INDEX | add | ) |
| INDEX ogdf::Array< E, INDEX >::high | ( | ) | const [inline] |
| void ogdf::Array< E, INDEX >::init | ( | INDEX | s | ) | [inline] |
Reinitializes the array to an array with index set [0..s-1].
Notice that the elements contained in the array get discarded!
Reimplemented in ogdf::ArrayBuffer< E, INDEX >, ogdf::ArrayBuffer< int >, and ogdf::ArrayBuffer< ABA_CONSTRAINT * >.
| void ogdf::Array< E, INDEX >::init | ( | INDEX | a, | |
| INDEX | b | |||
| ) | [inline] |
| void ogdf::Array< E, INDEX >::init | ( | INDEX | a, | |
| INDEX | b, | |||
| const E & | x | |||
| ) | [inline] |
| void ogdf::Array< E, INDEX >::init | ( | ) | [inline] |
Reinitializes the array to an array with empty index set.
Reimplemented in ogdf::ArrayBuffer< E, INDEX >, ogdf::ArrayBuffer< int >, and ogdf::ArrayBuffer< ABA_CONSTRAINT * >.
| void ogdf::Array< E, INDEX >::initialize | ( | ) | [private] |
| void ogdf::Array< E, INDEX >::initialize | ( | const E & | x | ) | [private] |
| int ogdf::Array< E, INDEX >::linearSearch | ( | const E & | e | ) | const [inline] |
Performs a linear search for element x.
Warning: This method has linear running time! Note that the linear search runs from back to front.
Reimplemented in ogdf::ArrayBuffer< E, INDEX >, ogdf::ArrayBuffer< int >, and ogdf::ArrayBuffer< ABA_CONSTRAINT * >.
| int ogdf::Array< E, INDEX >::linearSearch | ( | const E & | e, | |
| const COMPARER & | comp | |||
| ) | const [inline] |
Performs a linear search for element x with comparer comp.
Warning: This method has linear running time! Note that the linear search runs from back to front.
Reimplemented in ogdf::ArrayBuffer< E, INDEX >, ogdf::ArrayBuffer< int >, and ogdf::ArrayBuffer< ABA_CONSTRAINT * >.
| INDEX ogdf::Array< E, INDEX >::low | ( | ) | const [inline] |
| void ogdf::Array< E, INDEX >::operator delete | ( | void * | p, | |
| size_t | nBytes | |||
| ) | [inline] |
| void* ogdf::Array< E, INDEX >::operator new | ( | size_t | nBytes | ) | [inline] |
| void* ogdf::Array< E, INDEX >::operator new | ( | size_t | , | |
| void * | p | |||
| ) | [inline] |
| Array<E,INDEX>& ogdf::Array< E, INDEX >::operator= | ( | const Array< E, INDEX > & | array2 | ) | [inline] |
| const E& ogdf::Array< E, INDEX >::operator[] | ( | INDEX | i | ) | const [inline] |
Returns a reference to the element at position i.
Reimplemented in ogdf::ArrayBuffer< E, INDEX >, ogdf::ShellingOrderSet, ogdf::ArrayBuffer< int >, and ogdf::ArrayBuffer< ABA_CONSTRAINT * >.
| E& ogdf::Array< E, INDEX >::operator[] | ( | INDEX | i | ) | [inline] |
Returns a reference to the element at position i.
Reimplemented in ogdf::ArrayBuffer< E, INDEX >, ogdf::ShellingOrderSet, ogdf::ArrayBuffer< int >, and ogdf::ArrayBuffer< ABA_CONSTRAINT * >.
| void ogdf::Array< E, INDEX >::permute | ( | ) | [inline] |
| void ogdf::Array< E, INDEX >::permute | ( | INDEX | l, | |
| INDEX | r | |||
| ) |
| void ogdf::Array< E, INDEX >::quicksort | ( | const COMPARER & | comp | ) | [inline] |
| void ogdf::Array< E, INDEX >::quicksort | ( | INDEX | l, | |
| INDEX | r | |||
| ) | [inline] |
| void ogdf::Array< E, INDEX >::quicksort | ( | ) | [inline] |
| void ogdf::Array< E, INDEX >::quicksort | ( | INDEX | l, | |
| INDEX | r, | |||
| const COMPARER & | comp | |||
| ) | [inline] |
Sorts the subarray with index set [l..r] using Quicksort and a user-defined comparer comp.
| l | is the left-most position in the range to be sorted. | |
| r | is the right-most position in the range to be sorted. | |
| comp | is a user-defined comparer; C must be a class providing a less(x,y) method. |
| static void ogdf::Array< E, INDEX >::quicksortInt | ( | E * | pL, | |
| E * | pR, | |||
| const COMPARER & | comp | |||
| ) | [inline, static, private] |
| const E* ogdf::Array< E, INDEX >::rbegin | ( | ) | const [inline] |
| E* ogdf::Array< E, INDEX >::rbegin | ( | ) | [inline] |
| const E* ogdf::Array< E, INDEX >::rend | ( | ) | const [inline] |
| E* ogdf::Array< E, INDEX >::rend | ( | ) | [inline] |
| INDEX ogdf::Array< E, INDEX >::size | ( | ) | const [inline] |
Returns the size (number of elements) of the array.
Reimplemented in ogdf::ArrayBuffer< E, INDEX >, ogdf::ArrayBuffer< int >, and ogdf::ArrayBuffer< ABA_CONSTRAINT * >.
| void ogdf::Array< E, INDEX >::swap | ( | INDEX | i, | |
| INDEX | j | |||
| ) | [inline] |
friend class ArrayBuffer [friend] |
INDEX ogdf::Array< E, INDEX >::m_high [private] |
INDEX ogdf::Array< E, INDEX >::m_low [private] |
E* ogdf::Array< E, INDEX >::m_pStart [private] |
E* ogdf::Array< E, INDEX >::m_pStop [private] |
E* ogdf::Array< E, INDEX >::m_vpStart [private] |