mCRL2
Loading...
Searching...
No Matches
position_counter.h
Go to the documentation of this file.
1// Author(s): Wieger Wesselink
2// Copyright: see the accompanying file COPYING or copy at
3// https://github.com/mCRL2org/mCRL2/blob/master/COPYING
4//
5// Distributed under the Boost Software License, Version 1.0.
6// (See accompanying file LICENSE_1_0.txt or copy at
7// http://www.boost.org/LICENSE_1_0.txt)
8//
11
12#ifndef MCRL2_UTILITIES_DETAIL_POSITION_COUNTER_H
13#define MCRL2_UTILITIES_DETAIL_POSITION_COUNTER_H
14
15#include <cstddef>
16#include <vector>
17
18namespace mcrl2 {
19
20namespace utilities {
21
22namespace detail {
23
24// Registers the current position (x, y) in a tree, and counts the number of nodes on every depth
26{
27 const std::size_t undefined = std::size_t(-1);
28 std::size_t x = 0;
29 std::size_t y = undefined; // the depth
30 std::vector<std::size_t> ycounts; // counts the number of nodes at a certain depth
31
32 void increase()
33 {
34 if (y == undefined)
35 {
36 y = 0;
37 }
38 else
39 {
40 y++;
41 }
42 if (y == ycounts.size())
43 {
44 ycounts.push_back(1);
45 x = 0;
46 }
47 else
48 {
49 x = ycounts[y]++;
50 }
51 }
52
53 void decrease()
54 {
55 y--;
56 }
57
58 bool at(std::size_t x0, std::size_t y0)
59 {
60 return x == x0 && y == y0;
61 }
62};
63
64} // namespace detail
65
66} // namespace utilities
67
68} // namespace mcrl2
69
70#endif // MCRL2_UTILITIES_DETAIL_POSITION_COUNTER_H
A class that takes a linear process specification and checks all tau-summands of that LPS for conflue...
Definition indexed_set.h:72
bool at(std::size_t x0, std::size_t y0)