CACAO
DynamicVector.hpp
Go to the documentation of this file.
1 /* src/vm/jit/loop/DynamicVector.hpp
2 
3  Copyright (C) 1996-2012
4  CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
5 
6  This file is part of CACAO.
7 
8  This program is free software; you can redistribute it and/or
9  modify it under the terms of the GNU General Public License as
10  published by the Free Software Foundation; either version 2, or (at
11  your option) any later version.
12 
13  This program is distributed in the hope that it will be useful, but
14  WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  General Public License for more details.
17 
18  You should have received a copy of the GNU General Public License
19  along with this program; if not, write to the Free Software
20  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21  02110-1301, USA.
22 
23 */
24 
25 #ifndef _DYNAMIC_VECTOR_HPP
26 #define _DYNAMIC_VECTOR_HPP
27 
28 #include <vector>
29 
30 template<class T>
32 {
33  std::vector<T> _vec;
34 
35 public:
36 
37  typedef typename std::vector<T>::iterator iterator;
38  typedef typename std::vector<T>::const_iterator const_iterator;
39 
40  iterator begin();
41  const_iterator begin() const;
42 
43  iterator end();
44  const_iterator end() const;
45 
46  /**
47  * Returns the element at the specified index.
48  * Resizes the vector if the index does not exist yet.
49  */
50  T& operator[](size_t index);
51  const T& operator[](size_t index) const;
52 
53  size_t size() const;
54 
55  void resize(size_t size);
56 
57 /*
58  void reserve(size_t size);
59  void push_back(const T&);
60 */
61 };
62 
63 template<class T>
65 {
66  return _vec.begin();
67 }
68 
69 template<class T>
71 {
72  return _vec.begin();
73 }
74 
75 template<class T>
77 {
78  return _vec.end();
79 }
80 
81 template<class T>
83 {
84  return _vec.end();
85 }
86 
87 template<class T>
89 {
90  if (index >= _vec.size())
91  _vec.resize(index + 1);
92  return _vec[index];
93 }
94 
95 template<class T>
96 inline const T& DynamicVector<T>::operator[](size_t index) const
97 {
98  assert(index < _vec.size());
99  return _vec[index];
100 }
101 
102 template<class T>
103 inline size_t DynamicVector<T>::size() const
104 {
105  return _vec.size();
106 }
107 
108 template<class T>
109 inline void DynamicVector<T>::resize(size_t size)
110 {
111  _vec.resize(size);
112 }
113 
114 /*
115 template<class T>
116 inline void DynamicVector<T>::reserve(size_t size)
117 {
118  _vec.reserve(size);
119 }
120 
121 template<class T>
122 inline void DynamicVector<T>::push_back(const T& elem)
123 {
124  _vec.push_back(elem);
125 }*/
126 
127 #endif
128 
129 /*
130  * These are local overrides for various environment variables in Emacs.
131  * Please do not remove this and leave it at the end of the file, where
132  * Emacs will automagically detect them.
133  * ---------------------------------------------------------------------
134  * Local variables:
135  * mode: c++
136  * indent-tabs-mode: t
137  * c-basic-offset: 4
138  * tab-width: 4
139  * End:
140  * vim:noexpandtab:sw=4:ts=4:
141  */
142 
std::size_t index
std::vector< T > _vec
std::vector< T >::iterator iterator
size_t size() const
JNIEnv jthread jobject jclass jlong size
Definition: jvmti.h:387
std::vector< T >::const_iterator const_iterator
T & operator[](size_t index)
Returns the element at the specified index.
iterator end()
void resize(size_t size)
iterator begin()