Warning, file /office/calligra/libs/main/KoFilterVertex.cpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 /* This file is part of the Calligra libraries 0002 Copyright (C) 2001 Werner Trobin <trobin@kde.org> 0003 0004 This library is free software; you can redistribute it and/or 0005 modify it under the terms of the GNU Library General Public 0006 License as published by the Free Software Foundation; either 0007 version 2 of the License, or (at your option) any later version. 0008 0009 This library is distributed in the hope that it will be useful, 0010 but WITHOUT ANY WARRANTY; without even the implied warranty of 0011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0012 Library General Public License for more details. 0013 0014 You should have received a copy of the GNU Library General Public License 0015 along with this library; see the file COPYING.LIB. If not, write to 0016 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 0017 Boston, MA 02110-1301, USA. 0018 */ 0019 #include "KoFilterVertex.h" 0020 #include <limits.h> // UINT_MAX 0021 #include "KoFilterEdge.h" 0022 0023 namespace CalligraFilter { 0024 0025 Vertex::Vertex(const QByteArray& mimeType) 0026 : m_predecessor(0) 0027 , m_mimeType(mimeType) 0028 , m_weight(UINT_MAX) 0029 , m_index(-1) 0030 , d(0) 0031 { 0032 } 0033 0034 Vertex::~Vertex() 0035 { 0036 qDeleteAll(m_edges); 0037 } 0038 0039 bool Vertex::setKey(unsigned int key) 0040 { 0041 if (m_weight > key) { 0042 m_weight = key; 0043 return true; 0044 } 0045 return false; 0046 } 0047 0048 void Vertex::reset() 0049 { 0050 m_weight = UINT_MAX; 0051 m_predecessor = 0; 0052 } 0053 0054 void Vertex::addEdge(Edge* edge) 0055 { 0056 if (!edge || edge->weight() == 0) 0057 return; 0058 m_edges.append(edge); 0059 } 0060 0061 const Edge* Vertex::findEdge(const Vertex* vertex) const 0062 { 0063 if (!vertex) 0064 return 0; 0065 const Edge* edge = 0; 0066 foreach(Edge* e, m_edges) { 0067 if (e->vertex() == vertex && 0068 (!edge || e->weight() < edge->weight())) { 0069 edge = e; 0070 } 0071 } 0072 return edge; 0073 } 0074 0075 void Vertex::relaxVertices(PriorityQueue<Vertex>& queue) 0076 { 0077 foreach(Edge* e, m_edges) { 0078 e->relax(this, queue); 0079 } 0080 } 0081 0082 void Vertex::dump(const QByteArray& indent) const 0083 { 0084 #ifdef NDEBUG 0085 Q_UNUSED(indent) 0086 #else 0087 debugFilter << indent << "Vertex:" << m_mimeType << " (" << m_weight << "):"; 0088 const QByteArray i(indent + " "); 0089 foreach(Edge* edge, m_edges) { 0090 edge->dump(i); 0091 } 0092 #endif 0093 } 0094 0095 }