Empty is now a template, replaced RecursiveIterator with boost::counting_iterator
--- a/include/topology/dynamic-persistence.h Tue Dec 23 15:10:15 2008 -0800
+++ b/include/topology/dynamic-persistence.h Thu Dec 25 13:08:41 2008 -0800
@@ -52,7 +52,7 @@
// TODO: perhaps Consistency should be wrapped into a ConsistencyDescriptor that somehow knows how to initialize it.
// That way one could provide a simple consistency descriptor that just stored some integers describing the original
// position, or one could provide consistency that is references into the complex
-template<class Data_ = Empty,
+template<class Data_ = Empty<>,
class OrderDescriptor_ = VectorOrderDescriptor<>,
class ConsistencyIndex_ = size_t,
class ConsistencyComparison_ = std::less<ConsistencyIndex_> >
--- a/include/topology/filtration.hpp Tue Dec 23 15:10:15 2008 -0800
+++ b/include/topology/filtration.hpp Thu Dec 25 13:08:41 2008 -0800
@@ -1,11 +1,12 @@
#include "utilities/containers.h"
+#include <boost/iterator/counting_iterator.hpp>
template<class C, class I, class CT>
template<class Comparison>
Filtration<C,I,CT>::
Filtration(ComplexIndex bg, ComplexIndex end, const Comparison& cmp):
- order_(RecursiveIterator<ComplexIndex>(bg),
- RecursiveIterator<ComplexIndex>(end)),
+ order_(boost::counting_iterator<ComplexIndex>(bg),
+ boost::counting_iterator<ComplexIndex>(end)),
reverse_order_(order_.size()),
complex_order_map_(bg, reverse_order_.begin()),
simplex_index_map_(bg, end)
--- a/include/topology/order.h Tue Dec 23 15:10:15 2008 -0800
+++ b/include/topology/order.h Thu Dec 25 13:08:41 2008 -0800
@@ -3,6 +3,7 @@
#include "cycles.h"
#include "utilities/types.h"
+#include "utilities/indirect.h"
#include <vector>
#include <list>
@@ -20,7 +21,7 @@
* That prevents it from performing efficient insertions.
*/
template<class Chains_ = VectorChains<>,
- class Data_ = Empty>
+ class Data_ = Empty<> >
struct VectorOrderDescriptor:
public Chains_::template rebind<typename OrderTraits<VectorOrderDescriptor<Chains_, Data_> >::Index>::other,
public Data_
--- a/include/topology/persistence-diagram.h Tue Dec 23 15:10:15 2008 -0800
+++ b/include/topology/persistence-diagram.h Thu Dec 25 13:08:41 2008 -0800
@@ -68,7 +68,7 @@
* Stores birth-death pairs, i.e. points in the extended plane. Each point can also store
* additional information described by `Data_` template parameter.
*/
-template<class Data_ = Empty>
+template<class Data_ = Empty<> >
class PersistenceDiagram
{
public:
--- a/include/topology/persistence-diagram.hpp Tue Dec 23 15:10:15 2008 -0800
+++ b/include/topology/persistence-diagram.hpp Thu Dec 25 13:08:41 2008 -0800
@@ -116,7 +116,7 @@
* Some structures to compute bottleneck distance between two persistence diagrams (in bottleneck_distance() function below)
* by setting up bipartite graphs, and finding maximum cardinality matchings in them using Boost Graph Library.
*/
-#include <utilities/indirect.h>
+#include <boost/iterator/counting_iterator.hpp>
#include <boost/graph/adjacency_list.hpp>
#include <boost/graph/max_cardinality_matching.hpp>
@@ -216,10 +216,11 @@
// std::cout << "Edge: " << edges[i].first << " " << edges[i].second << " " << edges[i].distance << std::endl;
// Perform cardinality based binary search
- RecursiveIterator<EV_const_iterator> bdistance = std::upper_bound(RecursiveIterator<EV_const_iterator>(edges.begin()),
- RecursiveIterator<EV_const_iterator>(edges.end()),
- edges.begin(),
- CardinaliyComparison(max_size, edges.begin()));
+ typedef boost::counting_iterator<EV_const_iterator> EV_counting_const_iterator;
+ EV_counting_const_iterator bdistance = std::upper_bound(EV_counting_const_iterator(edges.begin()),
+ EV_counting_const_iterator(edges.end()),
+ edges.begin(),
+ CardinaliyComparison(max_size, edges.begin()));
return (*bdistance)->distance;
}
--- a/include/topology/simplex.h Tue Dec 23 15:10:15 2008 -0800
+++ b/include/topology/simplex.h Thu Dec 25 13:08:41 2008 -0800
@@ -30,7 +30,7 @@
*
* \ingroup topology
*/
-template<class V, class T = Empty>
+template<class V, class T = Empty<> >
class Simplex
{
public:
--- a/include/topology/static-persistence.h Tue Dec 23 15:10:15 2008 -0800
+++ b/include/topology/static-persistence.h Thu Dec 25 13:08:41 2008 -0800
@@ -15,7 +15,7 @@
* OrderDescriptor_ - class describing how the order is stored; it defaults to <VectorOrderDescriptor>
* which serves as a prototypical class
*/
-template<class Data_ = Empty,
+template<class Data_ = Empty<>,
class OrderDescriptor_ = VectorOrderDescriptor<> >
class StaticPersistence
{
--- a/include/utilities/counter.h Tue Dec 23 15:10:15 2008 -0800
+++ b/include/utilities/counter.h Thu Dec 25 13:08:41 2008 -0800
@@ -21,7 +21,6 @@
#define CountBy(x,y) do { x->count += y; } while (0)
#define SetFrequency(x, freq) do { x->frequency = freq; } while (0)
#define SetTrigger(x, y) do { x->trigger = y; } while(0)
-#endif // COUNTERS
#include <map>
@@ -76,5 +75,7 @@
#include "counter.hpp"
+#endif // COUNTERS
+
#endif // __COUNTER_H__
--- a/include/utilities/indirect.h Tue Dec 23 15:10:15 2008 -0800
+++ b/include/utilities/indirect.h Thu Dec 25 13:08:41 2008 -0800
@@ -37,30 +37,4 @@
}
};
-template<class Iterator_>
-class RecursiveIterator: public boost::iterator_adaptor<RecursiveIterator<Iterator_>, // Derived
- Iterator_, // Base
- Iterator_> // Value
-{
- private:
- struct enabler {};
-
- public:
- typedef Iterator_ Iterator;
- typedef boost::iterator_adaptor<RecursiveIterator<Iterator>,
- Iterator,
- Iterator> Parent;
-
- RecursiveIterator() {}
- explicit RecursiveIterator(Iterator iter):
- Parent(iter) {}
-
- private:
- friend class boost::iterator_core_access;
- typename Parent::reference
- dereference() const { return const_cast<typename Parent::reference>(this->base()); }
- // FIXME: I dislike to const_cast, but it's not obvious how to get rid of it
-};
-
-
#endif // __INDIRECT_H__
--- a/include/utilities/types.h Tue Dec 23 15:10:15 2008 -0800
+++ b/include/utilities/types.h Thu Dec 25 13:08:41 2008 -0800
@@ -6,7 +6,7 @@
/* Types */
typedef bool Sign;
-typedef unsigned short int Dimension;
+typedef short int Dimension;
const Sign POS = true;
const Sign NEG = false;
typedef double RealType;
@@ -16,8 +16,13 @@
typedef const unsigned int& version_type;
+// Empty is made a template so that we don't have to compile and deal with a library
+// solely for its operator<<(out, e) function
+template<typename T = void>
struct Empty {};
-std::ostream& operator<<(std::ostream& out, Empty e) { return out; }
+
+template<typename T>
+std::ostream& operator<<(std::ostream& out, Empty<T> e) { return out; }
enum SwitchType
{
@@ -32,17 +37,15 @@
Case4 = 0x20,
};
-
// Nothing to do for serializing Empty, but still need to provide this function
namespace boost {
namespace serialization {
-template<class Archive>
-void serialize(Archive & ar, Empty&, const unsigned int )
+template<class Archive, class T>
+void serialize(Archive & ar, Empty<T>&, const unsigned int )
{}
} // namespace serialization
} // namespace boost
-
#endif // __TYPES_H__