0
4
0
| ... | ... |
@@ -478,150 +478,150 @@ |
| 478 | 478 |
|
| 479 | 479 |
IncEdgeIt(const Graph& _graph, const Node &n) : graph(&_graph) {
|
| 480 | 480 |
_graph.firstInc(*this, direction, n); |
| 481 | 481 |
} |
| 482 | 482 |
|
| 483 | 483 |
IncEdgeIt(const Graph& _graph, const Edge &ue, const Node &n) |
| 484 | 484 |
: graph(&_graph), Edge(ue) {
|
| 485 | 485 |
direction = (_graph.source(ue) == n); |
| 486 | 486 |
} |
| 487 | 487 |
|
| 488 | 488 |
IncEdgeIt& operator++() {
|
| 489 | 489 |
graph->nextInc(*this, direction); |
| 490 | 490 |
return *this; |
| 491 | 491 |
} |
| 492 | 492 |
}; |
| 493 | 493 |
|
| 494 | 494 |
// \brief Base node of the iterator |
| 495 | 495 |
// |
| 496 | 496 |
// Returns the base node (ie. the source in this case) of the iterator |
| 497 | 497 |
Node baseNode(const OutArcIt &e) const {
|
| 498 | 498 |
return Parent::source(static_cast<const Arc&>(e)); |
| 499 | 499 |
} |
| 500 | 500 |
// \brief Running node of the iterator |
| 501 | 501 |
// |
| 502 | 502 |
// Returns the running node (ie. the target in this case) of the |
| 503 | 503 |
// iterator |
| 504 | 504 |
Node runningNode(const OutArcIt &e) const {
|
| 505 | 505 |
return Parent::target(static_cast<const Arc&>(e)); |
| 506 | 506 |
} |
| 507 | 507 |
|
| 508 | 508 |
// \brief Base node of the iterator |
| 509 | 509 |
// |
| 510 | 510 |
// Returns the base node (ie. the target in this case) of the iterator |
| 511 | 511 |
Node baseNode(const InArcIt &e) const {
|
| 512 | 512 |
return Parent::target(static_cast<const Arc&>(e)); |
| 513 | 513 |
} |
| 514 | 514 |
// \brief Running node of the iterator |
| 515 | 515 |
// |
| 516 | 516 |
// Returns the running node (ie. the source in this case) of the |
| 517 | 517 |
// iterator |
| 518 | 518 |
Node runningNode(const InArcIt &e) const {
|
| 519 | 519 |
return Parent::source(static_cast<const Arc&>(e)); |
| 520 | 520 |
} |
| 521 | 521 |
|
| 522 | 522 |
// Base node of the iterator |
| 523 | 523 |
// |
| 524 | 524 |
// Returns the base node of the iterator |
| 525 | 525 |
Node baseNode(const IncEdgeIt &e) const {
|
| 526 | 526 |
return e.direction ? u(e) : v(e); |
| 527 | 527 |
} |
| 528 | 528 |
// Running node of the iterator |
| 529 | 529 |
// |
| 530 | 530 |
// Returns the running node of the iterator |
| 531 | 531 |
Node runningNode(const IncEdgeIt &e) const {
|
| 532 | 532 |
return e.direction ? v(e) : u(e); |
| 533 | 533 |
} |
| 534 | 534 |
|
| 535 | 535 |
|
| 536 | 536 |
template <typename _Value> |
| 537 | 537 |
class ArcMap |
| 538 | 538 |
: public MapExtender<DefaultMap<Graph, Arc, _Value> > {
|
| 539 | 539 |
typedef MapExtender<DefaultMap<Graph, Arc, _Value> > Parent; |
| 540 | 540 |
|
| 541 | 541 |
public: |
| 542 |
ArcMap(const Graph& _g) |
|
| 542 |
explicit ArcMap(const Graph& _g) |
|
| 543 | 543 |
: Parent(_g) {}
|
| 544 | 544 |
ArcMap(const Graph& _g, const _Value& _v) |
| 545 | 545 |
: Parent(_g, _v) {}
|
| 546 | 546 |
|
| 547 | 547 |
ArcMap& operator=(const ArcMap& cmap) {
|
| 548 | 548 |
return operator=<ArcMap>(cmap); |
| 549 | 549 |
} |
| 550 | 550 |
|
| 551 | 551 |
template <typename CMap> |
| 552 | 552 |
ArcMap& operator=(const CMap& cmap) {
|
| 553 | 553 |
Parent::operator=(cmap); |
| 554 | 554 |
return *this; |
| 555 | 555 |
} |
| 556 | 556 |
|
| 557 | 557 |
}; |
| 558 | 558 |
|
| 559 | 559 |
|
| 560 | 560 |
template <typename _Value> |
| 561 | 561 |
class EdgeMap |
| 562 | 562 |
: public MapExtender<DefaultMap<Graph, Edge, _Value> > {
|
| 563 | 563 |
typedef MapExtender<DefaultMap<Graph, Edge, _Value> > Parent; |
| 564 | 564 |
|
| 565 | 565 |
public: |
| 566 |
EdgeMap(const Graph& _g) |
|
| 566 |
explicit EdgeMap(const Graph& _g) |
|
| 567 | 567 |
: Parent(_g) {}
|
| 568 | 568 |
|
| 569 | 569 |
EdgeMap(const Graph& _g, const _Value& _v) |
| 570 | 570 |
: Parent(_g, _v) {}
|
| 571 | 571 |
|
| 572 | 572 |
EdgeMap& operator=(const EdgeMap& cmap) {
|
| 573 | 573 |
return operator=<EdgeMap>(cmap); |
| 574 | 574 |
} |
| 575 | 575 |
|
| 576 | 576 |
template <typename CMap> |
| 577 | 577 |
EdgeMap& operator=(const CMap& cmap) {
|
| 578 | 578 |
Parent::operator=(cmap); |
| 579 | 579 |
return *this; |
| 580 | 580 |
} |
| 581 | 581 |
|
| 582 | 582 |
}; |
| 583 | 583 |
|
| 584 | 584 |
|
| 585 | 585 |
// Alteration extension |
| 586 | 586 |
|
| 587 | 587 |
Edge addEdge(const Node& from, const Node& to) {
|
| 588 | 588 |
Edge edge = Parent::addEdge(from, to); |
| 589 | 589 |
notifier(Edge()).add(edge); |
| 590 | 590 |
std::vector<Arc> arcs; |
| 591 | 591 |
arcs.push_back(Parent::direct(edge, true)); |
| 592 | 592 |
arcs.push_back(Parent::direct(edge, false)); |
| 593 | 593 |
notifier(Arc()).add(arcs); |
| 594 | 594 |
return edge; |
| 595 | 595 |
} |
| 596 | 596 |
|
| 597 | 597 |
void clear() {
|
| 598 | 598 |
notifier(Arc()).clear(); |
| 599 | 599 |
notifier(Edge()).clear(); |
| 600 | 600 |
Parent::clear(); |
| 601 | 601 |
} |
| 602 | 602 |
|
| 603 | 603 |
void erase(const Edge& edge) {
|
| 604 | 604 |
std::vector<Arc> arcs; |
| 605 | 605 |
arcs.push_back(Parent::direct(edge, true)); |
| 606 | 606 |
arcs.push_back(Parent::direct(edge, false)); |
| 607 | 607 |
notifier(Arc()).erase(arcs); |
| 608 | 608 |
notifier(Edge()).erase(edge); |
| 609 | 609 |
Parent::erase(edge); |
| 610 | 610 |
} |
| 611 | 611 |
|
| 612 | 612 |
|
| 613 | 613 |
EdgeSetExtender() {
|
| 614 | 614 |
arc_notifier.setContainer(*this); |
| 615 | 615 |
edge_notifier.setContainer(*this); |
| 616 | 616 |
} |
| 617 | 617 |
|
| 618 | 618 |
~EdgeSetExtender() {
|
| 619 | 619 |
edge_notifier.clear(); |
| 620 | 620 |
arc_notifier.clear(); |
| 621 | 621 |
} |
| 622 | 622 |
|
| 623 | 623 |
}; |
| 624 | 624 |
|
| 625 | 625 |
} |
| 626 | 626 |
|
| 627 | 627 |
#endif |
| ... | ... |
@@ -543,177 +543,177 @@ |
| 543 | 543 |
IncEdgeIt(const Graph& graph, const Node &node) : _graph(&graph) {
|
| 544 | 544 |
_graph->firstInc(*this, _direction, node); |
| 545 | 545 |
} |
| 546 | 546 |
|
| 547 | 547 |
IncEdgeIt(const Graph& graph, const Edge &edge, const Node &node) |
| 548 | 548 |
: _graph(&graph), Edge(edge) {
|
| 549 | 549 |
_direction = (_graph->source(edge) == node); |
| 550 | 550 |
} |
| 551 | 551 |
|
| 552 | 552 |
IncEdgeIt& operator++() {
|
| 553 | 553 |
_graph->nextInc(*this, _direction); |
| 554 | 554 |
return *this; |
| 555 | 555 |
} |
| 556 | 556 |
}; |
| 557 | 557 |
|
| 558 | 558 |
// \brief Base node of the iterator |
| 559 | 559 |
// |
| 560 | 560 |
// Returns the base node (ie. the source in this case) of the iterator |
| 561 | 561 |
Node baseNode(const OutArcIt &arc) const {
|
| 562 | 562 |
return Parent::source(static_cast<const Arc&>(arc)); |
| 563 | 563 |
} |
| 564 | 564 |
// \brief Running node of the iterator |
| 565 | 565 |
// |
| 566 | 566 |
// Returns the running node (ie. the target in this case) of the |
| 567 | 567 |
// iterator |
| 568 | 568 |
Node runningNode(const OutArcIt &arc) const {
|
| 569 | 569 |
return Parent::target(static_cast<const Arc&>(arc)); |
| 570 | 570 |
} |
| 571 | 571 |
|
| 572 | 572 |
// \brief Base node of the iterator |
| 573 | 573 |
// |
| 574 | 574 |
// Returns the base node (ie. the target in this case) of the iterator |
| 575 | 575 |
Node baseNode(const InArcIt &arc) const {
|
| 576 | 576 |
return Parent::target(static_cast<const Arc&>(arc)); |
| 577 | 577 |
} |
| 578 | 578 |
// \brief Running node of the iterator |
| 579 | 579 |
// |
| 580 | 580 |
// Returns the running node (ie. the source in this case) of the |
| 581 | 581 |
// iterator |
| 582 | 582 |
Node runningNode(const InArcIt &arc) const {
|
| 583 | 583 |
return Parent::source(static_cast<const Arc&>(arc)); |
| 584 | 584 |
} |
| 585 | 585 |
|
| 586 | 586 |
// Base node of the iterator |
| 587 | 587 |
// |
| 588 | 588 |
// Returns the base node of the iterator |
| 589 | 589 |
Node baseNode(const IncEdgeIt &edge) const {
|
| 590 | 590 |
return edge._direction ? u(edge) : v(edge); |
| 591 | 591 |
} |
| 592 | 592 |
// Running node of the iterator |
| 593 | 593 |
// |
| 594 | 594 |
// Returns the running node of the iterator |
| 595 | 595 |
Node runningNode(const IncEdgeIt &edge) const {
|
| 596 | 596 |
return edge._direction ? v(edge) : u(edge); |
| 597 | 597 |
} |
| 598 | 598 |
|
| 599 | 599 |
// Mappable extension |
| 600 | 600 |
|
| 601 | 601 |
template <typename _Value> |
| 602 | 602 |
class NodeMap |
| 603 | 603 |
: public MapExtender<DefaultMap<Graph, Node, _Value> > {
|
| 604 | 604 |
typedef MapExtender<DefaultMap<Graph, Node, _Value> > Parent; |
| 605 | 605 |
|
| 606 | 606 |
public: |
| 607 |
NodeMap(const Graph& graph) |
|
| 607 |
explicit NodeMap(const Graph& graph) |
|
| 608 | 608 |
: Parent(graph) {}
|
| 609 | 609 |
NodeMap(const Graph& graph, const _Value& value) |
| 610 | 610 |
: Parent(graph, value) {}
|
| 611 | 611 |
|
| 612 | 612 |
private: |
| 613 | 613 |
NodeMap& operator=(const NodeMap& cmap) {
|
| 614 | 614 |
return operator=<NodeMap>(cmap); |
| 615 | 615 |
} |
| 616 | 616 |
|
| 617 | 617 |
template <typename CMap> |
| 618 | 618 |
NodeMap& operator=(const CMap& cmap) {
|
| 619 | 619 |
Parent::operator=(cmap); |
| 620 | 620 |
return *this; |
| 621 | 621 |
} |
| 622 | 622 |
|
| 623 | 623 |
}; |
| 624 | 624 |
|
| 625 | 625 |
template <typename _Value> |
| 626 | 626 |
class ArcMap |
| 627 | 627 |
: public MapExtender<DefaultMap<Graph, Arc, _Value> > {
|
| 628 | 628 |
typedef MapExtender<DefaultMap<Graph, Arc, _Value> > Parent; |
| 629 | 629 |
|
| 630 | 630 |
public: |
| 631 |
ArcMap(const Graph& graph) |
|
| 631 |
explicit ArcMap(const Graph& graph) |
|
| 632 | 632 |
: Parent(graph) {}
|
| 633 | 633 |
ArcMap(const Graph& graph, const _Value& value) |
| 634 | 634 |
: Parent(graph, value) {}
|
| 635 | 635 |
|
| 636 | 636 |
private: |
| 637 | 637 |
ArcMap& operator=(const ArcMap& cmap) {
|
| 638 | 638 |
return operator=<ArcMap>(cmap); |
| 639 | 639 |
} |
| 640 | 640 |
|
| 641 | 641 |
template <typename CMap> |
| 642 | 642 |
ArcMap& operator=(const CMap& cmap) {
|
| 643 | 643 |
Parent::operator=(cmap); |
| 644 | 644 |
return *this; |
| 645 | 645 |
} |
| 646 | 646 |
}; |
| 647 | 647 |
|
| 648 | 648 |
|
| 649 | 649 |
template <typename _Value> |
| 650 | 650 |
class EdgeMap |
| 651 | 651 |
: public MapExtender<DefaultMap<Graph, Edge, _Value> > {
|
| 652 | 652 |
typedef MapExtender<DefaultMap<Graph, Edge, _Value> > Parent; |
| 653 | 653 |
|
| 654 | 654 |
public: |
| 655 |
EdgeMap(const Graph& graph) |
|
| 655 |
explicit EdgeMap(const Graph& graph) |
|
| 656 | 656 |
: Parent(graph) {}
|
| 657 | 657 |
|
| 658 | 658 |
EdgeMap(const Graph& graph, const _Value& value) |
| 659 | 659 |
: Parent(graph, value) {}
|
| 660 | 660 |
|
| 661 | 661 |
private: |
| 662 | 662 |
EdgeMap& operator=(const EdgeMap& cmap) {
|
| 663 | 663 |
return operator=<EdgeMap>(cmap); |
| 664 | 664 |
} |
| 665 | 665 |
|
| 666 | 666 |
template <typename CMap> |
| 667 | 667 |
EdgeMap& operator=(const CMap& cmap) {
|
| 668 | 668 |
Parent::operator=(cmap); |
| 669 | 669 |
return *this; |
| 670 | 670 |
} |
| 671 | 671 |
|
| 672 | 672 |
}; |
| 673 | 673 |
|
| 674 | 674 |
// Alteration extension |
| 675 | 675 |
|
| 676 | 676 |
Node addNode() {
|
| 677 | 677 |
Node node = Parent::addNode(); |
| 678 | 678 |
notifier(Node()).add(node); |
| 679 | 679 |
return node; |
| 680 | 680 |
} |
| 681 | 681 |
|
| 682 | 682 |
Edge addEdge(const Node& from, const Node& to) {
|
| 683 | 683 |
Edge edge = Parent::addEdge(from, to); |
| 684 | 684 |
notifier(Edge()).add(edge); |
| 685 | 685 |
std::vector<Arc> ev; |
| 686 | 686 |
ev.push_back(Parent::direct(edge, true)); |
| 687 | 687 |
ev.push_back(Parent::direct(edge, false)); |
| 688 | 688 |
notifier(Arc()).add(ev); |
| 689 | 689 |
return edge; |
| 690 | 690 |
} |
| 691 | 691 |
|
| 692 | 692 |
void clear() {
|
| 693 | 693 |
notifier(Arc()).clear(); |
| 694 | 694 |
notifier(Edge()).clear(); |
| 695 | 695 |
notifier(Node()).clear(); |
| 696 | 696 |
Parent::clear(); |
| 697 | 697 |
} |
| 698 | 698 |
|
| 699 | 699 |
template <typename Graph, typename NodeRefMap, typename EdgeRefMap> |
| 700 | 700 |
void build(const Graph& graph, NodeRefMap& nodeRef, |
| 701 | 701 |
EdgeRefMap& edgeRef) {
|
| 702 | 702 |
Parent::build(graph, nodeRef, edgeRef); |
| 703 | 703 |
notifier(Node()).build(); |
| 704 | 704 |
notifier(Edge()).build(); |
| 705 | 705 |
notifier(Arc()).build(); |
| 706 | 706 |
} |
| 707 | 707 |
|
| 708 | 708 |
void erase(const Node& node) {
|
| 709 | 709 |
Arc arc; |
| 710 | 710 |
Parent::firstOut(arc, node); |
| 711 | 711 |
while (arc != INVALID ) {
|
| 712 | 712 |
erase(arc); |
| 713 | 713 |
Parent::firstOut(arc, node); |
| 714 | 714 |
} |
| 715 | 715 |
|
| 716 | 716 |
Parent::firstIn(arc, node); |
| 717 | 717 |
while (arc != INVALID ) {
|
| 718 | 718 |
erase(arc); |
| 719 | 719 |
Parent::firstIn(arc, node); |
| ... | ... |
@@ -1841,312 +1841,331 @@ |
| 1841 | 1841 |
typedef GR Digraph; |
| 1842 | 1842 |
/// The key type of IdMap (\c Node, \c Arc or \c Edge). |
| 1843 | 1843 |
typedef K Item; |
| 1844 | 1844 |
/// The key type of IdMap (\c Node, \c Arc or \c Edge). |
| 1845 | 1845 |
typedef K Key; |
| 1846 | 1846 |
/// The value type of IdMap. |
| 1847 | 1847 |
typedef int Value; |
| 1848 | 1848 |
|
| 1849 | 1849 |
/// \brief Constructor. |
| 1850 | 1850 |
/// |
| 1851 | 1851 |
/// Constructor of the map. |
| 1852 | 1852 |
explicit IdMap(const Graph& graph) : _graph(&graph) {}
|
| 1853 | 1853 |
|
| 1854 | 1854 |
/// \brief Gives back the \e id of the item. |
| 1855 | 1855 |
/// |
| 1856 | 1856 |
/// Gives back the immutable and unique \e id of the item. |
| 1857 | 1857 |
int operator[](const Item& item) const { return _graph->id(item);}
|
| 1858 | 1858 |
|
| 1859 | 1859 |
/// \brief Gives back the \e item by its id. |
| 1860 | 1860 |
/// |
| 1861 | 1861 |
/// Gives back the \e item by its id. |
| 1862 | 1862 |
Item operator()(int id) { return _graph->fromId(id, Item()); }
|
| 1863 | 1863 |
|
| 1864 | 1864 |
private: |
| 1865 | 1865 |
const Graph* _graph; |
| 1866 | 1866 |
|
| 1867 | 1867 |
public: |
| 1868 | 1868 |
|
| 1869 | 1869 |
/// \brief This class represents the inverse of its owner (IdMap). |
| 1870 | 1870 |
/// |
| 1871 | 1871 |
/// This class represents the inverse of its owner (IdMap). |
| 1872 | 1872 |
/// \see inverse() |
| 1873 | 1873 |
class InverseMap {
|
| 1874 | 1874 |
public: |
| 1875 | 1875 |
|
| 1876 | 1876 |
/// \brief Constructor. |
| 1877 | 1877 |
/// |
| 1878 | 1878 |
/// Constructor for creating an id-to-item map. |
| 1879 | 1879 |
explicit InverseMap(const Graph& graph) : _graph(&graph) {}
|
| 1880 | 1880 |
|
| 1881 | 1881 |
/// \brief Constructor. |
| 1882 | 1882 |
/// |
| 1883 | 1883 |
/// Constructor for creating an id-to-item map. |
| 1884 | 1884 |
explicit InverseMap(const IdMap& map) : _graph(map._graph) {}
|
| 1885 | 1885 |
|
| 1886 | 1886 |
/// \brief Gives back the given item from its id. |
| 1887 | 1887 |
/// |
| 1888 | 1888 |
/// Gives back the given item from its id. |
| 1889 | 1889 |
Item operator[](int id) const { return _graph->fromId(id, Item());}
|
| 1890 | 1890 |
|
| 1891 | 1891 |
private: |
| 1892 | 1892 |
const Graph* _graph; |
| 1893 | 1893 |
}; |
| 1894 | 1894 |
|
| 1895 | 1895 |
/// \brief Gives back the inverse of the map. |
| 1896 | 1896 |
/// |
| 1897 | 1897 |
/// Gives back the inverse of the IdMap. |
| 1898 | 1898 |
InverseMap inverse() const { return InverseMap(*_graph);}
|
| 1899 | 1899 |
}; |
| 1900 | 1900 |
|
| 1901 | 1901 |
|
| 1902 | 1902 |
/// \brief General cross reference graph map type. |
| 1903 | 1903 |
|
| 1904 | 1904 |
/// This class provides simple invertable graph maps. |
| 1905 |
/// It wraps an arbitrary \ref concepts::ReadWriteMap "ReadWriteMap" |
|
| 1906 |
/// and if a key is set to a new value then store it |
|
| 1907 |
/// in the inverse map. |
|
| 1908 |
/// |
|
| 1905 |
/// It wraps a standard graph map (\c NodeMap, \c ArcMap or \c EdgeMap) |
|
| 1906 |
/// and if a key is set to a new value, then stores it in the inverse map. |
|
| 1909 | 1907 |
/// The values of the map can be accessed |
| 1910 | 1908 |
/// with stl compatible forward iterator. |
| 1911 | 1909 |
/// |
| 1910 |
/// This type is not reference map, so it cannot be modified with |
|
| 1911 |
/// the subscript operator. |
|
| 1912 |
/// |
|
| 1912 | 1913 |
/// \tparam GR The graph type. |
| 1913 | 1914 |
/// \tparam K The key type of the map (\c GR::Node, \c GR::Arc or |
| 1914 | 1915 |
/// \c GR::Edge). |
| 1915 | 1916 |
/// \tparam V The value type of the map. |
| 1916 | 1917 |
/// |
| 1917 | 1918 |
/// \see IterableValueMap |
| 1918 | 1919 |
template <typename GR, typename K, typename V> |
| 1919 | 1920 |
class CrossRefMap |
| 1920 | 1921 |
: protected ItemSetTraits<GR, K>::template Map<V>::Type {
|
| 1921 | 1922 |
private: |
| 1922 | 1923 |
|
| 1923 | 1924 |
typedef typename ItemSetTraits<GR, K>:: |
| 1924 | 1925 |
template Map<V>::Type Map; |
| 1925 | 1926 |
|
| 1926 |
typedef std:: |
|
| 1927 |
typedef std::multimap<V, K> Container; |
|
| 1927 | 1928 |
Container _inv_map; |
| 1928 | 1929 |
|
| 1929 | 1930 |
public: |
| 1930 | 1931 |
|
| 1931 | 1932 |
/// The graph type of CrossRefMap. |
| 1932 | 1933 |
typedef GR Graph; |
| 1933 | 1934 |
typedef GR Digraph; |
| 1934 | 1935 |
/// The key type of CrossRefMap (\c Node, \c Arc or \c Edge). |
| 1935 | 1936 |
typedef K Item; |
| 1936 | 1937 |
/// The key type of CrossRefMap (\c Node, \c Arc or \c Edge). |
| 1937 | 1938 |
typedef K Key; |
| 1938 | 1939 |
/// The value type of CrossRefMap. |
| 1939 | 1940 |
typedef V Value; |
| 1940 | 1941 |
|
| 1941 | 1942 |
/// \brief Constructor. |
| 1942 | 1943 |
/// |
| 1943 | 1944 |
/// Construct a new CrossRefMap for the given graph. |
| 1944 | 1945 |
explicit CrossRefMap(const Graph& graph) : Map(graph) {}
|
| 1945 | 1946 |
|
| 1946 | 1947 |
/// \brief Forward iterator for values. |
| 1947 | 1948 |
/// |
| 1948 | 1949 |
/// This iterator is an stl compatible forward |
| 1949 | 1950 |
/// iterator on the values of the map. The values can |
| 1950 | 1951 |
/// be accessed in the <tt>[beginValue, endValue)</tt> range. |
| 1952 |
/// They are considered with multiplicity, so each value is |
|
| 1953 |
/// traversed for each item it is assigned to. |
|
| 1951 | 1954 |
class ValueIterator |
| 1952 | 1955 |
: public std::iterator<std::forward_iterator_tag, Value> {
|
| 1953 | 1956 |
friend class CrossRefMap; |
| 1954 | 1957 |
private: |
| 1955 | 1958 |
ValueIterator(typename Container::const_iterator _it) |
| 1956 | 1959 |
: it(_it) {}
|
| 1957 | 1960 |
public: |
| 1958 | 1961 |
|
| 1959 | 1962 |
ValueIterator() {}
|
| 1960 | 1963 |
|
| 1961 | 1964 |
ValueIterator& operator++() { ++it; return *this; }
|
| 1962 | 1965 |
ValueIterator operator++(int) {
|
| 1963 | 1966 |
ValueIterator tmp(*this); |
| 1964 | 1967 |
operator++(); |
| 1965 | 1968 |
return tmp; |
| 1966 | 1969 |
} |
| 1967 | 1970 |
|
| 1968 | 1971 |
const Value& operator*() const { return it->first; }
|
| 1969 | 1972 |
const Value* operator->() const { return &(it->first); }
|
| 1970 | 1973 |
|
| 1971 | 1974 |
bool operator==(ValueIterator jt) const { return it == jt.it; }
|
| 1972 | 1975 |
bool operator!=(ValueIterator jt) const { return it != jt.it; }
|
| 1973 | 1976 |
|
| 1974 | 1977 |
private: |
| 1975 | 1978 |
typename Container::const_iterator it; |
| 1976 | 1979 |
}; |
| 1977 | 1980 |
|
| 1978 | 1981 |
/// \brief Returns an iterator to the first value. |
| 1979 | 1982 |
/// |
| 1980 | 1983 |
/// Returns an stl compatible iterator to the |
| 1981 | 1984 |
/// first value of the map. The values of the |
| 1982 | 1985 |
/// map can be accessed in the <tt>[beginValue, endValue)</tt> |
| 1983 | 1986 |
/// range. |
| 1984 | 1987 |
ValueIterator beginValue() const {
|
| 1985 | 1988 |
return ValueIterator(_inv_map.begin()); |
| 1986 | 1989 |
} |
| 1987 | 1990 |
|
| 1988 | 1991 |
/// \brief Returns an iterator after the last value. |
| 1989 | 1992 |
/// |
| 1990 | 1993 |
/// Returns an stl compatible iterator after the |
| 1991 | 1994 |
/// last value of the map. The values of the |
| 1992 | 1995 |
/// map can be accessed in the <tt>[beginValue, endValue)</tt> |
| 1993 | 1996 |
/// range. |
| 1994 | 1997 |
ValueIterator endValue() const {
|
| 1995 | 1998 |
return ValueIterator(_inv_map.end()); |
| 1996 | 1999 |
} |
| 1997 | 2000 |
|
| 1998 | 2001 |
/// \brief Sets the value associated with the given key. |
| 1999 | 2002 |
/// |
| 2000 | 2003 |
/// Sets the value associated with the given key. |
| 2001 | 2004 |
void set(const Key& key, const Value& val) {
|
| 2002 | 2005 |
Value oldval = Map::operator[](key); |
| 2003 |
typename Container::iterator it = _inv_map.find(oldval); |
|
| 2004 |
if (it != _inv_map.end() && it->second == key) {
|
|
| 2005 |
|
|
| 2006 |
typename Container::iterator it; |
|
| 2007 |
for (it = _inv_map.equal_range(oldval).first; |
|
| 2008 |
it != _inv_map.equal_range(oldval).second; ++it) {
|
|
| 2009 |
if (it->second == key) {
|
|
| 2010 |
_inv_map.erase(it); |
|
| 2011 |
break; |
|
| 2012 |
} |
|
| 2006 | 2013 |
} |
| 2007 |
_inv_map.insert(make_pair(val, key)); |
|
| 2014 |
_inv_map.insert(std::make_pair(val, key)); |
|
| 2008 | 2015 |
Map::set(key, val); |
| 2009 | 2016 |
} |
| 2010 | 2017 |
|
| 2011 | 2018 |
/// \brief Returns the value associated with the given key. |
| 2012 | 2019 |
/// |
| 2013 | 2020 |
/// Returns the value associated with the given key. |
| 2014 | 2021 |
typename MapTraits<Map>::ConstReturnValue |
| 2015 | 2022 |
operator[](const Key& key) const {
|
| 2016 | 2023 |
return Map::operator[](key); |
| 2017 | 2024 |
} |
| 2018 | 2025 |
|
| 2019 |
/// \brief Gives back |
|
| 2026 |
/// \brief Gives back an item by its value. |
|
| 2020 | 2027 |
/// |
| 2021 |
/// Gives back the item by its value. |
|
| 2022 |
Key operator()(const Value& key) const {
|
|
| 2023 |
|
|
| 2028 |
/// This function gives back an item that is assigned to |
|
| 2029 |
/// the given value or \c INVALID if no such item exists. |
|
| 2030 |
/// If there are more items with the same associated value, |
|
| 2031 |
/// only one of them is returned. |
|
| 2032 |
Key operator()(const Value& val) const {
|
|
| 2033 |
typename Container::const_iterator it = _inv_map.find(val); |
|
| 2024 | 2034 |
return it != _inv_map.end() ? it->second : INVALID; |
| 2025 | 2035 |
} |
| 2026 | 2036 |
|
| 2027 | 2037 |
protected: |
| 2028 | 2038 |
|
| 2029 | 2039 |
/// \brief Erase the key from the map and the inverse map. |
| 2030 | 2040 |
/// |
| 2031 | 2041 |
/// Erase the key from the map and the inverse map. It is called by the |
| 2032 | 2042 |
/// \c AlterationNotifier. |
| 2033 | 2043 |
virtual void erase(const Key& key) {
|
| 2034 | 2044 |
Value val = Map::operator[](key); |
| 2035 |
typename Container::iterator it = _inv_map.find(val); |
|
| 2036 |
if (it != _inv_map.end() && it->second == key) {
|
|
| 2037 |
|
|
| 2045 |
typename Container::iterator it; |
|
| 2046 |
for (it = _inv_map.equal_range(val).first; |
|
| 2047 |
it != _inv_map.equal_range(val).second; ++it) {
|
|
| 2048 |
if (it->second == key) {
|
|
| 2049 |
_inv_map.erase(it); |
|
| 2050 |
break; |
|
| 2051 |
} |
|
| 2038 | 2052 |
} |
| 2039 | 2053 |
Map::erase(key); |
| 2040 | 2054 |
} |
| 2041 | 2055 |
|
| 2042 | 2056 |
/// \brief Erase more keys from the map and the inverse map. |
| 2043 | 2057 |
/// |
| 2044 | 2058 |
/// Erase more keys from the map and the inverse map. It is called by the |
| 2045 | 2059 |
/// \c AlterationNotifier. |
| 2046 | 2060 |
virtual void erase(const std::vector<Key>& keys) {
|
| 2047 | 2061 |
for (int i = 0; i < int(keys.size()); ++i) {
|
| 2048 | 2062 |
Value val = Map::operator[](keys[i]); |
| 2049 |
typename Container::iterator it = _inv_map.find(val); |
|
| 2050 |
if (it != _inv_map.end() && it->second == keys[i]) {
|
|
| 2051 |
|
|
| 2063 |
typename Container::iterator it; |
|
| 2064 |
for (it = _inv_map.equal_range(val).first; |
|
| 2065 |
it != _inv_map.equal_range(val).second; ++it) {
|
|
| 2066 |
if (it->second == keys[i]) {
|
|
| 2067 |
_inv_map.erase(it); |
|
| 2068 |
break; |
|
| 2069 |
} |
|
| 2052 | 2070 |
} |
| 2053 | 2071 |
} |
| 2054 | 2072 |
Map::erase(keys); |
| 2055 | 2073 |
} |
| 2056 | 2074 |
|
| 2057 | 2075 |
/// \brief Clear the keys from the map and the inverse map. |
| 2058 | 2076 |
/// |
| 2059 | 2077 |
/// Clear the keys from the map and the inverse map. It is called by the |
| 2060 | 2078 |
/// \c AlterationNotifier. |
| 2061 | 2079 |
virtual void clear() {
|
| 2062 | 2080 |
_inv_map.clear(); |
| 2063 | 2081 |
Map::clear(); |
| 2064 | 2082 |
} |
| 2065 | 2083 |
|
| 2066 | 2084 |
public: |
| 2067 | 2085 |
|
| 2068 | 2086 |
/// \brief The inverse map type. |
| 2069 | 2087 |
/// |
| 2070 | 2088 |
/// The inverse of this map. The subscript operator of the map |
| 2071 | 2089 |
/// gives back the item that was last assigned to the value. |
| 2072 | 2090 |
class InverseMap {
|
| 2073 | 2091 |
public: |
| 2074 | 2092 |
/// \brief Constructor |
| 2075 | 2093 |
/// |
| 2076 | 2094 |
/// Constructor of the InverseMap. |
| 2077 | 2095 |
explicit InverseMap(const CrossRefMap& inverted) |
| 2078 | 2096 |
: _inverted(inverted) {}
|
| 2079 | 2097 |
|
| 2080 | 2098 |
/// The value type of the InverseMap. |
| 2081 | 2099 |
typedef typename CrossRefMap::Key Value; |
| 2082 | 2100 |
/// The key type of the InverseMap. |
| 2083 | 2101 |
typedef typename CrossRefMap::Value Key; |
| 2084 | 2102 |
|
| 2085 | 2103 |
/// \brief Subscript operator. |
| 2086 | 2104 |
/// |
| 2087 |
/// Subscript operator. It gives back the item |
|
| 2088 |
/// that was last assigned to the given value. |
|
| 2105 |
/// Subscript operator. It gives back an item |
|
| 2106 |
/// that is assigned to the given value or \c INVALID |
|
| 2107 |
/// if no such item exists. |
|
| 2089 | 2108 |
Value operator[](const Key& key) const {
|
| 2090 | 2109 |
return _inverted(key); |
| 2091 | 2110 |
} |
| 2092 | 2111 |
|
| 2093 | 2112 |
private: |
| 2094 | 2113 |
const CrossRefMap& _inverted; |
| 2095 | 2114 |
}; |
| 2096 | 2115 |
|
| 2097 | 2116 |
/// \brief It gives back the read-only inverse map. |
| 2098 | 2117 |
/// |
| 2099 | 2118 |
/// It gives back the read-only inverse map. |
| 2100 | 2119 |
InverseMap inverse() const {
|
| 2101 | 2120 |
return InverseMap(*this); |
| 2102 | 2121 |
} |
| 2103 | 2122 |
|
| 2104 | 2123 |
}; |
| 2105 | 2124 |
|
| 2106 | 2125 |
/// \brief Provides continuous and unique ID for the |
| 2107 | 2126 |
/// items of a graph. |
| 2108 | 2127 |
/// |
| 2109 | 2128 |
/// RangeIdMap provides a unique and continuous |
| 2110 | 2129 |
/// ID for each item of a given type (\c Node, \c Arc or |
| 2111 | 2130 |
/// \c Edge) in a graph. This id is |
| 2112 | 2131 |
/// - \b unique: different items get different ids, |
| 2113 | 2132 |
/// - \b continuous: the range of the ids is the set of integers |
| 2114 | 2133 |
/// between 0 and \c n-1, where \c n is the number of the items of |
| 2115 | 2134 |
/// this type (\c Node, \c Arc or \c Edge). |
| 2116 | 2135 |
/// - So, the ids can change when deleting an item of the same type. |
| 2117 | 2136 |
/// |
| 2118 | 2137 |
/// Thus this id is not (necessarily) the same as what can get using |
| 2119 | 2138 |
/// the \c id() function of the graph or \ref IdMap. |
| 2120 | 2139 |
/// This map can be inverted with its member class \c InverseMap, |
| 2121 | 2140 |
/// or with the \c operator() member. |
| 2122 | 2141 |
/// |
| 2123 | 2142 |
/// \tparam GR The graph type. |
| 2124 | 2143 |
/// \tparam K The key type of the map (\c GR::Node, \c GR::Arc or |
| 2125 | 2144 |
/// \c GR::Edge). |
| 2126 | 2145 |
/// |
| 2127 | 2146 |
/// \see IdMap |
| 2128 | 2147 |
template <typename GR, typename K> |
| 2129 | 2148 |
class RangeIdMap |
| 2130 | 2149 |
: protected ItemSetTraits<GR, K>::template Map<int>::Type {
|
| 2131 | 2150 |
|
| 2132 | 2151 |
typedef typename ItemSetTraits<GR, K>::template Map<int>::Type Map; |
| 2133 | 2152 |
|
| 2134 | 2153 |
public: |
| 2135 | 2154 |
/// The graph type of RangeIdMap. |
| 2136 | 2155 |
typedef GR Graph; |
| 2137 | 2156 |
typedef GR Digraph; |
| 2138 | 2157 |
/// The key type of RangeIdMap (\c Node, \c Arc or \c Edge). |
| 2139 | 2158 |
typedef K Item; |
| 2140 | 2159 |
/// The key type of RangeIdMap (\c Node, \c Arc or \c Edge). |
| 2141 | 2160 |
typedef K Key; |
| 2142 | 2161 |
/// The value type of RangeIdMap. |
| 2143 | 2162 |
typedef int Value; |
| 2144 | 2163 |
|
| 2145 | 2164 |
/// \brief Constructor. |
| 2146 | 2165 |
/// |
| 2147 | 2166 |
/// Constructor. |
| 2148 | 2167 |
explicit RangeIdMap(const Graph& gr) : Map(gr) {
|
| 2149 | 2168 |
Item it; |
| 2150 | 2169 |
const typename Map::Notifier* nf = Map::notifier(); |
| 2151 | 2170 |
for (nf->first(it); it != INVALID; nf->next(it)) {
|
| 2152 | 2171 |
Map::set(it, _inv_map.size()); |
| 1 | 1 |
/* -*- mode: C++; indent-tabs-mode: nil; -*- |
| 2 | 2 |
* |
| 3 | 3 |
* This file is a part of LEMON, a generic C++ optimization library. |
| 4 | 4 |
* |
| 5 | 5 |
* Copyright (C) 2003-2009 |
| 6 | 6 |
* Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport |
| 7 | 7 |
* (Egervary Research Group on Combinatorial Optimization, EGRES). |
| 8 | 8 |
* |
| 9 | 9 |
* Permission to use, modify and distribute this software is granted |
| 10 | 10 |
* provided that this copyright notice appears in all copies. For |
| 11 | 11 |
* precise terms see the accompanying LICENSE file. |
| 12 | 12 |
* |
| 13 | 13 |
* This software is provided "AS IS" with no warranty of any kind, |
| 14 | 14 |
* express or implied, and with no claim as to its suitability for any |
| 15 | 15 |
* purpose. |
| 16 | 16 |
* |
| 17 | 17 |
*/ |
| 18 | 18 |
|
| 19 | 19 |
#include <deque> |
| 20 | 20 |
#include <set> |
| 21 | 21 |
|
| 22 | 22 |
#include <lemon/concept_check.h> |
| 23 | 23 |
#include <lemon/concepts/maps.h> |
| 24 | 24 |
#include <lemon/maps.h> |
| 25 |
#include <lemon/list_graph.h> |
|
| 25 | 26 |
|
| 26 | 27 |
#include "test_tools.h" |
| 27 | 28 |
|
| 28 | 29 |
using namespace lemon; |
| 29 | 30 |
using namespace lemon::concepts; |
| 30 | 31 |
|
| 31 | 32 |
struct A {};
|
| 32 | 33 |
inline bool operator<(A, A) { return true; }
|
| 33 | 34 |
struct B {};
|
| 34 | 35 |
|
| 35 | 36 |
class C {
|
| 36 | 37 |
int x; |
| 37 | 38 |
public: |
| 38 | 39 |
C(int _x) : x(_x) {}
|
| 39 | 40 |
}; |
| 40 | 41 |
|
| 41 | 42 |
class F {
|
| 42 | 43 |
public: |
| 43 | 44 |
typedef A argument_type; |
| 44 | 45 |
typedef B result_type; |
| 45 | 46 |
|
| 46 | 47 |
B operator()(const A&) const { return B(); }
|
| 47 | 48 |
private: |
| 48 | 49 |
F& operator=(const F&); |
| 49 | 50 |
}; |
| 50 | 51 |
|
| 51 | 52 |
int func(A) { return 3; }
|
| 52 | 53 |
|
| 53 | 54 |
int binc(int a, B) { return a+1; }
|
| 54 | 55 |
|
| 55 | 56 |
typedef ReadMap<A, double> DoubleMap; |
| 56 | 57 |
typedef ReadWriteMap<A, double> DoubleWriteMap; |
| 57 | 58 |
typedef ReferenceMap<A, double, double&, const double&> DoubleRefMap; |
| 58 | 59 |
|
| 59 | 60 |
typedef ReadMap<A, bool> BoolMap; |
| 60 | 61 |
typedef ReadWriteMap<A, bool> BoolWriteMap; |
| 61 | 62 |
typedef ReferenceMap<A, bool, bool&, const bool&> BoolRefMap; |
| 62 | 63 |
|
| 63 | 64 |
int main() |
| 64 | 65 |
{
|
| 65 | 66 |
// Map concepts |
| 66 | 67 |
checkConcept<ReadMap<A,B>, ReadMap<A,B> >(); |
| 67 | 68 |
checkConcept<ReadMap<A,C>, ReadMap<A,C> >(); |
| 68 | 69 |
checkConcept<WriteMap<A,B>, WriteMap<A,B> >(); |
| 69 | 70 |
checkConcept<WriteMap<A,C>, WriteMap<A,C> >(); |
| 70 | 71 |
checkConcept<ReadWriteMap<A,B>, ReadWriteMap<A,B> >(); |
| 71 | 72 |
checkConcept<ReadWriteMap<A,C>, ReadWriteMap<A,C> >(); |
| 72 | 73 |
checkConcept<ReferenceMap<A,B,B&,const B&>, ReferenceMap<A,B,B&,const B&> >(); |
| 73 | 74 |
checkConcept<ReferenceMap<A,C,C&,const C&>, ReferenceMap<A,C,C&,const C&> >(); |
| 74 | 75 |
|
| 75 | 76 |
// NullMap |
| 76 | 77 |
{
|
| 77 | 78 |
checkConcept<ReadWriteMap<A,B>, NullMap<A,B> >(); |
| 78 | 79 |
NullMap<A,B> map1; |
| 79 | 80 |
NullMap<A,B> map2 = map1; |
| 80 | 81 |
map1 = nullMap<A,B>(); |
| 81 | 82 |
} |
| 82 | 83 |
|
| 83 | 84 |
// ConstMap |
| 84 | 85 |
{
|
| 85 | 86 |
checkConcept<ReadWriteMap<A,B>, ConstMap<A,B> >(); |
| 86 | 87 |
checkConcept<ReadWriteMap<A,C>, ConstMap<A,C> >(); |
| 87 | 88 |
ConstMap<A,B> map1; |
| 88 | 89 |
ConstMap<A,B> map2 = B(); |
| ... | ... |
@@ -287,67 +288,101 @@ |
| 287 | 288 |
} |
| 288 | 289 |
|
| 289 | 290 |
// Logical maps: |
| 290 | 291 |
// - TrueMap, FalseMap |
| 291 | 292 |
// - AndMap, OrMap |
| 292 | 293 |
// - NotMap, NotWriteMap |
| 293 | 294 |
// - EqualMap, LessMap |
| 294 | 295 |
{
|
| 295 | 296 |
checkConcept<BoolMap, TrueMap<A> >(); |
| 296 | 297 |
checkConcept<BoolMap, FalseMap<A> >(); |
| 297 | 298 |
checkConcept<BoolMap, AndMap<BoolMap,BoolMap> >(); |
| 298 | 299 |
checkConcept<BoolMap, OrMap<BoolMap,BoolMap> >(); |
| 299 | 300 |
checkConcept<BoolMap, NotMap<BoolMap> >(); |
| 300 | 301 |
checkConcept<BoolWriteMap, NotWriteMap<BoolWriteMap> >(); |
| 301 | 302 |
checkConcept<BoolMap, EqualMap<DoubleMap,DoubleMap> >(); |
| 302 | 303 |
checkConcept<BoolMap, LessMap<DoubleMap,DoubleMap> >(); |
| 303 | 304 |
|
| 304 | 305 |
TrueMap<int> tm; |
| 305 | 306 |
FalseMap<int> fm; |
| 306 | 307 |
RangeMap<bool> rm(2); |
| 307 | 308 |
rm[0] = true; rm[1] = false; |
| 308 | 309 |
check(andMap(tm,rm)[0] && !andMap(tm,rm)[1] && |
| 309 | 310 |
!andMap(fm,rm)[0] && !andMap(fm,rm)[1], |
| 310 | 311 |
"Something is wrong with AndMap"); |
| 311 | 312 |
check(orMap(tm,rm)[0] && orMap(tm,rm)[1] && |
| 312 | 313 |
orMap(fm,rm)[0] && !orMap(fm,rm)[1], |
| 313 | 314 |
"Something is wrong with OrMap"); |
| 314 | 315 |
check(!notMap(rm)[0] && notMap(rm)[1], |
| 315 | 316 |
"Something is wrong with NotMap"); |
| 316 | 317 |
check(!notWriteMap(rm)[0] && notWriteMap(rm)[1], |
| 317 | 318 |
"Something is wrong with NotWriteMap"); |
| 318 | 319 |
|
| 319 | 320 |
ConstMap<int, double> cm(2.0); |
| 320 | 321 |
IdentityMap<int> im; |
| 321 | 322 |
ConvertMap<IdentityMap<int>, double> id(im); |
| 322 | 323 |
check(lessMap(id,cm)[1] && !lessMap(id,cm)[2] && !lessMap(id,cm)[3], |
| 323 | 324 |
"Something is wrong with LessMap"); |
| 324 | 325 |
check(!equalMap(id,cm)[1] && equalMap(id,cm)[2] && !equalMap(id,cm)[3], |
| 325 | 326 |
"Something is wrong with EqualMap"); |
| 326 | 327 |
} |
| 327 | 328 |
|
| 328 | 329 |
// LoggerBoolMap |
| 329 | 330 |
{
|
| 330 | 331 |
typedef std::vector<int> vec; |
| 331 | 332 |
vec v1; |
| 332 | 333 |
vec v2(10); |
| 333 | 334 |
LoggerBoolMap<std::back_insert_iterator<vec> > |
| 334 | 335 |
map1(std::back_inserter(v1)); |
| 335 | 336 |
LoggerBoolMap<vec::iterator> map2(v2.begin()); |
| 336 | 337 |
map1.set(10, false); |
| 337 | 338 |
map1.set(20, true); map2.set(20, true); |
| 338 | 339 |
map1.set(30, false); map2.set(40, false); |
| 339 | 340 |
map1.set(50, true); map2.set(50, true); |
| 340 | 341 |
map1.set(60, true); map2.set(60, true); |
| 341 | 342 |
check(v1.size() == 3 && v2.size() == 10 && |
| 342 | 343 |
v1[0]==20 && v1[1]==50 && v1[2]==60 && |
| 343 | 344 |
v2[0]==20 && v2[1]==50 && v2[2]==60, |
| 344 | 345 |
"Something is wrong with LoggerBoolMap"); |
| 345 | 346 |
|
| 346 | 347 |
int i = 0; |
| 347 | 348 |
for ( LoggerBoolMap<vec::iterator>::Iterator it = map2.begin(); |
| 348 | 349 |
it != map2.end(); ++it ) |
| 349 | 350 |
check(v1[i++] == *it, "Something is wrong with LoggerBoolMap"); |
| 350 | 351 |
} |
| 352 |
|
|
| 353 |
// CrossRefMap |
|
| 354 |
{
|
|
| 355 |
typedef ListDigraph Graph; |
|
| 356 |
DIGRAPH_TYPEDEFS(Graph); |
|
| 357 |
|
|
| 358 |
checkConcept<ReadWriteMap<Node, int>, |
|
| 359 |
CrossRefMap<Graph, Node, int> >(); |
|
| 360 |
|
|
| 361 |
Graph gr; |
|
| 362 |
typedef CrossRefMap<Graph, Node, char> CRMap; |
|
| 363 |
typedef CRMap::ValueIterator ValueIt; |
|
| 364 |
CRMap map(gr); |
|
| 365 |
|
|
| 366 |
Node n0 = gr.addNode(); |
|
| 367 |
Node n1 = gr.addNode(); |
|
| 368 |
Node n2 = gr.addNode(); |
|
| 369 |
|
|
| 370 |
map.set(n0, 'A'); |
|
| 371 |
map.set(n1, 'B'); |
|
| 372 |
map.set(n2, 'C'); |
|
| 373 |
map.set(n2, 'A'); |
|
| 374 |
map.set(n0, 'C'); |
|
| 375 |
|
|
| 376 |
check(map[n0] == 'C' && map[n1] == 'B' && map[n2] == 'A', |
|
| 377 |
"Wrong CrossRefMap"); |
|
| 378 |
check(map('A') == n2 && map.inverse()['A'] == n2, "Wrong CrossRefMap");
|
|
| 379 |
check(map('B') == n1 && map.inverse()['B'] == n1, "Wrong CrossRefMap");
|
|
| 380 |
check(map('C') == n0 && map.inverse()['C'] == n0, "Wrong CrossRefMap");
|
|
| 381 |
|
|
| 382 |
ValueIt it = map.beginValue(); |
|
| 383 |
check(*it++ == 'A' && *it++ == 'B' && *it++ == 'C' && |
|
| 384 |
it == map.endValue(), "Wrong value iterator"); |
|
| 385 |
} |
|
| 351 | 386 |
|
| 352 | 387 |
return 0; |
| 353 | 388 |
} |
0 comments (0 inline)