56 m_pStart = m_pEnd = m_pFirst = m_pStop =
nullptr;
62 m_pStart = m_pEnd = m_pFirst =
new E[n+1];
65 m_pStop = m_pFirst+n+1;
79 m_pStart = Q.m_pStart;
82 m_pFirst = Q.m_pFirst;
83 Q.m_pStart = Q.m_pEnd = Q.m_pFirst = Q.m_pStop =
nullptr;
92 m_pStart = m_pEnd = m_pFirst = m_pStop =
nullptr;
100 m_pStart = m_pEnd = m_pFirst =
new E[n+1];
103 m_pStop = m_pFirst+n+1;
121 if (m_pEnd == m_pFirst)
return *(m_pStop-1);
122 else return *(m_pEnd-1);
128 if (m_pEnd == m_pFirst)
return *(m_pStop-1);
129 else return *(m_pEnd-1);
134 return (m_pEnd >= m_pStart) ?
135 (INDEX)(m_pEnd - m_pStart) :
136 (INDEX)((m_pEnd-m_pFirst)+(m_pStop-
m_pStart));
149 (h == m_pStop-m_pFirst-1) :
168 m_pStart = Q.m_pStart;
171 m_pFirst = Q.m_pFirst;
172 Q.m_pStart = Q.m_pEnd = Q.m_pFirst = Q.m_pStop =
nullptr;
181 if (m_pEnd == m_pStop) m_pEnd =
m_pFirst;
189 if (m_pStart == m_pStop) m_pStart =
m_pFirst;
197 void print(ostream &os,
char delim =
' ')
const 199 for (
const E *pX = m_pStart; pX !=
m_pEnd; ) {
200 if (pX != m_pStart) os << delim;
209 m_pEnd = m_pStart = m_pFirst =
new E[n];
212 m_pStop = m_pStart + n;
222 template<
class E,
class INDEX>
223 ostream &operator<<(ostream &os, const BoundedQueue<E,INDEX> &Q)
const E & bottom() const
Returns back element.
INDEX size() const
Returns current size of the queue.
void init()
Reinitializes the bounded queue to a non-valid bounded queue.
#define OGDF_THROW(CLASS)
Replacement for throw.
BoundedQueue()
Pointer to first element of total array.
E * m_pStop
Pointer to one past last element of current sequence.
const E & top() const
Returns front element.
~BoundedQueue()
Destruction.
void init(INDEX n)
Reinitializes the bounded queue to a bounded queue for at most n elements.
void append(const E &x)
Adds x at the end of queue.
void clear()
Makes the queue empty.
E * m_pEnd
Pointer to first element of current sequence.
Definition of exception classes.
void print(ostream &os, char delim=' ') const
Prints the queue to output stream os with the seperator delim.
E * m_pFirst
Pointer to one past last element of total array.
Exception thrown when not enough memory is available to execute an algorithm.
bool empty()
Returns true iff the queue is empty.
E & bottom()
Returns back element.
void copy(const BoundedQueue< E > &Q)
BoundedQueue< E > & operator=(BoundedQueue< E > &&Q)
Assignment operator (move semantics).
BoundedQueue(BoundedQueue< E > &&Q)
Constructs a bounded queue containing the elements of Q (move semantics).
INDEX capacity() const
Returns the capacity of the bounded queue.
BoundedQueue(INDEX n)
Constructs an empty bounded queue for at most n elements.
bool full()
Returns true iff the queue is full.
BoundedQueue< E > & operator=(const BoundedQueue< E > &Q)
Assignment operator.
The namespace for all OGDF objects.
E & top()
Returns front element.
BoundedQueue(const BoundedQueue< E > &Q)
Constructs a bounded queue that is a copy of Q.
The parameterized class BoundedQueue implements queues with bounded size.
#define OGDF_ASSERT(expr)
Assert condition expr. See doc/build.md for more information.
E pop()
Removes front element and returns it.