Changeset 1829:183b4cbf9733 in lemon-0.x
- Timestamp:
- 11/23/05 16:42:36 (19 years ago)
- Branch:
- default
- Phase:
- public
- Convert:
- svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@2379
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
lemon/graph_utils.h
r1811 r1829 111 111 112 112 template <typename Graph> 113 inline 114 typename enable_if<typename Graph::NodeNumTag, int>::type 113 inline typename enable_if<typename Graph::NodeNumTag, int>::type 115 114 _countNodes(const Graph &g) { 116 115 return g.nodeNum(); … … 138 137 139 138 template <typename Graph> 140 inline 141 typename enable_if<typename Graph::EdgeNumTag, int>::type 139 inline typename enable_if<typename Graph::EdgeNumTag, int>::type 142 140 _countEdges(const Graph &g) { 143 141 return g.edgeNum(); … … 421 419 ConUndirEdgeIt& operator++() { 422 420 Parent::operator=(findUndirEdge(graph, graph.source(*this), 423 graph.target(*this), *this));421 graph.target(*this), *this)); 424 422 return *this; 425 423 } … … 939 937 protected: 940 938 941 /// \brief Add a new key to the map.942 ///943 /// Add a new key to the map. It is called by the944 /// \c AlterationNotifier.945 virtual void add(const Key& key) {946 Map::add(key);947 }948 949 939 /// \brief Erase the key from the map. 950 940 /// … … 958 948 } 959 949 Map::erase(key); 950 } 951 952 /// \brief Erase more keys from the map. 953 /// 954 /// Erase more keys from the map. It is called by the 955 /// \c AlterationNotifier. 956 virtual void erase(const std::vector<Key>& keys) { 957 for (int i = 0; i < (int)keys.size(); ++i) { 958 Value val = Map::operator[](keys[i]); 959 typename Container::iterator it = invMap.find(val); 960 if (it != invMap.end() && it->second == keys[i]) { 961 invMap.erase(it); 962 } 963 } 964 Map::erase(keys); 960 965 } 961 966 … … 1071 1076 } 1072 1077 1078 /// \brief Add more new keys to the map. 1079 /// 1080 /// Add more new keys to the map. It is called by the 1081 /// \c AlterationNotifier. 1082 virtual void add(const std::vector<Item>& items) { 1083 Map::add(items); 1084 for (int i = 0; i < (int)items.size(); ++i) { 1085 Map::set(items[i], invMap.size()); 1086 invMap.push_back(items[i]); 1087 } 1088 } 1089 1073 1090 /// \brief Erase the key from the map. 1074 1091 /// 1075 /// Erase the key tothe map. It is called by the1092 /// Erase the key from the map. It is called by the 1076 1093 /// \c AlterationNotifier. 1077 1094 virtual void erase(const Item& item) { … … 1080 1097 invMap.pop_back(); 1081 1098 Map::erase(item); 1099 } 1100 1101 /// \brief Erase more keys from the map. 1102 /// 1103 /// Erase more keys from the map. It is called by the 1104 /// \c AlterationNotifier. 1105 virtual void erase(const std::vector<Item>& items) { 1106 for (int i = 0; i < (int)items.size(); ++i) { 1107 Map::set(invMap.back(), Map::operator[](items[i])); 1108 invMap[Map::operator[](items[i])] = invMap.back(); 1109 invMap.pop_back(); 1110 } 1111 Map::erase(items); 1082 1112 } 1083 1113 … … 1380 1410 /// \warning Besides addNode() and addEdge(), a graph structure may provide 1381 1411 /// alternative ways to modify the graph. The correct behavior of InDegMap 1382 /// is not guarantied if these additional feature as are used. For example1383 /// the fun stions \ref ListGraph::changeSource() "changeSource()",1412 /// is not guarantied if these additional features are used. For example 1413 /// the functions \ref ListGraph::changeSource() "changeSource()", 1384 1414 /// \ref ListGraph::changeTarget() "changeTarget()" and 1385 1415 /// \ref ListGraph::reverseEdge() "reverseEdge()" … … 1410 1440 AutoNodeMap(const Graph& graph) : Parent(graph, 0) {} 1411 1441 1412 v oid add(const Key& key) {1442 virtual void add(const Key& key) { 1413 1443 Parent::add(key); 1414 1444 Parent::set(key, 0); 1445 } 1446 virtual void add(const std::vector<Key>& keys) { 1447 Parent::add(keys); 1448 for (int i = 0; i < (int)keys.size(); ++i) { 1449 Parent::set(keys[i], 0); 1450 } 1415 1451 } 1416 1452 }; … … 1452 1488 } 1453 1489 1454 virtual void signalChange(const Edge& edge) {1455 erase(edge);1456 }1457 1458 virtual void commitChange(const Edge& edge) {1459 add(edge);1460 }1461 1462 1490 virtual void build() { 1463 1491 for(typename _Graph::NodeIt it(graph); it != INVALID; ++it) { … … 1486 1514 /// \warning Besides addNode() and addEdge(), a graph structure may provide 1487 1515 /// alternative ways to modify the graph. The correct behavior of OutDegMap 1488 /// is not guarantied if these additional feature as are used. For example1489 /// the fun stions \ref ListGraph::changeSource() "changeSource()",1516 /// is not guarantied if these additional features are used. For example 1517 /// the functions \ref ListGraph::changeSource() "changeSource()", 1490 1518 /// \ref ListGraph::changeTarget() "changeTarget()" and 1491 1519 /// \ref ListGraph::reverseEdge() "reverseEdge()" … … 1516 1544 AutoNodeMap(const Graph& graph) : Parent(graph, 0) {} 1517 1545 1518 v oid add(const Key& key) {1546 virtual void add(const Key& key) { 1519 1547 Parent::add(key); 1520 1548 Parent::set(key, 0); 1549 } 1550 virtual void add(const std::vector<Key>& keys) { 1551 Parent::add(keys); 1552 for (int i = 0; i < (int)keys.size(); ++i) { 1553 Parent::set(keys[i], 0); 1554 } 1521 1555 } 1522 1556 }; … … 1558 1592 } 1559 1593 1560 virtual void signalChange(const Edge& edge) {1561 erase(edge);1562 }1563 1564 virtual void commitChange(const Edge& edge) {1565 add(edge);1566 }1567 1568 1569 1594 virtual void build() { 1570 1595 for(typename _Graph::NodeIt it(graph); it != INVALID; ++it) {
Note: See TracChangeset
for help on using the changeset viewer.