|
Open Graph Drawing Framework |
v. 2023.09 (Elderberry)
|
|
|
Go to the documentation of this file.
41 #include <initializer_list>
44 #include <type_traits>
49 template<
class E,
bool isConst>
86 template<
class... Args>
103 template<
class E,
bool isConst>
104 class SListIteratorBase {
212 for (
const E& x :
init) {
225 L.m_head = L.m_tail =
nullptr;
430 L.m_head = L.m_tail =
nullptr;
438 while (pX !=
nullptr && pY !=
nullptr) {
439 if (pX->
m_x != pY->m_x) {
445 return pX ==
nullptr && pY ==
nullptr;
471 template<
class... Args>
495 template<
class... Args>
517 return (pBefore->
m_next = pNew);
572 if (!std::is_trivially_destructible<E>::value) {
600 if (L2.m_tail ==
nullptr) {
601 L2.m_tail = L2.m_head;
604 L2.m_head->m_list = &L2;
617 if (L2.m_head ==
nullptr) {
618 L2.m_head = L2.m_tail = pX;
620 L2.m_tail = L2.m_tail->m_next = pX;
623 L2.m_tail->m_list = &L2;
642 if (pBefore == L2.m_tail) {
652 m_tail->m_next = L2.m_head;
656 if (L2.m_tail !=
nullptr) {
662 L2.m_head = L2.m_tail =
nullptr;
668 for (p =
m_head; p; p = pNext) {
710 template<
class COMPARER>
714 if (comp.equal(*i, e)) {
724 template<
class COMPARER>
728 if (comp.equal(*i, e)) {
739 template<
class COMPARER>
766 std::function<
bool(
const E&)> includeElement = [](
const E&) {
return true; },
767 bool isFastTest =
true)
const {
773 std::function<
bool(
const E&)> includeElement = [](
const E&) {
return true; },
774 bool isFastTest =
true) {
780 std::function<
bool(
const E&)> includeElement = [](
const E&) {
return true; },
781 bool isFastTest =
true)
const {
789 std::function<
bool(
const E&)> includeElement = [](
const E&) {
return true; },
790 bool isFastTest =
true) {
819 void permute(
const int n, RNG& rng);
824 for (
auto e = start ==
nullptr ?
m_head : start; e !=
nullptr; e = e->m_next) {
932 template<
class... Args>
945 template<
class... Args>
1049 if (m_head == m_tail) {
1073 if (m_head == m_tail) {
1080 for (pX = m_head; pX; pX = pX->
m_next) {
1083 tail[i] = (tail[i]->m_next = pX);
1085 head[i] = tail[i] = pX;
1090 for (
int i = l; i <= h; i++) {
1118 for (pX = m_head; pX; pX = pX->
m_next) {
1122 A.permute(0, n - 1, rng);
1124 for (i = 0; i < n; i++) {
1125 A[i]->m_next =
A[i + 1];
1138 for (++pX; pX.valid(); ++pX) {
1174 for (i = a.
low(); i <= a.
high(); ++i) {
1175 bucket[f.
getBucket(a[i])].pushBack(a[i]);
1179 for (
int j = min; j <= max; ++j) {
1181 for (; it.
valid(); ++it) {
The namespace for all OGDF objects.
CONTAINER::iterator chooseIteratorFrom(CONTAINER &container, std::function< bool(const TYPE &)> includeElement=[](const TYPE &) { return true;}, bool isFastTest=true)
Returns an iterator to a random element in the container.
SListPure(const SListPure< E > &L)
Constructs a singly linked list that is a copy of L.
const SListPure< E > & getSListPure() const
Conversion to const SListPure.
const_iterator chooseIterator(std::function< bool(const E &)> includeElement=[](const E &) { return true;}, bool isFastTest=true) const
SListIterator< E > iterator
Provides a forward iterator that can read or modify any element in a list.
typename std::conditional< isConst, const SListElement< E >, SListElement< E > >::type ListElem
The underlying list element, depending on isConst.
iterator emplaceFront(Args &&... args)
Adds a new element at the beginning of the list.
#define OGDF_ASSERT(expr)
Assert condition expr. See doc/build.md for more information.
SListIterator< E > search(const E &e, const COMPARER &comp)
Scans the list for the specified element (using the user-defined comparer) and returns an iterator to...
const E & const_reference
Provides a reference to a const element stored in a list for reading and performing const operations.
SListConstIterator< E > search(const E &e) const
Scans the list for the specified element and returns an iterator to the first occurrence in the list,...
iterator backIterator()
Returns an iterator to the last element of the list.
int m_count
The length of the list.
void reverse()
Reverses the order of the list elements.
void moveFrontToFront(SList< E > &L2)
Moves the first element of this list to the begin of list L2.
SList(std::initializer_list< E > init)
Constructs a singly linked list containing the elements in init.
const_reference front() const
Returns a reference to the first element.
void quicksort(const COMPARER &comp)
Sorts the list using Quicksort and comparer comp.
SList()
Constructs an empty singly linked list.
int pos(const_iterator it) const
Returns the position (starting with 0) of it in the list.
SList< E > & operator=(const SList< E > &L)
Assignment operator.
SListElement()
Constructs an SListElement.
Encapsulates a pointer to an ogdf::SList element.
INDEX high() const
Returns the maximal array index.
iterator get(int pos)
Returns an iterator pointing to the element at position pos.
Singly linked lists (maintaining the length of the list).
E popFrontRet()
Removes the first element from the list and returns it.
reference back()
Returns a reference to the last element.
void permute()
Randomly permutes the elements in the list.
SListElement(SListPure< E > *list, const E &x)
Constructs an SListElement.
iterator insertAfter(const E &x, iterator itBefore)
Inserts element x after itBefore.
void clear()
Removes all elements from the list.
Abstract base class for bucket functions.
void bucketSort(Array< E > &a, int min, int max, BucketFunc< E > &f)
Bucket-sort array a using bucket assignment f; the values of f must be in the interval [min,...
SListElement< E > * m_head
Pointer to first element.
SListPure()
Constructs an empty singly linked list.
bool valid() const
Returns true iff the iterator points to an element.
SListIterator< E > insertAfter(const E &x, SListIterator< E > itBefore)
Inserts element x after itBefore.
void copy(const SListPure< E > &L)
E value_type
Represents the data type stored in a list element.
#define OGDF_NEW_DELETE
Makes the class use OGDF's memory allocator.
iterator chooseIterator(std::function< bool(const E &)> includeElement=[](const E &) { return true;}, bool isFastTest=true)
void quicksort()
Sorts the list using Quicksort.
iterator cyclicSucc(iterator it)
Returns an iterator to the cyclic successor of it.
E & reference
Provides a reference to an element stored in a list.
SListConstIterator< E > const_iterator
Provides a forward iterator that can read a const element in a list.
iterator begin()
Returns an iterator to the first element of the list.
SListElement< E > * m_next
Pointer to successor element.
SListPure(SListPure< E > &&L) noexcept
Constructs a singly linked list containing the elements of L (move semantics).
const_iterator cend() const
Returns a const iterator to one-past-last element of the list.
const_reference back() const
Returns a reference to the last element.
bool empty() const
Returns true iff the list is empty.
iterator emplaceBack(Args &&... args)
Adds a new element at the end of the list.
void moveFrontToBack(SList< E > &L2)
Moves the first element of this list to the end of list L2.
SListIteratorBase< E, isConst > & operator=(const SListIterator< E > &it)
Assignment operator.
SListElement< E > * m_tail
Pointer to last element.
void moveFrontToSucc(SList< E > &L2, SListIterator< E > itBefore)
Moves the first element of this list to list L2 inserted after itBefore.
Implementation of algorithms as templates working with different list types.
bool operator==(const SList< E > &L) const
Equality operator.
void conc(SListPure< E > &L2)
Appends L2 to this list and makes L2 empty.
iterator end()
Returns an iterator to one-past-last element of the list.
SListIterator< E > search(const E &e)
Scans the list for the specified element and returns an iterator to the first occurrence in the list,...
SListIteratorBase()
Constructs an invalid iterator.
SList(SList< E > &&L) noexcept
Constructs a singly linked list containing the elements of L (move semantics).
void delSucc(iterator itBefore)
Removes the succesor of itBefore.
SListPure< E > & operator=(SListPure< E > &&L)
Assignment operator (move semantics).
void permute(RNG &rng)
Randomly permutes the elements in the list using random number generator rng.
typename std::conditional< isConst, const ogdf::ExternE, ogdf::ExternE >::type Elem
The underlying type, depending on isConst.
const T & move(const T &v)
int size() const
Returns the number of elements in the list.
The parameterized class Array implements dynamic arrays of type E.
bool operator==(const SListIteratorBase< E, isConst > &it) const
Equality operator.
bool operator!=(const SListIteratorBase< E, isConst > &it) const
Inequality operator.
SListIteratorBase< E, isConst > operator++(int)
Increment operator (postfix).
Elem & operator*() const
Returns a reference to the element content.
const_iterator get(int pos) const
Returns an iterator pointing to the element at position pos.
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.
void reassignListRefs(SListElement< E > *start=nullptr)
Sets the debug reference of all list elements starting at start to this.
SListIterator< E > pushFront(const E &x)
Adds element x at the beginning of the list.
virtual int size() const
Returns the number of elements in the list.
const_iterator begin() const
Returns a const iterator to the first element of the list.
bool operator!=(const SListPure< E > &L) const
Inequality operator.
bool operator!=(const SList< E > &L) const
Inequality operator.
void clear()
Removes all elements from the list.
void delSucc(SListIterator< E > itBefore)
Removes the succesor of itBefore.
long unsigned int randomSeed()
Returns a random value suitable as initial seed for a random number engine.
E popFrontRet()
Removes the first element from the list and returns it.
const_iterator cbegin() const
Returns a const iterator to the first element of the list.
void moveFrontToBack(SListPure< E > &L2)
Moves the first element of this list to the end of list L2.
SListIteratorBase< E, isConst > & operator++()
Increment operator (prefix).
Structure for elements of singly linked lists.
Basic declarations, included by all source files.
SListIteratorBase(const SListIterator< E > &it)
Copy constructor.
SListIteratorBase(const SListIteratorBase< E, isArgConst > &it)
Constructs an iterator that is a copy of it.
SListIteratorBase< E, isConst > succ() const
Returns successor iterator.
SListElement(SListPure< E > *list, SListElement< E > *next, Args &&... args)
Constructs an SListElement with given arguments args for constructor of element type.
const_iterator end() const
Returns a const iterator to one-past-last element of the list.
Declaration and implementation of Array class and Array algorithms.
iterator emplaceBack(Args &&... args)
Adds a new element at the end of the list.
reference chooseElement(std::function< bool(const E &)> includeElement=[](const E &) { return true;}, bool isFastTest=true)
void print(std::ostream &os, const Array< E, INDEX > &a, char delim=' ')
Prints array a to output stream os using delimiter delim.
ListElem * m_pX
Pointer to slist element.
Class for the representation of edges.
virtual ~SListPure()
Destructor.
INDEX low() const
Returns the minimal array index.
void conc(SList< E > &L2)
Appends L2 to this list and makes L2 empty.
SListPure< E > * m_list
List object that the element belongs to.
SListIteratorBase(ListElem *pX)
Constructs an iterator that points to pX.
iterator pushBack(const E &x)
Adds element x at the end of the list.
const_iterator cyclicSucc(const_iterator it) const
Returns an iterator to the cyclic successor of it.
SListElement(SListPure< E > *list, const E &x, SListElement< E > *next)
Constructs an SListElement.
bool operator==(const SListPure< E > &L) const
Equality operator.
SList(const SList< E > &L)
Constructs a singly linked list that is a copy of L.
iterator pushFront(const E &x)
Adds element x at the beginning of the list.
const_iterator backIterator() const
Returns a const iterator to the last element of the list.
void quicksortTemplate(LIST &L)
void bucketSort(int l, int h, BucketFunc< E > &f)
Sorts the list using bucket sort.
SList< E > & operator=(SList< E > &&L)
Assignment operator (move semantics).
SListPure(std::initializer_list< E > init)
Constructs a singly linked list containing the elements in init.
void popFront()
Removes the first element from the list.
Declaration of memory manager for allocating small pieces of memory.
SListConstIterator< E > search(const E &e, const COMPARER &comp) const
Scans the list for the specified element (using the user-defined comparer) and returns an iterator to...
iterator emplaceFront(Args &&... args)
Adds a new element at the beginning of the list.
SListPure< E > & operator=(const SListPure< E > &L)
Assignment operator.
void moveFrontToFront(SListPure< E > &L2)
Moves the first element of this list to the begin of list L2.
virtual int getBucket(const E &x)=0
Returns the bucket of x.
const_reference chooseElement(std::function< bool(const E &)> includeElement=[](const E &) { return true;}, bool isFastTest=true) const
SListIterator< E > pushBack(const E &x)
Adds element x at the end of the list.
void popFront()
Removes the first element from the list.
reference front()
Returns a reference to the first element.
SListPure< E > * listOf()
Returns the list that this iterator belongs to.
void moveFrontToSucc(SListPure< E > &L2, iterator itBefore)
Moves the first element of this list to list L2 inserted after itBefore.