1dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project/*
2dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project *  vector.h
3dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project *  Android
4dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project *
5dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project *  Copyright 2005 The Android Open Source Project
6dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project *
7dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project */
8dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project
9dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project#ifndef ANDROID_VECTOR_H
10dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project#define ANDROID_VECTOR_H
11dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project
12dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project#include <new>
13dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project#include <stdint.h>
14dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project#include <sys/types.h>
15dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project
16dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project#include <cutils/log.h>
17dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project
18006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian#include "tinyutils/Errors.h"
19dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project#include "tinyutils/VectorImpl.h"
20dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project#include "tinyutils/TypeHelpers.h"
21dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project
22dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project// ---------------------------------------------------------------------------
23dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project
24dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Projectnamespace android {
25dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project
26dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project/*!
27dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project * The main templated vector class ensuring type safety
28dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project * while making use of VectorImpl.
29dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project * This is the class users want to use.
30dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project */
31dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project
32dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Projecttemplate <class TYPE>
33dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Projectclass Vector : private VectorImpl
34dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project{
35dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Projectpublic:
36dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project            typedef TYPE    value_type;
37dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project
38dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project    /*!
39dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project     * Constructors and destructors
40dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project     */
41dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project
42dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project                            Vector();
43dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project                            Vector(const Vector<TYPE>& rhs);
44dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project    virtual                 ~Vector();
45dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project
46dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project    /*! copy operator */
47dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project            const Vector<TYPE>&     operator = (const Vector<TYPE>& rhs) const;
48dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project            Vector<TYPE>&           operator = (const Vector<TYPE>& rhs);
49dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project
50dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project    /*
51dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project     * empty the vector
52dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project     */
53dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project
54dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project    inline  void            clear()             { VectorImpl::clear(); }
55dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project
56dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project    /*!
57dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project     * vector stats
58dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project     */
59dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project
60dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project    //! returns number of items in the vector
61dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project    inline  size_t          size() const                { return VectorImpl::size(); }
62dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project    //! returns wether or not the vector is empty
63dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project    inline  bool            isEmpty() const             { return VectorImpl::isEmpty(); }
64dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project    //! returns how many items can be stored without reallocating the backing store
65dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project    inline  size_t          capacity() const            { return VectorImpl::capacity(); }
66dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project    //! setst the capacity. capacity can never be reduced less than size()
67dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project    inline  ssize_t         setCapacity(size_t size)    { return VectorImpl::setCapacity(size); }
68dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project
69dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project    /*!
70dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project     * C-style array access
71dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project     */
72dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project
73dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project    //! read-only C-style access
74dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project    inline  const TYPE*     array() const;
75dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project    //! read-write C-style access
76dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project            TYPE*           editArray();
77dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project
78dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project    /*!
79dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project     * accessors
80dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project     */
81dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project
82dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project    //! read-only access to an item at a given index
83dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project    inline  const TYPE&     operator [] (size_t index) const;
84dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project    //! alternate name for operator []
85dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project    inline  const TYPE&     itemAt(size_t index) const;
86dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project    //! stack-usage of the vector. returns the top of the stack (last element)
87dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project            const TYPE&     top() const;
88dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project    //! same as operator [], but allows to access the vector backward (from the end) with a negative index
89dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project            const TYPE&     mirrorItemAt(ssize_t index) const;
90dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project
91dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project    /*!
92dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project     * modifing the array
93dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project     */
94dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project
95dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project    //! copy-on write support, grants write access to an item
96dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project            TYPE&           editItemAt(size_t index);
97dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project    //! grants right acces to the top of the stack (last element)
98dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project            TYPE&           editTop();
99dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project
100dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project            /*!
101dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project             * append/insert another vector
102dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project             */
103dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project
104dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project    //! insert another vector at a given index
105dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project            ssize_t         insertVectorAt(const Vector<TYPE>& vector, size_t index);
106dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project
107dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project    //! append another vector at the end of this one
108dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project            ssize_t         appendVector(const Vector<TYPE>& vector);
109dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project
110dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project
111dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project            /*!
112dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project             * add/insert/replace items
113dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project             */
114dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project
115dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project    //! insert one or several items initialized with their default constructor
116dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project    inline  ssize_t         insertAt(size_t index, size_t numItems = 1);
117dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project    //! insert on onr several items initialized from a prototype item
118dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project            ssize_t         insertAt(const TYPE& prototype_item, size_t index, size_t numItems = 1);
119dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project    //! pop the top of the stack (removes the last element). No-op if the stack's empty
120dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project    inline  void            pop();
121dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project    //! pushes an item initialized with its default constructor
122dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project    inline  void            push();
123dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project    //! pushes an item on the top of the stack
124dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project            void            push(const TYPE& item);
125dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project    //! same as push() but returns the index the item was added at (or an error)
126dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project    inline  ssize_t         add();
127dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project    //! same as push() but returns the index the item was added at (or an error)
128dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project            ssize_t         add(const TYPE& item);
129dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project    //! replace an item with a new one initialized with its default constructor
130dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project    inline  ssize_t         replaceAt(size_t index);
131dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project    //! replace an item with a new one
132dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project            ssize_t         replaceAt(const TYPE& item, size_t index);
133dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project
134dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project    /*!
135dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project     * remove items
136dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project     */
137dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project
138dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project    //! remove several items
139dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project    inline  ssize_t         removeItemsAt(size_t index, size_t count = 1);
140dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project    //! remove one item
141dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project    inline  ssize_t         removeAt(size_t index)  { return removeItemsAt(index); }
142dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project
143dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project    /*!
144dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project     * sort (stable) the array
145dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project     */
146dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project
147dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project     typedef int (*compar_t)(const TYPE* lhs, const TYPE* rhs);
148dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project     typedef int (*compar_r_t)(const TYPE* lhs, const TYPE* rhs, void* state);
149dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project
150dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project     inline status_t        sort(compar_t cmp);
151dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project     inline status_t        sort(compar_r_t cmp, void* state);
152dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project
153dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Projectprotected:
154dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project    virtual void    do_construct(void* storage, size_t num) const;
155dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project    virtual void    do_destroy(void* storage, size_t num) const;
156dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project    virtual void    do_copy(void* dest, const void* from, size_t num) const;
157dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project    virtual void    do_splat(void* dest, const void* item, size_t num) const;
158dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project    virtual void    do_move_forward(void* dest, const void* from, size_t num) const;
159dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project    virtual void    do_move_backward(void* dest, const void* from, size_t num) const;
160dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project};
161dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project
162dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project
163dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project// ---------------------------------------------------------------------------
164dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project// No user serviceable parts from here...
165dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project// ---------------------------------------------------------------------------
166dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project
167dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Projecttemplate<class TYPE> inline
168dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source ProjectVector<TYPE>::Vector()
169dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project    : VectorImpl(sizeof(TYPE),
170dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project                ((traits<TYPE>::has_trivial_ctor   ? HAS_TRIVIAL_CTOR   : 0)
171dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project                |(traits<TYPE>::has_trivial_dtor   ? HAS_TRIVIAL_DTOR   : 0)
172dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project                |(traits<TYPE>::has_trivial_copy   ? HAS_TRIVIAL_COPY   : 0)
173dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project                |(traits<TYPE>::has_trivial_assign ? HAS_TRIVIAL_ASSIGN : 0))
174dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project                )
175dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project{
176dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project}
177dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project
178dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Projecttemplate<class TYPE> inline
179dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source ProjectVector<TYPE>::Vector(const Vector<TYPE>& rhs)
180dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project    : VectorImpl(rhs) {
181dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project}
182dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project
183dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Projecttemplate<class TYPE> inline
184dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source ProjectVector<TYPE>::~Vector() {
185dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project    finish_vector();
186dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project}
187dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project
188dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Projecttemplate<class TYPE> inline
189dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source ProjectVector<TYPE>& Vector<TYPE>::operator = (const Vector<TYPE>& rhs) {
190dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project    VectorImpl::operator = (rhs);
191dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project    return *this;
192dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project}
193dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project
194dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Projecttemplate<class TYPE> inline
195dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Projectconst Vector<TYPE>& Vector<TYPE>::operator = (const Vector<TYPE>& rhs) const {
196dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project    VectorImpl::operator = (rhs);
197dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project    return *this;
198dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project}
199dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project
200dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Projecttemplate<class TYPE> inline
201dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Projectconst TYPE* Vector<TYPE>::array() const {
202dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project    return static_cast<const TYPE *>(arrayImpl());
203dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project}
204dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project
205dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Projecttemplate<class TYPE> inline
206dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source ProjectTYPE* Vector<TYPE>::editArray() {
207dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project    return static_cast<TYPE *>(editArrayImpl());
208dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project}
209dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project
210dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project
211dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Projecttemplate<class TYPE> inline
212dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Projectconst TYPE& Vector<TYPE>::operator[](size_t index) const {
213dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project    LOG_FATAL_IF( index>=size(),
214dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project                  "itemAt: index %d is past size %d", (int)index, (int)size() );
215dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project    return *(array() + index);
216dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project}
217dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project
218dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Projecttemplate<class TYPE> inline
219dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Projectconst TYPE& Vector<TYPE>::itemAt(size_t index) const {
220dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project    return operator[](index);
221dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project}
222dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project
223dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Projecttemplate<class TYPE> inline
224dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Projectconst TYPE& Vector<TYPE>::mirrorItemAt(ssize_t index) const {
225dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project    LOG_FATAL_IF( (index>0 ? index : -index)>=size(),
226dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project                  "mirrorItemAt: index %d is past size %d",
227dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project                  (int)index, (int)size() );
228dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project    return *(array() + ((index<0) ? (size()-index) : index));
229dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project}
230dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project
231dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Projecttemplate<class TYPE> inline
232dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Projectconst TYPE& Vector<TYPE>::top() const {
233dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project    return *(array() + size() - 1);
234dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project}
235dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project
236dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Projecttemplate<class TYPE> inline
237dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source ProjectTYPE& Vector<TYPE>::editItemAt(size_t index) {
238dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project    return *( static_cast<TYPE *>(editItemLocation(index)) );
239dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project}
240dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project
241dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Projecttemplate<class TYPE> inline
242dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source ProjectTYPE& Vector<TYPE>::editTop() {
243dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project    return *( static_cast<TYPE *>(editItemLocation(size()-1)) );
244dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project}
245dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project
246dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Projecttemplate<class TYPE> inline
247dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Projectssize_t Vector<TYPE>::insertVectorAt(const Vector<TYPE>& vector, size_t index) {
248dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project    return VectorImpl::insertVectorAt(reinterpret_cast<const VectorImpl&>(vector), index);
249dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project}
250dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project
251dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Projecttemplate<class TYPE> inline
252dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Projectssize_t Vector<TYPE>::appendVector(const Vector<TYPE>& vector) {
253dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project    return VectorImpl::appendVector(reinterpret_cast<const VectorImpl&>(vector));
254dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project}
255dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project
256dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Projecttemplate<class TYPE> inline
257dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Projectssize_t Vector<TYPE>::insertAt(const TYPE& item, size_t index, size_t numItems) {
258dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project    return VectorImpl::insertAt(&item, index, numItems);
259dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project}
260dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project
261dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Projecttemplate<class TYPE> inline
262dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Projectvoid Vector<TYPE>::push(const TYPE& item) {
263dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project    return VectorImpl::push(&item);
264dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project}
265dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project
266dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Projecttemplate<class TYPE> inline
267dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Projectssize_t Vector<TYPE>::add(const TYPE& item) {
268dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project    return VectorImpl::add(&item);
269dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project}
270dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project
271dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Projecttemplate<class TYPE> inline
272dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Projectssize_t Vector<TYPE>::replaceAt(const TYPE& item, size_t index) {
273dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project    return VectorImpl::replaceAt(&item, index);
274dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project}
275dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project
276dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Projecttemplate<class TYPE> inline
277dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Projectssize_t Vector<TYPE>::insertAt(size_t index, size_t numItems) {
278dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project    return VectorImpl::insertAt(index, numItems);
279dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project}
280dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project
281dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Projecttemplate<class TYPE> inline
282dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Projectvoid Vector<TYPE>::pop() {
283dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project    VectorImpl::pop();
284dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project}
285dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project
286dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Projecttemplate<class TYPE> inline
287dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Projectvoid Vector<TYPE>::push() {
288dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project    VectorImpl::push();
289dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project}
290dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project
291dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Projecttemplate<class TYPE> inline
292dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Projectssize_t Vector<TYPE>::add() {
293dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project    return VectorImpl::add();
294dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project}
295dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project
296dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Projecttemplate<class TYPE> inline
297dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Projectssize_t Vector<TYPE>::replaceAt(size_t index) {
298dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project    return VectorImpl::replaceAt(index);
299dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project}
300dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project
301dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Projecttemplate<class TYPE> inline
302dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Projectssize_t Vector<TYPE>::removeItemsAt(size_t index, size_t count) {
303dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project    return VectorImpl::removeItemsAt(index, count);
304dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project}
305dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project
306dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project// ---------------------------------------------------------------------------
307dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project
308dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Projecttemplate<class TYPE>
309dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Projectvoid Vector<TYPE>::do_construct(void* storage, size_t num) const {
310dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project    construct_type( reinterpret_cast<TYPE*>(storage), num );
311dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project}
312dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project
313dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Projecttemplate<class TYPE>
314dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Projectvoid Vector<TYPE>::do_destroy(void* storage, size_t num) const {
315dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project    destroy_type( reinterpret_cast<TYPE*>(storage), num );
316dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project}
317dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project
318dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Projecttemplate<class TYPE>
319dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Projectvoid Vector<TYPE>::do_copy(void* dest, const void* from, size_t num) const {
320dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project    copy_type( reinterpret_cast<TYPE*>(dest), reinterpret_cast<const TYPE*>(from), num );
321dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project}
322dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project
323dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Projecttemplate<class TYPE>
324dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Projectvoid Vector<TYPE>::do_splat(void* dest, const void* item, size_t num) const {
325dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project    splat_type( reinterpret_cast<TYPE*>(dest), reinterpret_cast<const TYPE*>(item), num );
326dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project}
327dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project
328dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Projecttemplate<class TYPE>
329dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Projectvoid Vector<TYPE>::do_move_forward(void* dest, const void* from, size_t num) const {
330dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project    move_forward_type( reinterpret_cast<TYPE*>(dest), reinterpret_cast<const TYPE*>(from), num );
331dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project}
332dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project
333dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Projecttemplate<class TYPE>
334dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Projectvoid Vector<TYPE>::do_move_backward(void* dest, const void* from, size_t num) const {
335dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project    move_backward_type( reinterpret_cast<TYPE*>(dest), reinterpret_cast<const TYPE*>(from), num );
336dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project}
337dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project
338dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project}; // namespace android
339dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project
340dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project
341dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project// ---------------------------------------------------------------------------
342dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project
343dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project#endif // ANDROID_VECTOR_H
344