55template<
class E,
class INDEX =
int>
125 for (
j =
ind[i] + 1;
j < last;
j++) {
351 if (
size() !=
L.size()) {
389 for (i =
num; i-- > 0;) {
403 template<
class COMPARER>
406 for (i =
num; i-- > 0;) {
426 template<
class COMPARER>
448 template<
class COMPARER>
494template<
class E,
class INDEX>
496 for (
int i = 0; i < a.
size(); i++) {
505template<
class E,
class INDEX>
Declaration and implementation of Array class and Array algorithms.
An array that keeps track of the number of inserted elements; also usable as an efficient stack.
ArrayBuffer(const Array< E, INDEX > &source, bool autogrow=true)
Creates an array buffer, initialized by the given array; you may specify that the array should not gr...
iterator end()
Returns an iterator to one past the last element.
const_reverse_iterator rend() const
Returns a const reverse iterator to one before the first element.
const E & top() const
Returns the newest element of the buffer.
void clear()
Clears the buffer.
E popRet()
Removes the newest element from the buffer and returns it.
void setGrowable(bool _growable)
Sets the flag whether the buffer will automatically expand if the initial size is insufficient.
reverse_iterator rend()
Returns a reverse iterator to one before the first element.
void quicksort(const COMPARER &comp)
Sorts buffer using Quicksort and a user-defined comparer comp.
void push(E e)
Puts a new element in the buffer.
INDEX binarySearch(const E &e, const COMPARER &comp) const
Performs a binary search for element e with comparer comp.
const E & operator[](INDEX i) const
Returns a reference to the element at position i.
const_iterator begin() const
Returns a const iterator to the first element.
void quicksort()
Sorts buffer using Quicksort.
void permute()
Randomly permutes the array.
INDEX linearSearch(const E &x) const
Performs a linear search for element x.
void setCapacity(INDEX newCapacity)
Changes the capacity of the buffer (independent whether the buffer is growable of not).
reverse_iterator rbegin()
Returns a reverse iterator to the last element.
bool full() const
Returns true iff the buffer is non-growable and filled.
void compactCpycon(Array< E, INDEX > &A2) const
Generates a compact copy holding the current elements.
bool isGrowable() const
Returns whether the buffer will automatically expand if the initial size is insufficient.
const_reverse_iterator rbegin() const
Returns a const reverse iterator to the last element.
bool operator==(const ArrayBuffer< E, INDEX > &L) const
Equality operator.
void pop()
Removes the newest element from the buffer.
INDEX num
The number of elements in the buffer.
E & operator[](INDEX i)
Returns a reference to the element at position i.
INDEX linearSearch(const E &x, const COMPARER &comp) const
Performs a linear search for element x with comparer comp.
ArrayBuffer< E, INDEX > & operator=(ArrayBuffer< E, INDEX > &&buffer)
Assignment operator (move semantics).
void permute(INDEX l, INDEX r, RNG &rng)
Randomly permutes the subarray with index set [l..r] using random number generator rng.
void init()
Reinitializes the array, clearing it, and without initial memory allocation.
void permute(INDEX l, INDEX r)
Randomly permutes the subarray with index set [l..r].
ArrayBuffer< E, INDEX > & operator=(const ArrayBuffer< E, INDEX > &buffer)
Assignment operator.
bool operator!=(const ArrayBuffer< E, INDEX > &L) const
Inequality operator.
INDEX binarySearch(const E &e) const
Performs a binary search for element e.
ArrayBuffer()
Creates an empty array buffer, without initial memory allocation.
ArrayBuffer(INDEX size, bool autogrow=true)
Creates an empty array buffer, allocating memory for up to size elements; you may specify that the ar...
E & top()
Returns the newest element of the buffer.
ArrayBuffer(ArrayBuffer< E, INDEX > &&buffer)
Creates an array buffer containing the elements of buffer (move semantics).
const_iterator end() const
Returns a const iterator to one past the last element.
ArrayBuffer(const ArrayBuffer< E, INDEX > &buffer)
Creates an array buffer that is a copy of buffer.
bool empty() const
Returns true if the buffer is empty, false otherwise.
typename Array< E, INDEX >::iterator iterator
typename Array< E, INDEX >::const_reverse_iterator const_reverse_iterator
void permute(RNG &rng)
Randomly permutes the array using random number generator rng.
iterator begin()
Returns an iterator to the first element.
INDEX size() const
Returns number of elements in the buffer.
typename Array< E, INDEX >::reverse_iterator reverse_iterator
INDEX capacity() const
Returns the current capacity of the datastructure. Note that this value is rather irrelevant if the a...
void leftShift(ArrayBuffer< INDEX, INDEX > &ind)
Removes the components listed in the buffer ind by shifting the remaining components to the left.
void init(INDEX size)
Reinitializes the array, clearing it, and allocating memory for up to size elements.
void compactCopy(Array< E, INDEX > &A2) const
Generates a compact copy holding the current elements.
typename Array< E, INDEX >::const_iterator const_iterator
The parameterized class Array implements dynamic arrays of type E.
iterator begin()
Returns an iterator to the first element.
const_reference operator[](INDEX i) const
Returns a reference to the element at position i.
void resize(INDEX newSize, const E &x)
Resizes (enlarges or shrinks) the array to hold newSize elements and sets new elements to x.
void grow(INDEX add, const E &x)
Enlarges the array by add elements and sets new elements to x.
void swap(INDEX i, INDEX j)
Swaps the elements at position i and j.
reverse_iterator rend()
Returns an reverse iterator to one before the first element.
void init()
Reinitializes the array to an array with empty index set.
void quicksort()
Sorts array using Quicksort.
int binarySearch(const E &e) const
Performs a binary search for element e.
ArrayConstIterator< E > const_iterator
Provides a random-access iterator that can read a const element in an array.
Array< E, INDEX > & operator=(const Array< E, INDEX > &A)
Assignment operator.
void permute()
Randomly permutes the array.
INDEX size() const
Returns the size (number of elements) of the array.
void copy(const Array< E, INDEX > &A)
Constructs a new array which is a copy of A.
ArrayIterator< E > iterator
Provides a random-access iterator that can read or modify any element in an array.
Random-access reverse iterator based on a pointer to an array element.
Standard comparer (valid as a static comparer).
#define OGDF_ASSERT(expr)
Assert condition expr. See doc/build.md for more information.
#define OGDF_NEW_DELETE
Makes the class use OGDF's memory allocator.
long unsigned int randomSeed()
Returns a random value suitable as initial seed for a random number engine.
static MultilevelBuilder * getDoubleFactoredZeroAdjustedMerger()
The namespace for all OGDF objects.
std::ostream & operator<<(std::ostream &os, const ogdf::Array< E, INDEX > &a)
Prints array a to output stream os.
void print(std::ostream &os, const Array< E, INDEX > &a, char delim=' ')
Prints array a to output stream os using delimiter delim.