Changeset 1810:474d093466a5 in lemon-0.x
- Timestamp:
- 11/16/05 19:58:10 (19 years ago)
- Branch:
- default
- Phase:
- public
- Convert:
- svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@2355
- Location:
- lemon
- Files:
-
- 2 added
- 1 deleted
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
lemon/bits/array_map.h
r1719 r1810 19 19 20 20 #include <memory> 21 #include <lemon/bits/map_ iterator.h>21 #include <lemon/bits/map_extender.h> 22 22 #include <lemon/concept_check.h> 23 23 #include <lemon/concept/maps.h> -
lemon/bits/static_map.h
r1719 r1810 22 22 23 23 #include <lemon/utility.h> 24 #include <lemon/bits/map_ iterator.h>24 #include <lemon/bits/map_extender.h> 25 25 #include <lemon/bits/alteration_notifier.h> 26 26 #include <lemon/error.h> -
lemon/bits/vector_map.h
r1730 r1810 22 22 23 23 #include <lemon/utility.h> 24 #include <lemon/bits/map_ iterator.h>24 #include <lemon/bits/map_extender.h> 25 25 #include <lemon/bits/alteration_notifier.h> 26 26 #include <lemon/concept_check.h> -
lemon/iterable_maps.h
r1805 r1810 137 137 { 138 138 sep=0; 139 for(typename BaseMap::MapSet::iterator i=cref.mapSet().begin(); 140 i!=cref.mapSet().end(); 141 ++i) { 142 i->second=sep; 143 vals.push_back(i->first); 139 for(typename BaseMap::MapIt i(cref);i!=INVALID; ++i) { 140 i.set(sep); 141 vals.push_back(i); 144 142 sep++; 145 143 } … … 304 302 template <typename Item> 305 303 struct IterableIntMapNode { 306 IterableIntMapNode() : value(-1) {} 304 IterableIntMapNode() {} 305 IterableIntMapNode(int _value) : value(_value) {} 307 306 Item prev, next; 308 307 int value; … … 314 313 /// \brief Dynamic iterable integer map. 315 314 /// 316 /// \todo Document please 315 /// This class provides a special graph map type which can store 316 /// for each graph item(node, edge, etc.) an integer value. For each 317 /// non negative value it is possible to iterate on the keys which 318 /// mapped to the given value. 319 /// 320 /// \param _Graph The graph type. 321 /// \param _Item One of the graph's item type, the key of the map. 317 322 template <typename _Graph, typename _Item> 318 323 class IterableIntMap : protected ItemSetTraits<_Graph, _Item> … … 323 328 ::Parent Parent; 324 329 330 /// The key type 325 331 typedef _Item Key; 332 /// The value type 326 333 typedef int Value; 334 /// The graph type 327 335 typedef _Graph Graph; 328 336 329 explicit IterableIntMap(const Graph& graph) : Parent(graph) {} 337 /// \brief Constructor of the Map. 338 /// 339 /// Constructor of the Map. It set all values -1. 340 explicit IterableIntMap(const Graph& graph) 341 : Parent(graph, _iterable_maps_bits::IterableIntMapNode<_Item>(-1)) {} 342 343 /// \brief Constructor of the Map with a given value. 344 /// 345 /// Constructor of the Map with a given value. 346 explicit IterableIntMap(const Graph& graph, int value) 347 : Parent(graph, _iterable_maps_bits::IterableIntMapNode<_Item>(value)) { 348 if (value >= 0) { 349 for (typename Parent::ItemIt it(*this); it != INVALID; ++it) { 350 lace(it); 351 } 352 } 353 } 330 354 331 355 private: … … 363 387 public: 364 388 389 /// Indicates that the map if reference map. 365 390 typedef True ReferenceMapTag; 366 391 392 /// \brief Refernce to the value of the map. 393 /// 394 /// This class is near to similar to the int type. It can 395 /// be converted to int and it has the same operators. 367 396 class Reference { 368 397 friend class IterableIntMap; … … 448 477 IterableIntMap& _map; 449 478 }; 450 479 480 /// The const reference type. 451 481 typedef const Value& ConstReference; 452 482 483 /// \brief Gives back the maximal value plus one. 484 /// 485 /// Gives back the maximal value plus one. 453 486 int size() const { 454 487 return (int)first.size(); 455 488 } 456 489 490 /// \brief Set operation of the map. 491 /// 492 /// Set operation of the map. 457 493 void set(const Key& key, const Value& value) { 458 494 unlace(key); … … 461 497 } 462 498 499 /// \brief Const subscript operator of the map. 500 /// 501 /// Const subscript operator of the map. 463 502 const Value& operator[](const Key& key) const { 464 503 return Parent::operator[](key).value; 465 504 } 466 505 506 /// \brief Subscript operator of the map. 507 /// 508 /// Subscript operator of the map. 467 509 Reference operator[](const Key& key) { 468 510 return Reference(*this, key); 469 511 } 470 512 513 /// \brief Iterator for the keys with the same value. 514 /// 515 /// Iterator for the keys with the same value. It works 516 /// like a graph item iterator in the map, it can be converted 517 /// the item type of the map, incremented with \c ++ operator, and 518 /// if the iterator leave the last valid item it will be equal to 519 /// \c INVALID. 471 520 class ItemIt : public _Item { 472 521 public: 473 522 typedef _Item Parent; 474 523 524 /// \brief Invalid constructor \& conversion. 525 /// 526 /// This constructor initializes the item to be invalid. 527 /// \sa Invalid for more details. 475 528 ItemIt(Invalid) : Parent(INVALID), _map(0) {} 476 529 530 /// \brief Creates an iterator with a value. 531 /// 532 /// Creates an iterator with a value. It iterates on the 533 /// keys which have the given value. 534 /// \param map The IterableIntMap 535 /// \param value The value 477 536 ItemIt(const IterableIntMap& map, int value) : _map(&map) { 478 537 if (value < 0 || value >= (int)_map->first.size()) { … … 483 542 } 484 543 544 /// \brief Increment operator. 545 /// 546 /// Increment Operator. 485 547 ItemIt& operator++() { 486 548 Parent::operator=(_map->IterableIntMap::Parent:: -
lemon/lp_base.h
r1787 r1810 682 682 } 683 683 template<class T> 684 typename enable_if<typename T:: ValueSet::value_type::LpSolverCol,684 typename enable_if<typename T::MapIt::Value::LpSolverCol, 685 685 int>::type 686 686 addColSet(T &t,dummy<2> = 2) { 687 ///\bug <tt>return addColSet(t.valueSet());</tt> should also work.688 687 int s=0; 689 for(typename T::ValueSet::iterator i=t.valueSet().begin(); 690 i!=t.valueSet().end(); 691 ++i) 688 for(typename T::MapIt i(t); i!=INVALID; ++i) 692 689 { 693 *i=addCol();690 i.set(addCol()); 694 691 s++; 695 692 } … … 788 785 } 789 786 template<class T> 790 typename enable_if<typename T:: ValueSet::value_type::LpSolverRow,787 typename enable_if<typename T::MapIt::Value::LpSolverRow, 791 788 int>::type 792 789 addRowSet(T &t,dummy<2> = 2) { 793 ///\bug <tt>return addRowSet(t.valueSet());</tt> should also work.794 790 int s=0; 795 for(typename T::ValueSet::iterator i=t.valueSet().begin(); 796 i!=t.valueSet().end(); 797 ++i) 791 for(typename T::MapIt i(t); i!=INVALID; ++i) 798 792 { 799 *i=addRow();793 i.set(addRow()); 800 794 s++; 801 795 }
Note: See TracChangeset
for help on using the changeset viewer.