23 #ifndef GUDHI_SKELETON_BLOCKER_SIMPLEX_H
24 #define GUDHI_SKELETON_BLOCKER_SIMPLEX_H
30 #include <initializer_list>
51 std::set<T> simplex_set;
54 typedef typename T::boost_vertex_handle boost_vertex_handle;
56 typedef T Vertex_handle;
59 typedef typename std::set<T>::const_iterator Simplex_vertex_const_iterator;
60 typedef typename std::set<T>::iterator Simplex_vertex_iterator;
82 template<
typename... Args>
83 Skeleton_blocker_simplex(Args... args){
84 add_vertices(args...);
88 template<
typename... Args>
89 void add_vertices(T v,Args... args){
91 add_vertices(args...);
94 void add_vertices(T v){
106 if ((token[0] ==
'{') && (token[token.size()-1] ==
'}' ) )
109 token.erase(token.size()-1,1);
110 while(token.size()!=0 ){
111 int coma_position=token.find_first_of(
',');
113 std::string n = token.substr(0,coma_position);
115 token.erase(0,n.size()+1);
135 simplex_set.insert(v);
144 simplex_set.erase(v);
153 v.reserve(std::min(simplex_set.size(), a.simplex_set.size()));
155 set_intersection(simplex_set.begin(),simplex_set.end(),
156 a.simplex_set.begin(),a.simplex_set.end(),
157 std::back_inserter(v));
160 simplex_set.insert(i);
169 v.reserve(simplex_set.size());
171 set_difference(simplex_set.begin(),simplex_set.end(),
172 a.simplex_set.begin(),a.simplex_set.end(),
173 std::back_inserter(v));
177 simplex_set.insert(i);
186 v.reserve(simplex_set.size() + a.simplex_set.size());
188 set_union(simplex_set.begin(),simplex_set.end(),
189 a.simplex_set.begin(),a.simplex_set.end(),
190 std::back_inserter(v));
192 simplex_set.insert(v.begin(),v.end());
195 typename std::set<T>::const_iterator begin()
const{
196 return simplex_set.cbegin();
199 typename std::set<T>::const_iterator end()
const{
200 return simplex_set.cend();
203 typename std::set<T>::iterator begin(){
204 return simplex_set.begin();
207 typename std::set<T>::iterator end(){
208 return simplex_set.end();
223 return (simplex_set.size() - 1);
227 return simplex_set.empty();
248 return *(simplex_set.rbegin());
254 return includes(simplex_set.cbegin(),simplex_set.cend(),a.simplex_set.cbegin(),a.simplex_set.cend());
261 auto first1 = begin();
264 auto first2 = a.begin();
265 auto last2 = a.end();
267 while (first2!=last2) {
273 if ( (first1==last1) || (*first2<*first1) )
return false;
274 if (!(*first1<*first2)) ++first2;
285 auto first1 = begin();
288 auto first2 = a.begin();
289 auto last2 = a.end();
291 while (first2!=last2) {
297 if ( (first1==last1) || (*first2<*first1) )
return false;
298 if (!(*first1<*first2)) ++first2;
309 auto first1 = begin();
312 auto first2 = a.begin();
313 auto last2 = a.end();
315 while (first2!=last2) {
317 if(x == *first2 || y == *first2){
321 if ( (first1==last1) || (*first2<*first1) )
return false;
322 if (!(*first1<*first2)) ++first2;
334 return (simplex_set.find(v) != simplex_set.end());
342 v.reserve(std::min(simplex_set.size(), a.simplex_set.size()));
344 set_intersection(simplex_set.cbegin(),simplex_set.cend(),
345 a.simplex_set.cbegin(),a.simplex_set.cend(),
346 std::back_inserter(v));
348 return (v.size()==0);
353 return (this->simplex_set == other.simplex_set);
356 bool operator!=(
const Skeleton_blocker_simplex& other)
const{
357 return (this->simplex_set != other.simplex_set);
360 bool operator<(
const Skeleton_blocker_simplex& other)
const{
361 return (std::lexicographical_compare(this->simplex_set.begin(),this->simplex_set.end(),
362 other.begin(),other.end()));
380 if(first) first = false ;
friend std::ostream & operator<<(std::ostream &o, const Skeleton_blocker_simplex &sigma)
Definition: Skeleton_blocker_simplex.h:374
void add_vertex(T v)
Definition: Skeleton_blocker_simplex.h:133
bool disjoint(const Skeleton_blocker_simplex &a) const
Definition: Skeleton_blocker_simplex.h:340
void union_vertices(const Skeleton_blocker_simplex &a)
Definition: Skeleton_blocker_simplex.h:184
void difference(const Skeleton_blocker_simplex &a)
Definition: Skeleton_blocker_simplex.h:167
void remove_vertex(T v)
Definition: Skeleton_blocker_simplex.h:142
T last_vertex() const
Definition: Skeleton_blocker_simplex.h:245
T first_vertex() const
Definition: Skeleton_blocker_simplex.h:235
Skeleton_blocker_simplex(std::string token)
Definition: Skeleton_blocker_simplex.h:104
bool contains(const Skeleton_blocker_simplex &a) const
Definition: Skeleton_blocker_simplex.h:253
bool contains_difference(const Skeleton_blocker_simplex &a, T x, T y) const
Definition: Skeleton_blocker_simplex.h:308
bool contains(T v) const
Definition: Skeleton_blocker_simplex.h:333
Abstract simplex used in Skeleton blockers data-structure.
Definition: Skeleton_blocker_simplex.h:48
void intersection(const Skeleton_blocker_simplex &a)
Definition: Skeleton_blocker_simplex.h:151
void clear()
Definition: Skeleton_blocker_simplex.h:72
int dimension() const
Definition: Skeleton_blocker_simplex.h:222
bool contains_difference(const Skeleton_blocker_simplex &a, T x) const
Definition: Skeleton_blocker_simplex.h:284
bool contains_difference(const Skeleton_blocker_simplex &a, const Skeleton_blocker_simplex &b) const
Definition: Skeleton_blocker_simplex.h:260