equal
deleted
inserted
replaced
20 #include <set> |
20 #include <set> |
21 |
21 |
22 #include <lemon/concept_check.h> |
22 #include <lemon/concept_check.h> |
23 #include <lemon/concepts/maps.h> |
23 #include <lemon/concepts/maps.h> |
24 #include <lemon/maps.h> |
24 #include <lemon/maps.h> |
|
25 #include <lemon/smart_graph.h> |
25 |
26 |
26 #include "test_tools.h" |
27 #include "test_tools.h" |
27 |
28 |
28 using namespace lemon; |
29 using namespace lemon; |
29 using namespace lemon::concepts; |
30 using namespace lemon::concepts; |
353 { |
354 { |
354 typedef SmartGraph Graph; |
355 typedef SmartGraph Graph; |
355 typedef SmartGraph::Node Item; |
356 typedef SmartGraph::Node Item; |
356 |
357 |
357 typedef IterableBoolMap<SmartGraph, SmartGraph::Node> Ibm; |
358 typedef IterableBoolMap<SmartGraph, SmartGraph::Node> Ibm; |
358 checkConcept<ReadWriteMap<Item, int>, Ibm>(); |
359 checkConcept<ReferenceMap<Item, bool, bool&, const bool&>, Ibm>(); |
359 |
360 |
360 const int num = 10; |
361 const int num = 10; |
361 Graph g; |
362 Graph g; |
362 std::vector<Item> items; |
363 std::vector<Item> items; |
363 for (int i = 0; i < num; ++i) { |
364 for (int i = 0; i < num; ++i) { |
434 { |
435 { |
435 typedef SmartGraph Graph; |
436 typedef SmartGraph Graph; |
436 typedef SmartGraph::Node Item; |
437 typedef SmartGraph::Node Item; |
437 typedef IterableIntMap<SmartGraph, SmartGraph::Node> Iim; |
438 typedef IterableIntMap<SmartGraph, SmartGraph::Node> Iim; |
438 |
439 |
439 checkConcept<ReadWriteMap<Item, int>, Iim>(); |
440 checkConcept<ReferenceMap<Item, int, int&, const int&>, Iim>(); |
440 |
441 |
441 const int num = 10; |
442 const int num = 10; |
442 Graph g; |
443 Graph g; |
443 std::vector<Item> items; |
444 std::vector<Item> items; |
444 for (int i = 0; i < num; ++i) { |
445 for (int i = 0; i < num; ++i) { |
465 } |
466 } |
466 check(map1.size() == 2, "Wrong size"); |
467 check(map1.size() == 2, "Wrong size"); |
467 |
468 |
468 int n = 0; |
469 int n = 0; |
469 for (Iim::ItemIt it(map1, 0); it != INVALID; ++it) { |
470 for (Iim::ItemIt it(map1, 0); it != INVALID; ++it) { |
470 check(map1[static_cast<Item>(it)] == 0, "Wrong Value"); |
471 check(map1[static_cast<Item>(it)] == 0, "Wrong value"); |
471 ++n; |
472 ++n; |
472 } |
473 } |
473 check(n == (num + 1) / 2, "Wrong number"); |
474 check(n == (num + 1) / 2, "Wrong number"); |
474 |
475 |
475 for (Iim::ItemIt it(map1, 1); it != INVALID; ++it) { |
476 for (Iim::ItemIt it(map1, 1); it != INVALID; ++it) { |
476 check(map1[static_cast<Item>(it)] == 1, "Wrong Value"); |
477 check(map1[static_cast<Item>(it)] == 1, "Wrong value"); |
477 ++n; |
478 ++n; |
478 } |
479 } |
479 check(n == num, "Wrong number"); |
480 check(n == num, "Wrong number"); |
480 |
481 |
481 } |
482 } |
522 } |
523 } |
523 check(distance(map1.beginValue(), map1.endValue()) == 2, "Wrong size"); |
524 check(distance(map1.beginValue(), map1.endValue()) == 2, "Wrong size"); |
524 |
525 |
525 int n = 0; |
526 int n = 0; |
526 for (Ivm::ItemIt it(map1, 0.0); it != INVALID; ++it) { |
527 for (Ivm::ItemIt it(map1, 0.0); it != INVALID; ++it) { |
527 check(map1[static_cast<Item>(it)] == 0.0, "Wrong Value"); |
528 check(map1[static_cast<Item>(it)] == 0.0, "Wrong value"); |
528 ++n; |
529 ++n; |
529 } |
530 } |
530 check(n == (num + 1) / 2, "Wrong number"); |
531 check(n == (num + 1) / 2, "Wrong number"); |
531 |
532 |
532 for (Ivm::ItemIt it(map1, 1.0); it != INVALID; ++it) { |
533 for (Ivm::ItemIt it(map1, 1.0); it != INVALID; ++it) { |
533 check(map1[static_cast<Item>(it)] == 1.0, "Wrong Value"); |
534 check(map1[static_cast<Item>(it)] == 1.0, "Wrong value"); |
534 ++n; |
535 ++n; |
535 } |
536 } |
536 check(n == num, "Wrong number"); |
537 check(n == num, "Wrong number"); |
537 |
538 |
538 } |
539 } |