27 #ifndef MESQUITE_PATCH_DATA_MEM_HPP
28 #define MESQUITE_PATCH_DATA_MEM_HPP
57 inline size_t size()
const;
58 inline bool empty()
const;
60 inline const X&
operator[](
size_t index )
const;
66 inline void resize(
size_t new_size );
100 template <
typename X>
102 { clear(); free( arrayData ); }
104 template <
typename X>
106 {
return activeSize; }
108 template <
typename X>
110 {
return arrayData; }
112 template <
typename X>
114 {
return arrayData; }
116 template <
typename X>
118 {
return arrayData[index]; }
120 template <
typename X>
122 {
return arrayData[index]; }
124 template <
typename X>
126 {
return !activeSize; }
128 template <
typename X>
130 {
return arrayData; }
132 template <
typename X>
134 {
return arrayData; }
136 template <
typename X>
138 {
return arrayData + activeSize; }
140 template <
typename X>
142 {
return arrayData + activeSize; }
144 template <
typename X>
147 assert( new_size >= activeSize );
148 X* new_array = (X*)malloc(
sizeof(X) * new_size );
149 for (
size_t i = 0;
i < activeSize; ++
i)
152 new (new_array +
i) X( arrayData[
i] );
156 arrayData = new_array;
157 arrayLength = new_size;
160 template <
typename X>
163 if (new_size > activeSize)
165 if (new_size > arrayLength)
166 resize_storage( new_size );
168 for (
size_t i = activeSize;
i < new_size; ++
i)
171 new (arrayData +
i) X();
173 activeSize = new_size;
175 else if (new_size < activeSize)
177 for (
size_t i = new_size;
i < activeSize; ++
i)
179 activeSize = new_size;
181 if (activeSize && ((SHRINK_PERCENT*activeSize) < arrayLength))
182 resize_storage( new_size );
186 template <
typename X>
189 for (
size_t i = 0;
i < activeSize; ++
i)
194 template <
typename X>
202 (SHRINK_PERCENT * other.
activeSize) < arrayLength)
206 for (
size_t i = 0;
i < activeSize; ++
i)
void resize(size_t new_size)
const X * to_array() const
MsqMeshEntity is the Mesquite object that stores information about the elements in the mesh...
Shink memory when used portion is less than this percent.
const X & operator[](size_t index) const
void resize_storage(size_t size)
PatchDataMem< X > & operator=(const PatchDataMem< X > &)