mCRL2
Loading...
Searching...
No Matches
rewrite_stack.h
Go to the documentation of this file.
1// Author(s): Jan Friso Groote
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//
18
19#ifndef MCRL2_DATA_DETAIL_REWRITE_STACK_H
20#define MCRL2_DATA_DETAIL_REWRITE_STACK_H
21
22#include <algorithm>
25
26namespace mcrl2
27{
28namespace data
29{
30namespace detail
31{
32
45
47
48
49class rewrite_stack : protected atermpp::vector<data_expression>
50{
51 protected:
52 std::size_t m_stack_size;
53 std::size_t m_reserved_stack_size; // This is equal to the size() of the underlying stack.
54 // Access of "size()" expensive as it is surrounded by a mutex.
55
56 public:
57
60 : m_stack_size(0)
61 {
63 }
64
66 {
67 resize(std::max(2*size(),static_cast<std::size_t>(128)));
70 }
71
72 void increase(std::size_t distance)
73 {
75 {
77 }
79 }
80
81 void decrease(std::size_t distance)
82 {
83 assert(distance<=m_stack_size);
85 }
86
88 {
90 {
92 }
93 data_expression& result=operator[](m_stack_size);
95 return result;
96 }
97
99 {
100 assert(m_stack_size>0);
101 return operator[](m_stack_size-1);
102 }
103
104 void set_element(std::size_t pos, std::size_t frame_size, const data_expression& d)
105 {
106 assert(m_stack_size+pos>=frame_size && pos<frame_size);
107 operator[](m_stack_size-frame_size+pos)=d;
108 }
109
110 data_expression& element(std::size_t pos, std::size_t frame_size)
111 {
112 assert(m_stack_size+pos>=frame_size && pos<frame_size);
113 return operator[](m_stack_size-frame_size+pos);
114 }
115
116 atermpp::vector<data_expression>::const_iterator stack_iterator(std::size_t pos, std::size_t frame_size) const
117 {
118 assert(m_stack_size+pos>=frame_size && pos<frame_size);
119 return begin()+m_stack_size-frame_size+pos;
120 }
121
122 std::size_t stack_size() const
123 {
124 return m_stack_size;
125 }
126
127 void reset_stack_size(std::size_t n)
128 {
129 m_stack_size=n;
130 }
131};
132
133} // namespace detail
134} // namespace data
135} // namespace mcrl2
136
137#endif // MCRL2_DATA_DETAIL_REWRITE_STACK_H
138
A vector class in which aterms can be stored.
Definition vector.h:34
std::size_t size() const
Definition vector.h:329
super::const_iterator const_iterator
Definition vector.h:47
void resize(size_type count)
Definition vector.h:287
void increase(std::size_t distance)
void set_element(std::size_t pos, std::size_t frame_size, const data_expression &d)
data_expression & element(std::size_t pos, std::size_t frame_size)
void decrease(std::size_t distance)
atermpp::vector< data_expression >::const_iterator stack_iterator(std::size_t pos, std::size_t frame_size) const
data_expression & new_stack_position()
The class data_expression.
A class that takes a linear process specification and checks all tau-summands of that LPS for conflue...
Definition indexed_set.h:72