Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

TimestampFlags.h
Go to the documentation of this file.
1 
31 #pragma once
32 
33 #include <ogdf/basic/basic.h>
34 
35 #include <algorithm>
36 #include <cstddef>
37 #include <limits>
38 #include <vector>
39 
40 namespace ogdf {
41 namespace internal {
42 namespace gcm {
43 namespace datastructure {
44 
46 private:
47  std::vector<unsigned int> flags;
48  unsigned int current_round = 1;
49 
50 public:
51  TimestampFlags() { /*nothing to do*/
52  }
53 
54  TimestampFlags(size_t size) : flags(size, 0) { /*nothing to do*/
55  }
56 
57  size_t size() const { return flags.size(); }
58 
59  void clear() {
60  ++current_round;
61  if (current_round == std::numeric_limits<unsigned int>::max()) {
62  current_round = 1;
63  std::fill(flags.begin(), flags.end(), 0);
64  }
65  }
66 
67  inline bool is_set(size_t id) const {
68  OGDF_ASSERT(id < flags.size());
69  return flags[id] == current_round;
70  }
71 
72  inline void set(size_t id) {
73  OGDF_ASSERT(id < flags.size());
74  flags[id] = current_round;
75  }
76 };
77 
78 }
79 }
80 }
81 }
ogdf
The namespace for all OGDF objects.
Definition: multilevelmixer.cpp:39
OGDF_ASSERT
#define OGDF_ASSERT(expr)
Assert condition expr. See doc/build.md for more information.
Definition: basic.h:66
ogdf::internal::gcm::datastructure::TimestampFlags::is_set
bool is_set(size_t id) const
Definition: TimestampFlags.h:67
ogdf::internal::gcm::datastructure::TimestampFlags::TimestampFlags
TimestampFlags(size_t size)
Definition: TimestampFlags.h:54
ogdf::internal::gcm::datastructure::TimestampFlags::set
void set(size_t id)
Definition: TimestampFlags.h:72
ogdf::internal::gcm::datastructure::TimestampFlags::TimestampFlags
TimestampFlags()
Definition: TimestampFlags.h:51
ogdf::internal::gcm::datastructure::TimestampFlags::clear
void clear()
Definition: TimestampFlags.h:59
ogdf::internal::gcm::datastructure::TimestampFlags::flags
std::vector< unsigned int > flags
Definition: TimestampFlags.h:47
ogdf::internal::gcm::datastructure::TimestampFlags::size
size_t size() const
Definition: TimestampFlags.h:57
basic.h
Basic declarations, included by all source files.
ogdf::internal::gcm::datastructure::TimestampFlags::current_round
unsigned int current_round
Definition: TimestampFlags.h:48
ogdf::internal::gcm::datastructure::TimestampFlags
Definition: TimestampFlags.h:45