TTK
Loading...
Searching...
No Matches
FTRLazy.h
Go to the documentation of this file.
1
13
14#pragma once
15
16// local includes
17#include "FTRCommon.h"
18#include "FTRDataTypes.h"
19
20// c++ includes
21#include <set>
22#include <vector>
23
24namespace ttk {
25 namespace ftr {
26 class Lazy : public Allocable {
27 private:
28 std::vector<std::set<linkEdge>> lazyAdd_;
29
30 public:
31 Lazy() = default;
32
33 void alloc() override {
34 lazyAdd_.resize(nbElmt_);
35 }
36
37 void init() override {
38 // nothing
39 }
40
41 void addEmplace(const idEdge e0, const idEdge e1, const idSuperArc a) {
42 lazyAdd_[a].emplace(std::make_pair(e0, e1));
43 }
44
45 void delEmplace(const idEdge e0, const idEdge e1, const idSuperArc a) {
46 const auto p = std::make_pair(e0, e1);
47 auto it = lazyAdd_[a].find(p);
48 if(it != lazyAdd_[a].end()) {
49 lazyAdd_[a].erase(it);
50 }
51 }
52
53 // return the head of lazyAdd / lazyDel (or a null link if empty)
54 // would have used std::optional if possible
56 if(lazyAdd_[a].empty()) {
57 return nullLink;
58 } else {
59 linkEdge add = *lazyAdd_[a].begin();
60 lazyAdd_[a].erase(lazyAdd_[a].begin());
61 return add;
62 }
63 }
64
65 bool isEmpty(const idSuperArc a) {
66 return lazyAdd_[a].empty();
67 }
68
69 // const decltype(lazyAdd_)& addEach() const
70 // {
71 // return lazyAdd_;
72 // }
73
74 // const decltype(lazyDel_)& delEach() const
75 // {
76 // return lazyDel_;
77 // }
78 };
79
80 } // namespace ftr
81} // namespace ttk
idVertex nbElmt_
Allocation may depends on the number of vertices.
Definition FTRCommon.h:50
TTK DynamicGraph laziness.
Definition FTRLazy.h:26
bool isEmpty(const idSuperArc a)
Definition FTRLazy.h:65
linkEdge addGetNext(const idSuperArc a)
Definition FTRLazy.h:55
void alloc() override
Definition FTRLazy.h:33
void delEmplace(const idEdge e0, const idEdge e1, const idSuperArc a)
Definition FTRLazy.h:45
void init() override
Definition FTRLazy.h:37
void addEmplace(const idEdge e0, const idEdge e1, const idSuperArc a)
Definition FTRLazy.h:41
Lazy()=default
long unsigned int idSuperArc
SuperArc index in vect_superArcs_.
SimplexId idEdge
Edge index in vect_edgeList_.
std::pair< idEdge, idEdge > linkEdge
The Topology ToolKit.
T end(std::pair< T, T > &p)
Definition ripserpy.cpp:472
T begin(std::pair< T, T > &p)
Definition ripserpy.cpp:468