File: TriangNode.hh

package info (click to toggle)
topcom 0.17.8%2Bds-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 78,572 kB
  • sloc: cpp: 16,640; sh: 975; makefile: 345; ansic: 40
file content (163 lines) | stat: -rw-r--r-- 4,126 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
////////////////////////////////////////////////////////////////////////////////
// 
// TriangNode.hh 
//
//    produced: 30/04/98 jr
// last change: 18/06/98 jr
//
////////////////////////////////////////////////////////////////////////////////
#ifndef TRIANGNODE_HH
#define TRIANGNODE_HH

#include "Pair.hh"
#include "HashSet.hh"
#include "IntegerSet.hh"
#include "SimplicialComplex.hh"

#include "CommandlineOptions.hh"

#include "Chirotope.hh"
#include "Symmetry.hh"
#include "Flip.hh"

class TriangNode : public SimplicialComplex {
private:
  parameter_type               _ID;
  parameter_type               _no;
  parameter_type               _rank;
public:
  TriangNode();
public:
  // constructors:
  inline TriangNode(const size_type, // ID
		    const parameter_type, // no
		    const parameter_type, // rank
		    const SimplicialComplex&);
  inline TriangNode(const size_type, // ID
		    const TriangNode&);
  inline TriangNode(const size_type, // ID
		    const TriangNode&, 
		    const Flip&);

  // destructor:
  inline ~TriangNode();

  // assignments:
  inline TriangNode& operator=(const TriangNode&);

  // accessors:
  inline const parameter_type ID()                const { return _ID; }
  inline const parameter_type no()                const { return _no; }
  inline const parameter_type rank()              const { return _rank; }

  // modifiers for mutables:
  void mark_flip(const flip_type&);
  // functions:
  bool containment_ok(const Circuit& c) const;
  bool link_ok(const Circuit& c) const;

public:
  // comparison operators:
  inline bool operator==(const TriangNode&) const;

public:
  // stream output/input:
  inline std::ostream& write(std::ostream& ost) const;
  inline std::istream& read(std::istream& ost);
  friend inline std::ostream& operator<<(std::ostream& ost, const TriangNode& tn);
  friend inline std::istream& operator>>(std::istream& ist, TriangNode& tn);
};


// constructors:
inline TriangNode::TriangNode() : 
  SimplicialComplex(), _ID(-1), _no(0), _rank(0) {}

inline TriangNode::TriangNode(const size_type ID,
			      const parameter_type no, 
			      const parameter_type rank,
			      const SimplicialComplex& triang) : 
  SimplicialComplex(triang),
  _ID(ID), _no(no), _rank(rank) {
}

inline TriangNode::TriangNode(const size_type ID, const TriangNode& tn) : 
  SimplicialComplex(tn), 
  _ID(ID), _no(tn._no), _rank(tn._rank) {}

inline TriangNode::TriangNode(const size_type ID, const TriangNode& tn, const Flip& flip) :
  SimplicialComplex(tn), 
  _ID(ID), _no(tn._no), _rank(tn._rank) {
  // unmark flips:
  *this -= flip.first;
  *this += flip.second;
}

// destructor:
inline TriangNode::~TriangNode() {}

// assignment:
inline TriangNode& TriangNode::operator=(const TriangNode& tn) {
  if (this == &tn) {
    return *this;
  }
  SimplicialComplex::operator=(tn);
  _ID = tn._ID;
  _no = tn._no;
  _rank = tn._rank;
  return *this;
}

// comparison operator:
inline bool TriangNode::operator==(const TriangNode& tn) const {
  return SimplicialComplex::operator==(tn);
}

// stream output/input:
inline std::ostream& TriangNode::write(std::ostream& ost) const {
  ost << '[' << _ID << "->" << _no << ',' << _rank << ':' << (SimplicialComplex)(*this) << ']';
  return ost;
}

inline std::istream& TriangNode::read(std::istream& ist) {
  char c;

  ist >> c >> _ID >> c >> c >> _no >> c >> _rank >> c;
  SimplicialComplex::read(ist);
  ist >> c;
  return ist;
}

inline std::ostream& operator<<(std::ostream& ost, const TriangNode& tn) {
  return tn.write(ost);
}

inline std::istream& operator>>(std::istream& ist, TriangNode& tn) {
  return tn.read(ist);
}


#ifdef STL_CONTAINERS

#include <tr1/unordered_map>
#include <tr1/unordered_set>

namespace std {
  namespace tr1 {
    template<>				
    struct hash<TriangNode> {
      std::size_t operator()(const TriangNode& tn) const {
	std::size_t result;
	for (size_type k = 0; k < tn.keysize(); ++k) {
	  result ^= tn.key(k);
	}
	return result;
      }
    };                                                     
  };
};                                            
#endif

#endif

// eof TriangNode.hh