Open
Graph Drawing
Framework

 v. 2020.02 (Catalpa)
 

FaceSet.h
Go to the documentation of this file.
1 
32 #pragma once
33 
34 #include <ogdf/basic/FaceArray.h>
35 #include <ogdf/basic/SList.h>
36 
37 namespace ogdf {
38 
40 
52 template<bool SupportFastSizeQuery = true>
53 class FaceSet {
54 public:
55  using ListType = typename std::conditional<SupportFastSizeQuery, List<face>, ListPure<face>>::type;
56 
58  explicit FaceSet(const CombinatorialEmbedding &E) : m_it(E) { }
59 
61 
67  void insert(face f) {
68  OGDF_ASSERT(f->embeddingOf() == m_it.embeddingOf());
69  ListIterator<face> &itF = m_it[f];
70 
71  if (!itF.valid()) {
72  itF = m_faces.pushBack(f);
73  }
74  }
75 
77 
83  void remove(face f) {
84  OGDF_ASSERT(f->embeddingOf() == m_it.embeddingOf());
85  ListIterator<face> &itF = m_it[f];
86 
87  if (itF.valid()) {
88  m_faces.del(itF);
89  itF = ListIterator<face>();
90  }
91  }
92 
94 
98  void clear() {
99  m_it.init(embeddingOf());
100  m_faces.clear();
101  }
102 
104 
109  bool isMember(face f) const {
110  OGDF_ASSERT(f->embeddingOf() == m_it.embeddingOf());
111  return m_it[f].valid();
112  }
113 
115  const ListType &faces() const {
116  return m_faces;
117  }
118 
121  return *m_it.embeddingOf();
122  }
123 
125 
128  int size() const {
129  return m_faces.size();
130  }
131 
133  template<bool OtherSupportsFastSizeQuery>
135  this = other;
136  }
137 
139  template<bool OtherSupportsFastSizeQuery>
141  m_faces.clear();
142  m_it.init(other.embeddingOf());
143  for(face f : other.faces()) {
144  insert(f);
145  }
146  }
147 
148 private:
152 
155 };
156 
157 }
Declaration of singly linked lists and iterators.
int size() const
Returns the number of faces in this set.
Definition: FaceSet.h:128
FaceSet(const FaceSet< OtherSupportsFastSizeQuery > &other)
Copy constructor.
Definition: FaceSet.h:134
const ListType & faces() const
Returns a reference to the list of faces contained in this set.
Definition: FaceSet.h:115
Combinatorial embeddings of planar graphs.
Doubly linked lists.
Definition: List.h:41
declaration and implementation of FaceArray class
bool isMember(face f) const
Returns true iff face f is contained in this set.
Definition: FaceSet.h:109
FaceSet(const CombinatorialEmbedding &E)
Creates an empty face set associated with combinatorial embedding E.
Definition: FaceSet.h:58
FaceArray< ListIterator< face > > m_it
m_it[f] contains the list iterator pointing to f if f is contained in S, or an invalid list iterator ...
Definition: FaceSet.h:151
void insert(face f)
Inserts face f into this set.
Definition: FaceSet.h:67
Dynamic arrays indexed with faces of a combinatorial embedding.
typename std::conditional< SupportFastSizeQuery, List< face >, ListPure< face > >::type ListType
Definition: FaceSet.h:55
const ConstCombinatorialEmbedding & embeddingOf() const
Returns the associated combinatorial embedding.
Definition: FaceSet.h:120
Faces in a combinatorial embedding.
Encapsulates a pointer to a list element.
Definition: List.h:42
FaceSet & operator=(const FaceSet< OtherSupportsFastSizeQuery > &other)
Assignment operator.
Definition: FaceSet.h:140
void clear()
Removes all faces from this set-.
Definition: FaceSet.h:98
The namespace for all OGDF objects.
Face sets.
Definition: FaceSet.h:53
Combinatorial embeddings of planar graphs with modification functionality.
#define OGDF_ASSERT(expr)
Assert condition expr. See doc/build.md for more information.
Definition: basic.h:41
ListType m_faces
The list of faces contained in this set.
Definition: FaceSet.h:154