56 #include <QtCore/QHash> 57 #include <QtCore/QQueue> 58 #include <QtCore/QString> 59 #include <QtCore/QDebug> 65 template <
typename Vertex,
typename EdgeData>
90 inline Vertex *
from()
const {
94 inline Vertex *
to()
const {
143 EdgeData *
edgeData(Vertex* first, Vertex* second) {
145 return row ? row->
value(second) : 0;
151 #if defined(QT_DEBUG) && 0 152 qDebug(
"Graph::createEdge(): %s",
154 .arg(first->toString()).arg(second->toString())));
168 #if defined(QT_DEBUG) && 0 169 qDebug(
"Graph::removeEdge(): %s",
171 .arg(first->toString()).arg(second->toString())));
176 if (data)
delete data;
181 #if defined(QT_DEBUG) && 0 182 qDebug(
"Graph::takeEdge(): %s",
184 .arg(first->toString()).arg(second->toString())));
209 return setOfVertices;
216 Vertex *
to =
it.to();
225 #if defined(QT_DEBUG) 234 for (
int i = 0; i < adjacents.
count(); ++i) {
235 Vertex *v1 = adjacents.
at(i);
237 bool forward = data->from == v;
239 edges +=
QString::fromAscii(
"\"%1\"->\"%2\" [label=\"[%3,%4,%5,%6,%7]\" color=\"#000000\"] \n")
243 .
arg(data->minPrefSize)
245 .
arg(data->maxPrefSize)
260 if (!adjacentToFirst) {
264 adjacentToFirst->
insert(to, data);
272 adjacentToFirst->
remove(to);
273 if (adjacentToFirst->
isEmpty()) {
276 delete adjacentToFirst;
The QHash::const_iterator class provides an STL-style const iterator for QHash and QMultiHash...
#define QT_END_NAMESPACE
This macro expands to.
static QString fromAscii(const char *, int size=-1)
Returns a QString initialized with the first size characters from the string str. ...
int remove(const Key &key)
Removes all the items that have the key from the hash.
#define it(className, varName)
QList< QPair< Vertex *, Vertex * > > connections() const
QSet< Vertex * > vertices() const
const_iterator & operator++()
int count(const T &t) const
Returns the number of occurrences of value in the list.
The QString class provides a Unicode character string.
The QHash class is a template class that provides a hash-table-based dictionary.
EdgeData * edgeData(Vertex *first, Vertex *second)
void createEdge(Vertex *first, Vertex *second, EdgeData *data)
bool operator!=(const const_iterator &o) const
const T value(const Key &key) const
Returns the value associated with the key.
iterator insert(const Key &key, const T &value)
Inserts a new item with the key and a value of value.
Q_CORE_EXPORT void qDebug(const char *,...)
Q_TYPENAME QHash< Vertex *, QHash< Vertex *, EdgeData * > *>::const_iterator row
void append(const T &t)
Inserts value at the end of the list.
#define QT_BEGIN_NAMESPACE
This macro expands to.
QHash< Vertex *, QHash< Vertex *, EdgeData * > * > m_graph
QList< Vertex * > adjacentVertices(Vertex *vertex) const
const T & at(int i) const
Returns the item at index position i in the list.
bool isEmpty() const
Returns true if the hash contains no items; otherwise returns false.
Q_CORE_EXPORT void qWarning(const char *,...)
const_iterator insert(const T &value)
static const char * data(const QByteArray &arr)
const_iterator constBegin() const
Returns a const STL-style iterator pointing to the first item in the hash.
const_iterator constEnd() const
Returns a const STL-style iterator pointing to the imaginary item after the last item in the hash...
const_iterator & operator=(const const_iterator &o) const
QString arg(qlonglong a, int fieldwidth=0, int base=10, const QChar &fillChar=QLatin1Char(' ')) const Q_REQUIRED_RESULT
iterator end()
Returns an STL-style iterator pointing to the imaginary item after the last item in the hash...
const Key key(const T &value) const
Returns the first key mapped to value.
Q_OUTOFLINE_TEMPLATE QPair< T1, T2 > qMakePair(const T1 &x, const T2 &y)
const_iterator(const Graph *graph, bool begin)
EdgeData * takeEdge(Vertex *first, Vertex *second)
void removeDirectedEdge(Vertex *from, Vertex *to)
void removeEdge(Vertex *first, Vertex *second)
#define qPrintable(string)
QList< Key > keys() const
Returns a list containing all the keys in the hash, in an arbitrary order.
Q_TYPENAME QHash< Vertex *, EdgeData * >::const_iterator column
bool operator==(const const_iterator &o) const
const_iterator constBegin() const
The QList class is a template class that provides lists.
void createDirectedEdge(Vertex *from, Vertex *to, EdgeData *data)
const_iterator constEnd() const