|
Open Graph Drawing Framework |
v. 2023.09 (Elderberry)
|
|
|
Go to the documentation of this file.
44 #include <type_traits>
63 template<
class E,
class INDEX =
int>
64 class ArrayBuffer :
private Array<E, INDEX> {
99 buffer.growable =
true;
119 const INDEX nInd = ind.size();
127 INDEX j, current = ind[0];
128 for (INDEX i = 0; i < nInd - 1; i++) {
132 const INDEX last = ind[i + 1];
133 for (j = ind[i] + 1; j < last; j++) {
139 for (j = ind[nInd - 1] + 1; j <
size(); j++) {
280 buffer.growable =
true;
318 template<typename EE = E, typename std::enable_if<!OGDF_TRIVIALLY_COPYABLE<EE>::value,
int>
::type = 0>
323 for (INDEX i =
num; i-- > 0;) {
342 template<typename EE = E, typename std::enable_if<OGDF_TRIVIALLY_COPYABLE<EE>::value,
int>
::type = 0>
347 OGDF_ASSERT(
sizeof(E) <=
size_t(std::numeric_limits<INDEX>::max() /
num));
350 sizeof(E) <=
size_t(std::numeric_limits<INDEX>::max() /
num)
352 :
size_t(std::numeric_limits<INDEX>::max()));
364 if (
size() != L.size()) {
368 auto thisIterator =
begin();
369 auto thatIterator = L.begin();
371 while (thisIterator !=
end() && thatIterator != L.end()) {
372 if (*thisIterator != *thatIterator) {
402 for (i =
num; i-- > 0;) {
416 template<
class COMPARER>
419 for (i =
num; i-- > 0;) {
439 template<
class COMPARER>
461 template<
class COMPARER>
507 template<
class E,
class INDEX>
509 for (
int i = 0; i < a.size(); i++) {
518 template<
class E,
class INDEX>
An array that keeps track of the number of inserted elements; also usable as an efficient stack.
The namespace for all OGDF objects.
E & top()
Returns the newest element of the buffer.
void compactCopy(Array< E, INDEX > &A2) const
Generates a compact copy holding the current elements.
reverse_iterator rbegin()
Returns a reverse iterator to the last element.
INDEX capacity() const
Returns the current capacity of the datastructure. Note that this value is rather irrelevant if the a...
#define OGDF_ASSERT(expr)
Assert condition expr. See doc/build.md for more information.
bool empty() const
Returns true if the buffer is empty, false otherwise.
bool isGrowable() const
Returns whether the buffer will automatically expand if the initial size is insufficient.
const E & top() const
Returns the newest element of the buffer.
Standard comparer (valid as a static comparer).
ArrayBuffer(ArrayBuffer< E, INDEX > &&buffer)
Creates an array buffer containing the elements of buffer (move semantics).
void init(INDEX size)
Reinitializes the array, clearing it, and allocating memory for up to size elements.
INDEX binarySearch(const E &e, const COMPARER &comp) const
Performs a binary search for element e with comparer comp.
void permute(INDEX l, INDEX r)
Randomly permutes the subarray with index set [l..r].
bool full() const
Returns true iff the buffer is non-growable and filled.
Random-access reverse iterator based on a pointer to an array element.
void permute()
Randomly permutes the array.
ArrayIterator< E > iterator
Provides a random-access iterator that can read or modify any element in an array.
E popRet()
Removes the newest element from the buffer and returns it.
void init()
Reinitializes the array to an array with empty index set.
void setCapacity(INDEX newCapacity)
Changes the capacity of the buffer (independent whether the buffer is growable of not).
#define OGDF_NEW_DELETE
Makes the class use OGDF's memory allocator.
ArrayBuffer< E, INDEX > & operator=(const ArrayBuffer< E, INDEX > &buffer)
Assignment operator.
INDEX linearSearch(const E &x) const
Performs a linear search for element x.
void permute()
Randomly permutes the array.
Array< E, INDEX > & operator=(const Array< E, INDEX > &A)
Assignment operator.
typename Array< abacus::Constraint *, int >::const_reverse_iterator const_reverse_iterator
void leftShift(ArrayBuffer< INDEX, INDEX > &ind)
Removes the components listed in the buffer ind by shifting the remaining components to the left.
INDEX num
The number of elements in the buffer.
const_reverse_iterator rbegin() const
Returns a const reverse iterator to the last element.
void quicksort()
Sorts buffer using Quicksort.
void init()
Reinitializes the array, clearing it, and without initial memory allocation.
void permute(RNG &rng)
Randomly permutes the array using random number generator rng.
typename Array< abacus::Constraint *, int >::const_iterator const_iterator
const_iterator end() const
Returns a const iterator to one past the last element.
const T & move(const T &v)
The parameterized class Array implements dynamic arrays of type E.
const_reference operator[](INDEX i) const
Returns a reference to the element at position i.
typename Array< abacus::Constraint *, int >::iterator iterator
INDEX size() const
Returns number of elements in the buffer.
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.
const_reverse_iterator rend() const
Returns a const reverse iterator to one before the first element.
iterator end()
Returns an iterator to one past the last element.
std::ostream & operator<<(std::ostream &os, const ogdf::Array< E, INDEX > &a)
Prints array a to output stream os.
iterator begin()
Returns an iterator to the first element.
reverse_iterator rend()
Returns an reverse iterator to one before the first element.
INDEX binarySearch(const E &e) const
Performs a binary search for element e.
void setGrowable(bool _growable)
Sets the flag whether the buffer will automatically expand if the initial size is insufficient.
const_iterator begin() const
Returns a const iterator to the first element.
INDEX linearSearch(const E &x, const COMPARER &comp) const
Performs a linear search for element x with comparer comp.
long unsigned int randomSeed()
Returns a random value suitable as initial seed for a random number engine.
void permute(INDEX l, INDEX r, RNG &rng)
Randomly permutes the subarray with index set [l..r] using random number generator rng.
E & operator[](INDEX i)
Returns a reference to the element at position i.
iterator begin()
Returns an iterator to the first element.
void resize(INDEX newSize, const E &x)
Resizes (enlarges or shrinks) the array to hold newSize elements and sets new elements to x.
E * m_pStart
The real start of the array (address of A[m_low]).
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...
typename Array< abacus::Constraint *, int >::reverse_iterator reverse_iterator
ArrayConstIterator< E > const_iterator
Provides a random-access iterator that can read a const element in an array.
ArrayBuffer(INDEX size, bool autogrow=true)
Creates an empty array buffer, allocating memory for up to size elements; you may specify that the ar...
Basic declarations, included by all source files.
ArrayBuffer()
Creates an empty array buffer, without initial memory allocation.
void pop()
Removes the newest element from the buffer.
bool operator==(const ArrayBuffer< E, INDEX > &L) const
Equality operator.
Forms the virtual base class for all possible constraints given in pool format.
int binarySearch(const E &e) const
Performs a binary search for element e.
Declaration and implementation of Array class and Array algorithms.
void print(std::ostream &os, const Array< E, INDEX > &a, char delim=' ')
Prints array a to output stream os using delimiter delim.
ArrayBuffer< E, INDEX > & operator=(ArrayBuffer< E, INDEX > &&buffer)
Assignment operator (move semantics).
void quicksort()
Sorts array using Quicksort.
INDEX size() const
Returns the size (number of elements) of the array.
void compactCpycon(Array< E, INDEX > &A2) const
Generates a compact copy holding the current elements.
void grow(INDEX add, const E &x)
Enlarges the array by add elements and sets new elements to x.
void copy(const Array< E, INDEX > &A)
Constructs a new array which is a copy of A.
void clear()
Clears the buffer.
const E & operator[](INDEX i) const
Returns a reference to the element at position i.
bool operator!=(const ArrayBuffer< E, INDEX > &L) const
Inequality operator.
reverse_iterator rend()
Returns a reverse iterator to one before the first element.
Declarations for Comparer objects.
Declaration of memory manager for allocating small pieces of memory.
ArrayBuffer(const ArrayBuffer< E, INDEX > &buffer)
Creates an array buffer that is a copy of buffer.