[Lemon-commits] Alpar Juttner: Merge bugfix #330 to branch 1.1
Lemon HG
hg at lemon.cs.elte.hu
Thu Dec 10 17:25:44 CET 2009
details: http://lemon.cs.elte.hu/hg/lemon/rev/76689f2fc02d
changeset: 868:76689f2fc02d
user: Alpar Juttner <alpar [at] cs.elte.hu>
date: Thu Dec 10 17:10:25 2009 +0100
description:
Merge bugfix #330 to branch 1.1
diffstat:
lemon/Makefile.am | 3 +
lemon/bin_heap.h | 12 +-
lemon/bits/map_extender.h | 100 ++++----
lemon/bucket_heap.h | 567 +++++++++++++++++++++++++++++++++++++++++++++++
lemon/concepts/maps.h | 3 +-
lemon/fib_heap.h | 468 +++++++++++++++++++++++++++++++++++++++
lemon/radix_heap.h | 433 ++++++++++++++++++++++++++++++++++++
test/heap_test.cc | 37 +++
8 files changed, 1568 insertions(+), 55 deletions(-)
diffs (truncated from 1867 to 300 lines):
diff --git a/lemon/Makefile.am b/lemon/Makefile.am
--- a/lemon/Makefile.am
+++ b/lemon/Makefile.am
@@ -59,6 +59,7 @@
lemon/assert.h \
lemon/bfs.h \
lemon/bin_heap.h \
+ lemon/bucket_heap.h \
lemon/cbc.h \
lemon/circulation.h \
lemon/clp.h \
@@ -76,6 +77,7 @@
lemon/elevator.h \
lemon/error.h \
lemon/euler.h \
+ lemon/fib_heap.h \
lemon/full_graph.h \
lemon/glpk.h \
lemon/gomory_hu.h \
@@ -98,6 +100,7 @@
lemon/network_simplex.h \
lemon/path.h \
lemon/preflow.h \
+ lemon/radix_heap.h \
lemon/radix_sort.h \
lemon/random.h \
lemon/smart_graph.h \
diff --git a/lemon/bin_heap.h b/lemon/bin_heap.h
--- a/lemon/bin_heap.h
+++ b/lemon/bin_heap.h
@@ -33,23 +33,23 @@
///
///\brief A Binary Heap implementation.
///
- ///This class implements the \e binary \e heap data structure.
- ///
+ ///This class implements the \e binary \e heap data structure.
+ ///
///A \e heap is a data structure for storing items with specified values
///called \e priorities in such a way that finding the item with minimum
- ///priority is efficient. \c Comp specifies the ordering of the priorities.
+ ///priority is efficient. \c CMP specifies the ordering of the priorities.
///In a heap one can change the priority of an item, add or erase an
///item, etc.
///
///\tparam PR Type of the priority of the items.
///\tparam IM A read and writable item map with int values, used internally
///to handle the cross references.
- ///\tparam Comp A functor class for the ordering of the priorities.
+ ///\tparam CMP A functor class for the ordering of the priorities.
///The default is \c std::less<PR>.
///
///\sa FibHeap
///\sa Dijkstra
- template <typename PR, typename IM, typename Comp = std::less<PR> >
+ template <typename PR, typename IM, typename CMP = std::less<PR> >
class BinHeap {
public:
@@ -62,7 +62,7 @@
///\e
typedef std::pair<Item,Prio> Pair;
///\e
- typedef Comp Compare;
+ typedef CMP Compare;
/// \brief Type to represent the items states.
///
diff --git a/lemon/bits/map_extender.h b/lemon/bits/map_extender.h
--- a/lemon/bits/map_extender.h
+++ b/lemon/bits/map_extender.h
@@ -49,6 +49,8 @@
typedef typename Parent::Reference Reference;
typedef typename Parent::ConstReference ConstReference;
+ typedef typename Parent::ReferenceMapTag ReferenceMapTag;
+
class MapIt;
class ConstMapIt;
@@ -82,36 +84,36 @@
typedef typename Map::Value Value;
- MapIt() {}
+ MapIt() : map(NULL) {}
- MapIt(Invalid i) : Parent(i) { }
+ MapIt(Invalid i) : Parent(i), map(NULL) {}
- explicit MapIt(Map& _map) : map(_map) {
- map.notifier()->first(*this);
+ explicit MapIt(Map& _map) : map(&_map) {
+ map->notifier()->first(*this);
}
MapIt(const Map& _map, const Item& item)
- : Parent(item), map(_map) {}
+ : Parent(item), map(&_map) {}
MapIt& operator++() {
- map.notifier()->next(*this);
+ map->notifier()->next(*this);
return *this;
}
typename MapTraits<Map>::ConstReturnValue operator*() const {
- return map[*this];
+ return (*map)[*this];
}
typename MapTraits<Map>::ReturnValue operator*() {
- return map[*this];
+ return (*map)[*this];
}
void set(const Value& value) {
- map.set(*this, value);
+ map->set(*this, value);
}
protected:
- Map& map;
+ Map* map;
};
@@ -122,19 +124,19 @@
typedef typename Map::Value Value;
- ConstMapIt() {}
+ ConstMapIt() : map(NULL) {}
- ConstMapIt(Invalid i) : Parent(i) { }
+ ConstMapIt(Invalid i) : Parent(i), map(NULL) {}
- explicit ConstMapIt(Map& _map) : map(_map) {
- map.notifier()->first(*this);
+ explicit ConstMapIt(Map& _map) : map(&_map) {
+ map->notifier()->first(*this);
}
ConstMapIt(const Map& _map, const Item& item)
: Parent(item), map(_map) {}
ConstMapIt& operator++() {
- map.notifier()->next(*this);
+ map->notifier()->next(*this);
return *this;
}
@@ -143,32 +145,32 @@
}
protected:
- const Map& map;
+ const Map* map;
};
class ItemIt : public Item {
typedef Item Parent;
public:
+ ItemIt() : map(NULL) {}
- ItemIt() {}
- ItemIt(Invalid i) : Parent(i) { }
+ ItemIt(Invalid i) : Parent(i), map(NULL) {}
- explicit ItemIt(Map& _map) : map(_map) {
- map.notifier()->first(*this);
+ explicit ItemIt(Map& _map) : map(&_map) {
+ map->notifier()->first(*this);
}
ItemIt(const Map& _map, const Item& item)
- : Parent(item), map(_map) {}
+ : Parent(item), map(&_map) {}
ItemIt& operator++() {
- map.notifier()->next(*this);
+ map->notifier()->next(*this);
return *this;
}
protected:
- const Map& map;
+ const Map* map;
};
};
@@ -191,6 +193,8 @@
typedef typename Parent::Reference Reference;
typedef typename Parent::ConstReference ConstReference;
+ typedef typename Parent::ReferenceMapTag ReferenceMapTag;
+
class MapIt;
class ConstMapIt;
@@ -227,36 +231,36 @@
public:
typedef typename Map::Value Value;
- MapIt() {}
+ MapIt() : map(NULL) {}
- MapIt(Invalid i) : Parent(i) { }
+ MapIt(Invalid i) : Parent(i), map(NULL) { }
- explicit MapIt(Map& _map) : map(_map) {
- map.graph.first(*this);
+ explicit MapIt(Map& _map) : map(&_map) {
+ map->graph.first(*this);
}
MapIt(const Map& _map, const Item& item)
- : Parent(item), map(_map) {}
+ : Parent(item), map(&_map) {}
MapIt& operator++() {
- map.graph.next(*this);
+ map->graph.next(*this);
return *this;
}
typename MapTraits<Map>::ConstReturnValue operator*() const {
- return map[*this];
+ return (*map)[*this];
}
typename MapTraits<Map>::ReturnValue operator*() {
- return map[*this];
+ return (*map)[*this];
}
void set(const Value& value) {
- map.set(*this, value);
+ map->set(*this, value);
}
protected:
- Map& map;
+ Map* map;
};
@@ -267,53 +271,53 @@
typedef typename Map::Value Value;
- ConstMapIt() {}
+ ConstMapIt() : map(NULL) {}
- ConstMapIt(Invalid i) : Parent(i) { }
+ ConstMapIt(Invalid i) : Parent(i), map(NULL) { }
- explicit ConstMapIt(Map& _map) : map(_map) {
- map.graph.first(*this);
+ explicit ConstMapIt(Map& _map) : map(&_map) {
+ map->graph.first(*this);
}
ConstMapIt(const Map& _map, const Item& item)
- : Parent(item), map(_map) {}
+ : Parent(item), map(&_map) {}
ConstMapIt& operator++() {
- map.graph.next(*this);
+ map->graph.next(*this);
return *this;
}
typename MapTraits<Map>::ConstReturnValue operator*() const {
- return map[*this];
+ return (*map)[*this];
}
protected:
- const Map& map;
+ const Map* map;
};
class ItemIt : public Item {
typedef Item Parent;
public:
+ ItemIt() : map(NULL) {}
- ItemIt() {}
- ItemIt(Invalid i) : Parent(i) { }
+ ItemIt(Invalid i) : Parent(i), map(NULL) { }
- explicit ItemIt(Map& _map) : map(_map) {
- map.graph.first(*this);
+ explicit ItemIt(Map& _map) : map(&_map) {
+ map->graph.first(*this);
More information about the Lemon-commits
mailing list