1 #ifndef ROSE_SgSharedVector_H
2 #define ROSE_SgSharedVector_H
4 #include <featureTests.h>
5 #ifdef ROSE_ENABLE_BINARY_ANALYSIS
7 #ifdef ROSE_HAVE_BOOST_SERIALIZATION_LIB
8 #include <boost/serialization/access.hpp>
9 #include <boost/serialization/array.hpp>
10 #include <boost/serialization/base_object.hpp>
11 #include <boost/serialization/nvp.hpp>
12 #include <boost/serialization/split_member.hpp>
23 template <
typename _Tp>
26 typedef _Tp value_type;
28 typedef const _Tp* const_pointer;
29 typedef _Tp& reference;
30 typedef const _Tp& const_reference;
31 typedef size_t size_type;
38 #ifdef ROSE_HAVE_BOOST_SERIALIZATION_LIB
40 friend class boost::serialization::access;
43 void save(S &s,
const unsigned )
const {
44 s & BOOST_SERIALIZATION_NVP(p_size);
45 s & boost::serialization::make_nvp(
"p_pool", boost::serialization::make_array(p_pool, p_size));
49 void load(S &s,
const unsigned ) {
50 s & BOOST_SERIALIZATION_NVP(p_size);
52 p_pool =
new value_type[p_capacity];
53 s & boost::serialization::make_nvp(
"p_pool", boost::serialization::make_array(p_pool, p_size));
56 BOOST_SERIALIZATION_SPLIT_MEMBER();
63 iterator operator++() {
return (this->p)++; }
64 bool operator!=(
const iterator & x )
const {
return (this->p != x->p); }
65 value_type & operator*()
const {
return *(this->p); }
74 bool operator!=(
const const_iterator & x )
const {
return (this->p != x.p); }
75 const value_type & operator*()
const {
return *(this->p); }
85 : p_pool(0), p_capacity(0), p_size(0) {}
88 : p_pool(pool), p_capacity(n), p_size(n) {}
91 : p_pool(pool), p_capacity(nres), p_size(0) {
96 : p_pool(x.pool()), p_capacity(x.capacity()), p_size(x.size()) {}
102 assert(offset <= x.size());
104 p_pool = x.pool() + offset;
105 p_capacity = x.capacity() - offset;
106 p_size = x.size() - offset;
110 assert(offset+size <= x.size());
111 p_pool = x.pool() + offset;
112 p_capacity = x.capacity() - offset;
121 p_capacity = x.capacity();
132 void erase(iterator position) {
135 void erase(iterator start, iterator finish) {
144 void insert(iterator position, const_reference x) {
147 void insert(iterator position, size_type n, const_reference x) {
150 void insert(iterator position, iterator start, iterator finish) {
153 void push_back(const_reference x) {
154 assert(p_size<p_capacity);
155 p_pool[p_size++] = x;
159 iterator begin() {
return iterator(p_pool); };
160 iterator end() {
return iterator(p_pool+p_size); };
162 const_iterator begin()
const {
return const_iterator(p_pool); };
163 const_iterator end()
const {
return const_iterator(p_pool+p_size); };
166 reference operator[](size_type n) {
169 const_reference operator[](size_type n)
const {
172 reference at(size_type n) {
179 const_reference at(size_type n)
const {
186 return p_pool[p_size-1];
188 const_reference back()
const {
190 return p_pool[p_size-1];
196 const_reference front()
const {
200 pointer pool()
const {
205 size_type capacity()
const {
211 size_type max_size()
const {
214 void reserve(size_type n) {
215 assert(n<=p_capacity);
217 void resize(size_type n) {
221 assert(n<=p_capacity);
225 size_type size()
const {