Intermediate commit while converting to the new architecture
* Converted Filtration into StaticPersistence and DynamicPersistenceTrails
(both right now work with the underlying std::vector rather than std::list order)
* Filtration is now just an auxilliary glue (a map between Complex and Persistence)
* Whether chains are vectors or lists can be interchanged
* Added PersistenceDiagram with a simple bottleneck_distance() function
* Converted triangle, alphashapes3d, and cech-complex examples
* Lots of organizational changes
(factoring utilities out into containers.h, indirect.h, property-maps.h)
* Trying to document along the way with NaturalDocs-type comments
#ifndef __INDIRECT_H__
#define __INDIRECT_H__
#include <boost/iterator/iterator_adaptor.hpp>
// TODO: write documentation
template<class Iterator_, class Comparison_>
struct IndirectComparison
{
typedef Iterator_ Iterator;
typedef Comparison_ Comparison;
IndirectComparison(const Comparison& cmp):
cmp_(cmp)
{}
bool operator()(Iterator a, Iterator b) const
{ return cmp_(*a, *b); }
const Comparison& cmp_;
};
template<class Comparison>
struct ThreeOutcomeCompare: public Comparison
{
typedef typename Comparison::first_argument_type first_argument_type;
typedef typename Comparison::second_argument_type second_argument_type;
ThreeOutcomeCompare(const Comparison& cmp = Comparison()): Comparison(cmp) {}
int compare(const first_argument_type& a, const second_argument_type& b) const
{ if (operator()(a,b)) return -1;
else if (operator()(b,a)) return 1;
else return 0;
}
};
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__