1
/* VerifyPN - TAPAAL Petri Net Engine
2
* Copyright (C) 2016 Peter Gjøl Jensen <root@petergjoel.dk>
4
* This program is free software: you can redistribute it and/or modify
5
* it under the terms of the GNU General Public License as published by
6
* the Free Software Foundation, either version 3 of the License, or
7
* (at your option) any later version.
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
14
* You should have received a copy of the GNU General Public License
15
* along with this program. If not, see <http://www.gnu.org/licenses/>.
20
* Author: Peter G. Jensen
23
* Created on 06 October 2016, 13:51
34
uint16_t HEAPBOUND = 128,
35
uint16_t SPLITBOUND = 128,
36
size_t ALLOCSIZE = (1024 * 64),
40
class set_stable : public set<HEAPBOUND, SPLITBOUND, ALLOCSIZE, T, I> {
42
#define pt set<HEAPBOUND, SPLITBOUND, ALLOCSIZE, T, I>
44
using pt = set<HEAPBOUND, SPLITBOUND, ALLOCSIZE, T, I>;
49
this->_entries = new linked_bucket_t<typename pt::entry_t, ALLOCSIZE>(1);
53
return this->_entries->size();
56
size_t unpack(I index, uchar* destination);
61
set_stable<HEAPBOUND, SPLITBOUND, ALLOCSIZE, T, I>::unpack(I index, uchar* destination) {
62
typename pt::node_t* node = NULL;
63
typename pt::fwdnode_t* par = NULL;
64
// we can find size without bothering anyone (to much)
65
std::stack<uchar> path;
71
typename pt::entry_t& ent = this->_entries->operator[](index);
72
par = (typename pt::fwdnode_t*)ent.node;
73
node = (typename pt::node_t*)par->_children[ent.path];
74
typename pt::bucket_t* bckt = node->_data;
75
I* ents = bckt->entries(node->_count, true);
76
for (size_t i = 0; i < node->_count; ++i) {
77
if (ents[i] == index) {
90
while (par != this->_root) {
91
path.push(par->_path);
97
size_t ps = path.size();
99
size = node->_data->first(0, bindex);
102
uchar* bs = (uchar*) & size;
108
for (size_t i = 0; i < bindex; ++i) {
110
uint16_t f = node->_data->first(0, i);
111
uchar* fc = (uchar*) & f;
112
uchar* oc = (uchar*) & o;
118
offset += pt::bytes(f);
119
// assert(bytes(f) == nbucket->bytes(i));
122
uchar* bs = (uchar*) & size;
127
offset = (pt::bytes(size - ps) * bindex);
133
if ((size - ps) >= HEAPBOUND) {
134
src = *((uchar**)&(node->_data->data(node->_count, true)[offset]));
136
src = &(node->_data->data(node->_count, true)[offset]);
139
memcpy(&(destination[ps]), src, (size - ps));
142
uint16_t first = node->_data->first(0, bindex);
145
while (!path.empty()) {
146
destination[pos] = path.top();
153
uchar* fc = (uchar*) & first;
155
destination[pos] = fc[1];
158
destination[pos] = fc[0];
167
#endif /* PTRIE_MAP_H */
b'\\ No newline at end of file'