| The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1 | /* | 
|  | 2 | * Copyright (C) 2005 The Android Open Source Project | 
|  | 3 | * | 
|  | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); | 
|  | 5 | * you may not use this file except in compliance with the License. | 
|  | 6 | * You may obtain a copy of the License at | 
|  | 7 | * | 
|  | 8 | *      http://www.apache.org/licenses/LICENSE-2.0 | 
|  | 9 | * | 
|  | 10 | * Unless required by applicable law or agreed to in writing, software | 
|  | 11 | * distributed under the License is distributed on an "AS IS" BASIS, | 
|  | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 
|  | 13 | * See the License for the specific language governing permissions and | 
|  | 14 | * limitations under the License. | 
|  | 15 | */ | 
|  | 16 |  | 
|  | 17 | #ifndef ANDROID_VECTOR_H | 
|  | 18 | #define ANDROID_VECTOR_H | 
|  | 19 |  | 
|  | 20 | #include <new> | 
|  | 21 | #include <stdint.h> | 
|  | 22 | #include <sys/types.h> | 
|  | 23 |  | 
|  | 24 | #include <utils/Log.h> | 
|  | 25 | #include <utils/VectorImpl.h> | 
|  | 26 | #include <utils/TypeHelpers.h> | 
|  | 27 |  | 
|  | 28 | // --------------------------------------------------------------------------- | 
|  | 29 |  | 
|  | 30 | namespace android { | 
|  | 31 |  | 
| Mathias Agopian | 698c087 | 2011-06-28 19:09:31 -0700 | [diff] [blame] | 32 | template <typename TYPE> | 
|  | 33 | class SortedVector; | 
|  | 34 |  | 
| The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 35 | /*! | 
|  | 36 | * The main templated vector class ensuring type safety | 
|  | 37 | * while making use of VectorImpl. | 
|  | 38 | * This is the class users want to use. | 
|  | 39 | */ | 
|  | 40 |  | 
|  | 41 | template <class TYPE> | 
|  | 42 | class Vector : private VectorImpl | 
|  | 43 | { | 
|  | 44 | public: | 
|  | 45 | typedef TYPE    value_type; | 
|  | 46 |  | 
|  | 47 | /*! | 
|  | 48 | * Constructors and destructors | 
|  | 49 | */ | 
|  | 50 |  | 
|  | 51 | Vector(); | 
|  | 52 | Vector(const Vector<TYPE>& rhs); | 
| Mathias Agopian | 698c087 | 2011-06-28 19:09:31 -0700 | [diff] [blame] | 53 | explicit                Vector(const SortedVector<TYPE>& rhs); | 
| The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 54 | virtual                 ~Vector(); | 
|  | 55 |  | 
|  | 56 | /*! copy operator */ | 
|  | 57 | const Vector<TYPE>&     operator = (const Vector<TYPE>& rhs) const; | 
|  | 58 | Vector<TYPE>&           operator = (const Vector<TYPE>& rhs); | 
|  | 59 |  | 
| Mathias Agopian | 698c087 | 2011-06-28 19:09:31 -0700 | [diff] [blame] | 60 | const Vector<TYPE>&     operator = (const SortedVector<TYPE>& rhs) const; | 
|  | 61 | Vector<TYPE>&           operator = (const SortedVector<TYPE>& rhs); | 
|  | 62 |  | 
|  | 63 | /* | 
| The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 64 | * empty the vector | 
|  | 65 | */ | 
|  | 66 |  | 
|  | 67 | inline  void            clear()             { VectorImpl::clear(); } | 
|  | 68 |  | 
|  | 69 | /*! | 
|  | 70 | * vector stats | 
|  | 71 | */ | 
|  | 72 |  | 
|  | 73 | //! returns number of items in the vector | 
|  | 74 | inline  size_t          size() const                { return VectorImpl::size(); } | 
|  | 75 | //! returns wether or not the vector is empty | 
|  | 76 | inline  bool            isEmpty() const             { return VectorImpl::isEmpty(); } | 
|  | 77 | //! returns how many items can be stored without reallocating the backing store | 
|  | 78 | inline  size_t          capacity() const            { return VectorImpl::capacity(); } | 
|  | 79 | //! setst the capacity. capacity can never be reduced less than size() | 
|  | 80 | inline  ssize_t         setCapacity(size_t size)    { return VectorImpl::setCapacity(size); } | 
|  | 81 |  | 
|  | 82 | /*! | 
|  | 83 | * C-style array access | 
|  | 84 | */ | 
|  | 85 |  | 
|  | 86 | //! read-only C-style access | 
|  | 87 | inline  const TYPE*     array() const; | 
|  | 88 | //! read-write C-style access | 
|  | 89 | TYPE*           editArray(); | 
|  | 90 |  | 
|  | 91 | /*! | 
|  | 92 | * accessors | 
|  | 93 | */ | 
|  | 94 |  | 
|  | 95 | //! read-only access to an item at a given index | 
|  | 96 | inline  const TYPE&     operator [] (size_t index) const; | 
|  | 97 | //! alternate name for operator [] | 
|  | 98 | inline  const TYPE&     itemAt(size_t index) const; | 
|  | 99 | //! stack-usage of the vector. returns the top of the stack (last element) | 
|  | 100 | const TYPE&     top() const; | 
|  | 101 | //! same as operator [], but allows to access the vector backward (from the end) with a negative index | 
|  | 102 | const TYPE&     mirrorItemAt(ssize_t index) const; | 
|  | 103 |  | 
|  | 104 | /*! | 
|  | 105 | * modifing the array | 
|  | 106 | */ | 
|  | 107 |  | 
|  | 108 | //! copy-on write support, grants write access to an item | 
|  | 109 | TYPE&           editItemAt(size_t index); | 
|  | 110 | //! grants right acces to the top of the stack (last element) | 
|  | 111 | TYPE&           editTop(); | 
|  | 112 |  | 
|  | 113 | /*! | 
|  | 114 | * append/insert another vector | 
|  | 115 | */ | 
|  | 116 |  | 
|  | 117 | //! insert another vector at a given index | 
|  | 118 | ssize_t         insertVectorAt(const Vector<TYPE>& vector, size_t index); | 
|  | 119 |  | 
|  | 120 | //! append another vector at the end of this one | 
|  | 121 | ssize_t         appendVector(const Vector<TYPE>& vector); | 
|  | 122 |  | 
|  | 123 |  | 
| Jeff Brown | e839a58 | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 124 | //! insert an array at a given index | 
| Jeff Brown | f4a4ec2 | 2010-06-16 01:53:36 -0700 | [diff] [blame] | 125 | ssize_t         insertArrayAt(const TYPE* array, size_t index, size_t length); | 
| Jeff Brown | e839a58 | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 126 |  | 
|  | 127 | //! append an array at the end of this vector | 
| Jeff Brown | f4a4ec2 | 2010-06-16 01:53:36 -0700 | [diff] [blame] | 128 | ssize_t         appendArray(const TYPE* array, size_t length); | 
| Jeff Brown | e839a58 | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 129 |  | 
| The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 130 | /*! | 
|  | 131 | * add/insert/replace items | 
|  | 132 | */ | 
|  | 133 |  | 
|  | 134 | //! insert one or several items initialized with their default constructor | 
|  | 135 | inline  ssize_t         insertAt(size_t index, size_t numItems = 1); | 
| Jeff Brown | f4a4ec2 | 2010-06-16 01:53:36 -0700 | [diff] [blame] | 136 | //! insert one or several items initialized from a prototype item | 
| The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 137 | ssize_t         insertAt(const TYPE& prototype_item, size_t index, size_t numItems = 1); | 
|  | 138 | //! pop the top of the stack (removes the last element). No-op if the stack's empty | 
|  | 139 | inline  void            pop(); | 
|  | 140 | //! pushes an item initialized with its default constructor | 
|  | 141 | inline  void            push(); | 
|  | 142 | //! pushes an item on the top of the stack | 
|  | 143 | void            push(const TYPE& item); | 
|  | 144 | //! same as push() but returns the index the item was added at (or an error) | 
|  | 145 | inline  ssize_t         add(); | 
|  | 146 | //! same as push() but returns the index the item was added at (or an error) | 
|  | 147 | ssize_t         add(const TYPE& item); | 
|  | 148 | //! replace an item with a new one initialized with its default constructor | 
|  | 149 | inline  ssize_t         replaceAt(size_t index); | 
|  | 150 | //! replace an item with a new one | 
|  | 151 | ssize_t         replaceAt(const TYPE& item, size_t index); | 
|  | 152 |  | 
|  | 153 | /*! | 
|  | 154 | * remove items | 
|  | 155 | */ | 
|  | 156 |  | 
|  | 157 | //! remove several items | 
|  | 158 | inline  ssize_t         removeItemsAt(size_t index, size_t count = 1); | 
|  | 159 | //! remove one item | 
|  | 160 | inline  ssize_t         removeAt(size_t index)  { return removeItemsAt(index); } | 
|  | 161 |  | 
|  | 162 | /*! | 
|  | 163 | * sort (stable) the array | 
|  | 164 | */ | 
|  | 165 |  | 
|  | 166 | typedef int (*compar_t)(const TYPE* lhs, const TYPE* rhs); | 
|  | 167 | typedef int (*compar_r_t)(const TYPE* lhs, const TYPE* rhs, void* state); | 
|  | 168 |  | 
|  | 169 | inline status_t        sort(compar_t cmp); | 
|  | 170 | inline status_t        sort(compar_r_t cmp, void* state); | 
|  | 171 |  | 
| Mathias Agopian | d0b55c0 | 2011-03-16 23:18:07 -0700 | [diff] [blame] | 172 | // for debugging only | 
|  | 173 | inline size_t getItemSize() const { return itemSize(); } | 
|  | 174 |  | 
| Mathias Agopian | e60e1fd | 2011-04-25 15:28:17 -0700 | [diff] [blame] | 175 |  | 
|  | 176 | /* | 
|  | 177 | * these inlines add some level of compatibility with STL. eventually | 
|  | 178 | * we should probably turn things around. | 
|  | 179 | */ | 
|  | 180 | typedef TYPE* iterator; | 
|  | 181 | typedef TYPE const* const_iterator; | 
|  | 182 |  | 
|  | 183 | inline iterator begin() { return editArray(); } | 
|  | 184 | inline iterator end()   { return editArray() + size(); } | 
|  | 185 | inline const_iterator begin() const { return array(); } | 
|  | 186 | inline const_iterator end() const   { return array() + size(); } | 
|  | 187 | inline void reserve(size_t n) { setCapacity(n); } | 
|  | 188 | inline bool empty() const{ return isEmpty(); } | 
| Andreas Huber | bc48ce6 | 2012-02-29 15:47:17 -0800 | [diff] [blame] | 189 | inline void push_back(const TYPE& item)  { insertAt(item, size(), 1); } | 
|  | 190 | inline void push_front(const TYPE& item) { insertAt(item, 0, 1); } | 
| Mathias Agopian | e60e1fd | 2011-04-25 15:28:17 -0700 | [diff] [blame] | 191 | inline iterator erase(iterator pos) { | 
|  | 192 | return begin() + removeItemsAt(pos-array()); | 
|  | 193 | } | 
|  | 194 |  | 
| The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 195 | protected: | 
|  | 196 | virtual void    do_construct(void* storage, size_t num) const; | 
|  | 197 | virtual void    do_destroy(void* storage, size_t num) const; | 
|  | 198 | virtual void    do_copy(void* dest, const void* from, size_t num) const; | 
|  | 199 | virtual void    do_splat(void* dest, const void* item, size_t num) const; | 
|  | 200 | virtual void    do_move_forward(void* dest, const void* from, size_t num) const; | 
|  | 201 | virtual void    do_move_backward(void* dest, const void* from, size_t num) const; | 
|  | 202 | }; | 
|  | 203 |  | 
| Jeff Brown | e6d77c5 | 2012-03-16 14:45:49 -0700 | [diff] [blame] | 204 | // Vector<T> can be trivially moved using memcpy() because moving does not | 
|  | 205 | // require any change to the underlying SharedBuffer contents or reference count. | 
|  | 206 | template<typename T> struct trait_trivial_move<Vector<T> > { enum { value = true }; }; | 
| The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 207 |  | 
|  | 208 | // --------------------------------------------------------------------------- | 
|  | 209 | // No user serviceable parts from here... | 
|  | 210 | // --------------------------------------------------------------------------- | 
|  | 211 |  | 
|  | 212 | template<class TYPE> inline | 
|  | 213 | Vector<TYPE>::Vector() | 
|  | 214 | : VectorImpl(sizeof(TYPE), | 
|  | 215 | ((traits<TYPE>::has_trivial_ctor   ? HAS_TRIVIAL_CTOR   : 0) | 
|  | 216 | |(traits<TYPE>::has_trivial_dtor   ? HAS_TRIVIAL_DTOR   : 0) | 
| Mathias Agopian | 5f28411 | 2009-06-22 01:17:46 -0700 | [diff] [blame] | 217 | |(traits<TYPE>::has_trivial_copy   ? HAS_TRIVIAL_COPY   : 0)) | 
| The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 218 | ) | 
|  | 219 | { | 
|  | 220 | } | 
|  | 221 |  | 
|  | 222 | template<class TYPE> inline | 
|  | 223 | Vector<TYPE>::Vector(const Vector<TYPE>& rhs) | 
|  | 224 | : VectorImpl(rhs) { | 
|  | 225 | } | 
|  | 226 |  | 
|  | 227 | template<class TYPE> inline | 
| Mathias Agopian | 698c087 | 2011-06-28 19:09:31 -0700 | [diff] [blame] | 228 | Vector<TYPE>::Vector(const SortedVector<TYPE>& rhs) | 
|  | 229 | : VectorImpl(static_cast<const VectorImpl&>(rhs)) { | 
|  | 230 | } | 
|  | 231 |  | 
|  | 232 | template<class TYPE> inline | 
| The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 233 | Vector<TYPE>::~Vector() { | 
|  | 234 | finish_vector(); | 
|  | 235 | } | 
|  | 236 |  | 
|  | 237 | template<class TYPE> inline | 
|  | 238 | Vector<TYPE>& Vector<TYPE>::operator = (const Vector<TYPE>& rhs) { | 
|  | 239 | VectorImpl::operator = (rhs); | 
|  | 240 | return *this; | 
|  | 241 | } | 
|  | 242 |  | 
|  | 243 | template<class TYPE> inline | 
|  | 244 | const Vector<TYPE>& Vector<TYPE>::operator = (const Vector<TYPE>& rhs) const { | 
| Mathias Agopian | 698c087 | 2011-06-28 19:09:31 -0700 | [diff] [blame] | 245 | VectorImpl::operator = (static_cast<const VectorImpl&>(rhs)); | 
|  | 246 | return *this; | 
|  | 247 | } | 
|  | 248 |  | 
|  | 249 | template<class TYPE> inline | 
|  | 250 | Vector<TYPE>& Vector<TYPE>::operator = (const SortedVector<TYPE>& rhs) { | 
|  | 251 | VectorImpl::operator = (static_cast<const VectorImpl&>(rhs)); | 
|  | 252 | return *this; | 
|  | 253 | } | 
|  | 254 |  | 
|  | 255 | template<class TYPE> inline | 
|  | 256 | const Vector<TYPE>& Vector<TYPE>::operator = (const SortedVector<TYPE>& rhs) const { | 
| The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 257 | VectorImpl::operator = (rhs); | 
|  | 258 | return *this; | 
|  | 259 | } | 
|  | 260 |  | 
|  | 261 | template<class TYPE> inline | 
|  | 262 | const TYPE* Vector<TYPE>::array() const { | 
|  | 263 | return static_cast<const TYPE *>(arrayImpl()); | 
|  | 264 | } | 
|  | 265 |  | 
|  | 266 | template<class TYPE> inline | 
|  | 267 | TYPE* Vector<TYPE>::editArray() { | 
|  | 268 | return static_cast<TYPE *>(editArrayImpl()); | 
|  | 269 | } | 
|  | 270 |  | 
|  | 271 |  | 
|  | 272 | template<class TYPE> inline | 
|  | 273 | const TYPE& Vector<TYPE>::operator[](size_t index) const { | 
|  | 274 | LOG_FATAL_IF( index>=size(), | 
|  | 275 | "itemAt: index %d is past size %d", (int)index, (int)size() ); | 
|  | 276 | return *(array() + index); | 
|  | 277 | } | 
|  | 278 |  | 
|  | 279 | template<class TYPE> inline | 
|  | 280 | const TYPE& Vector<TYPE>::itemAt(size_t index) const { | 
|  | 281 | return operator[](index); | 
|  | 282 | } | 
|  | 283 |  | 
|  | 284 | template<class TYPE> inline | 
|  | 285 | const TYPE& Vector<TYPE>::mirrorItemAt(ssize_t index) const { | 
|  | 286 | LOG_FATAL_IF( (index>0 ? index : -index)>=size(), | 
|  | 287 | "mirrorItemAt: index %d is past size %d", | 
|  | 288 | (int)index, (int)size() ); | 
|  | 289 | return *(array() + ((index<0) ? (size()-index) : index)); | 
|  | 290 | } | 
|  | 291 |  | 
|  | 292 | template<class TYPE> inline | 
|  | 293 | const TYPE& Vector<TYPE>::top() const { | 
|  | 294 | return *(array() + size() - 1); | 
|  | 295 | } | 
|  | 296 |  | 
|  | 297 | template<class TYPE> inline | 
|  | 298 | TYPE& Vector<TYPE>::editItemAt(size_t index) { | 
|  | 299 | return *( static_cast<TYPE *>(editItemLocation(index)) ); | 
|  | 300 | } | 
|  | 301 |  | 
|  | 302 | template<class TYPE> inline | 
|  | 303 | TYPE& Vector<TYPE>::editTop() { | 
|  | 304 | return *( static_cast<TYPE *>(editItemLocation(size()-1)) ); | 
|  | 305 | } | 
|  | 306 |  | 
|  | 307 | template<class TYPE> inline | 
|  | 308 | ssize_t Vector<TYPE>::insertVectorAt(const Vector<TYPE>& vector, size_t index) { | 
|  | 309 | return VectorImpl::insertVectorAt(reinterpret_cast<const VectorImpl&>(vector), index); | 
|  | 310 | } | 
|  | 311 |  | 
|  | 312 | template<class TYPE> inline | 
|  | 313 | ssize_t Vector<TYPE>::appendVector(const Vector<TYPE>& vector) { | 
|  | 314 | return VectorImpl::appendVector(reinterpret_cast<const VectorImpl&>(vector)); | 
|  | 315 | } | 
|  | 316 |  | 
|  | 317 | template<class TYPE> inline | 
| Jeff Brown | f4a4ec2 | 2010-06-16 01:53:36 -0700 | [diff] [blame] | 318 | ssize_t Vector<TYPE>::insertArrayAt(const TYPE* array, size_t index, size_t length) { | 
|  | 319 | return VectorImpl::insertArrayAt(array, index, length); | 
| Jeff Brown | e839a58 | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 320 | } | 
|  | 321 |  | 
|  | 322 | template<class TYPE> inline | 
| Jeff Brown | f4a4ec2 | 2010-06-16 01:53:36 -0700 | [diff] [blame] | 323 | ssize_t Vector<TYPE>::appendArray(const TYPE* array, size_t length) { | 
|  | 324 | return VectorImpl::appendArray(array, length); | 
| Jeff Brown | e839a58 | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 325 | } | 
|  | 326 |  | 
|  | 327 | template<class TYPE> inline | 
| The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 328 | ssize_t Vector<TYPE>::insertAt(const TYPE& item, size_t index, size_t numItems) { | 
|  | 329 | return VectorImpl::insertAt(&item, index, numItems); | 
|  | 330 | } | 
|  | 331 |  | 
|  | 332 | template<class TYPE> inline | 
|  | 333 | void Vector<TYPE>::push(const TYPE& item) { | 
|  | 334 | return VectorImpl::push(&item); | 
|  | 335 | } | 
|  | 336 |  | 
|  | 337 | template<class TYPE> inline | 
|  | 338 | ssize_t Vector<TYPE>::add(const TYPE& item) { | 
|  | 339 | return VectorImpl::add(&item); | 
|  | 340 | } | 
|  | 341 |  | 
|  | 342 | template<class TYPE> inline | 
|  | 343 | ssize_t Vector<TYPE>::replaceAt(const TYPE& item, size_t index) { | 
|  | 344 | return VectorImpl::replaceAt(&item, index); | 
|  | 345 | } | 
|  | 346 |  | 
|  | 347 | template<class TYPE> inline | 
|  | 348 | ssize_t Vector<TYPE>::insertAt(size_t index, size_t numItems) { | 
|  | 349 | return VectorImpl::insertAt(index, numItems); | 
|  | 350 | } | 
|  | 351 |  | 
|  | 352 | template<class TYPE> inline | 
|  | 353 | void Vector<TYPE>::pop() { | 
|  | 354 | VectorImpl::pop(); | 
|  | 355 | } | 
|  | 356 |  | 
|  | 357 | template<class TYPE> inline | 
|  | 358 | void Vector<TYPE>::push() { | 
|  | 359 | VectorImpl::push(); | 
|  | 360 | } | 
|  | 361 |  | 
|  | 362 | template<class TYPE> inline | 
|  | 363 | ssize_t Vector<TYPE>::add() { | 
|  | 364 | return VectorImpl::add(); | 
|  | 365 | } | 
|  | 366 |  | 
|  | 367 | template<class TYPE> inline | 
|  | 368 | ssize_t Vector<TYPE>::replaceAt(size_t index) { | 
|  | 369 | return VectorImpl::replaceAt(index); | 
|  | 370 | } | 
|  | 371 |  | 
|  | 372 | template<class TYPE> inline | 
|  | 373 | ssize_t Vector<TYPE>::removeItemsAt(size_t index, size_t count) { | 
|  | 374 | return VectorImpl::removeItemsAt(index, count); | 
|  | 375 | } | 
|  | 376 |  | 
|  | 377 | template<class TYPE> inline | 
|  | 378 | status_t Vector<TYPE>::sort(Vector<TYPE>::compar_t cmp) { | 
|  | 379 | return VectorImpl::sort((VectorImpl::compar_t)cmp); | 
|  | 380 | } | 
|  | 381 |  | 
|  | 382 | template<class TYPE> inline | 
|  | 383 | status_t Vector<TYPE>::sort(Vector<TYPE>::compar_r_t cmp, void* state) { | 
|  | 384 | return VectorImpl::sort((VectorImpl::compar_r_t)cmp, state); | 
|  | 385 | } | 
|  | 386 |  | 
|  | 387 | // --------------------------------------------------------------------------- | 
|  | 388 |  | 
|  | 389 | template<class TYPE> | 
|  | 390 | void Vector<TYPE>::do_construct(void* storage, size_t num) const { | 
|  | 391 | construct_type( reinterpret_cast<TYPE*>(storage), num ); | 
|  | 392 | } | 
|  | 393 |  | 
|  | 394 | template<class TYPE> | 
|  | 395 | void Vector<TYPE>::do_destroy(void* storage, size_t num) const { | 
|  | 396 | destroy_type( reinterpret_cast<TYPE*>(storage), num ); | 
|  | 397 | } | 
|  | 398 |  | 
|  | 399 | template<class TYPE> | 
|  | 400 | void Vector<TYPE>::do_copy(void* dest, const void* from, size_t num) const { | 
|  | 401 | copy_type( reinterpret_cast<TYPE*>(dest), reinterpret_cast<const TYPE*>(from), num ); | 
|  | 402 | } | 
|  | 403 |  | 
|  | 404 | template<class TYPE> | 
|  | 405 | void Vector<TYPE>::do_splat(void* dest, const void* item, size_t num) const { | 
|  | 406 | splat_type( reinterpret_cast<TYPE*>(dest), reinterpret_cast<const TYPE*>(item), num ); | 
|  | 407 | } | 
|  | 408 |  | 
|  | 409 | template<class TYPE> | 
|  | 410 | void Vector<TYPE>::do_move_forward(void* dest, const void* from, size_t num) const { | 
|  | 411 | move_forward_type( reinterpret_cast<TYPE*>(dest), reinterpret_cast<const TYPE*>(from), num ); | 
|  | 412 | } | 
|  | 413 |  | 
|  | 414 | template<class TYPE> | 
|  | 415 | void Vector<TYPE>::do_move_backward(void* dest, const void* from, size_t num) const { | 
|  | 416 | move_backward_type( reinterpret_cast<TYPE*>(dest), reinterpret_cast<const TYPE*>(from), num ); | 
|  | 417 | } | 
|  | 418 |  | 
|  | 419 | }; // namespace android | 
|  | 420 |  | 
|  | 421 |  | 
|  | 422 | // --------------------------------------------------------------------------- | 
|  | 423 |  | 
|  | 424 | #endif // ANDROID_VECTOR_H |