23 #ifndef SRC_PERSISTENT_COHOMOLOGY_INCLUDE_GUDHI_PERSISTENT_COHOMOLOGY_PERSISTENT_COHOMOLOGY_COLUMN_H_
24 #define SRC_PERSISTENT_COHOMOLOGY_INCLUDE_GUDHI_PERSISTENT_COHOMOLOGY_PERSISTENT_COHOMOLOGY_COLUMN_H_
28 #include "boost/tuple/tuple.hpp"
29 #include "boost/intrusive/set.hpp"
30 #include "boost/intrusive/list.hpp"
34 namespace persistent_cohomology {
36 template<
typename SimplexKey,
typename ArithmeticElement>
37 class Persistent_cohomology_column;
44 typedef boost::intrusive::list_base_hook<boost::intrusive::tag<cam_h_tag>,
45 boost::intrusive::link_mode<boost::intrusive::auto_unlink>
48 typedef boost::intrusive::list_base_hook<boost::intrusive::tag<cam_v_tag>,
49 boost::intrusive::link_mode<boost::intrusive::normal_link>
56 template<
typename SimplexKey,
typename ArithmeticElement>
57 class Persistent_cohomology_cell :
public base_hook_cam_h,
58 public base_hook_cam_v {
60 template<
class T1,
class T2>
friend class Persistent_cohomology;
61 friend class Persistent_cohomology_column<
SimplexKey, ArithmeticElement>;
63 typedef Persistent_cohomology_column<SimplexKey, ArithmeticElement> Column;
65 Persistent_cohomology_cell(
SimplexKey key, ArithmeticElement x,
73 ArithmeticElement coefficient_;
84 template<
typename SimplexKey,
typename ArithmeticElement>
85 class Persistent_cohomology_column :
public boost::intrusive::set_base_hook<
86 boost::intrusive::link_mode<boost::intrusive::normal_link> > {
88 template<
class T1,
class T2>
friend class Persistent_cohomology;
90 typedef Persistent_cohomology_cell<SimplexKey, ArithmeticElement> Cell;
91 typedef boost::intrusive::list<Cell,
92 boost::intrusive::constant_time_size<false>,
93 boost::intrusive::base_hook<base_hook_cam_v> > Col_type;
96 explicit Persistent_cohomology_column(
SimplexKey key) {
102 Persistent_cohomology_column(Persistent_cohomology_column
const &other)
104 class_key_(other.class_key_) {
105 if (!other.col_.empty())
106 std::cerr <<
"Copying a non-empty column.\n";
121 friend bool operator<(
const Persistent_cohomology_column& c1,
122 const Persistent_cohomology_column& c2) {
123 typename Col_type::const_iterator it1 = c1.col_.begin();
124 typename Col_type::const_iterator it2 = c2.col_.begin();
125 while (it1 != c1.col_.end() && it2 != c2.col_.end()) {
126 if (it1->key_ == it2->key_) {
127 if (it1->coefficient_ == it2->coefficient_) {
131 return it1->coefficient_ < it2->coefficient_;
134 return it1->key_ < it2->key_;
137 return (it2 != c2.col_.end());
148 #endif // SRC_PERSISTENT_COHOMOLOGY_INCLUDE_GUDHI_PERSISTENT_COHOMOLOGY_PERSISTENT_COHOMOLOGY_COLUMN_H_
Key type used as simplex identifier.
Definition: SimplexKey.h:27