1006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian/*
29857d99eecc389389da261a72461322d5cfb8eebMathias Agopian * Copyright 2005 The Android Open Source Project
3006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian *
4006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian * Licensed under the Apache License, Version 2.0 (the "License");
5006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian * you may not use this file except in compliance with the License.
6006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian * You may obtain a copy of the License at
7006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian *
8006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian *      http://www.apache.org/licenses/LICENSE-2.0
9006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian *
10006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian * Unless required by applicable law or agreed to in writing, software
11006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian * distributed under the License is distributed on an "AS IS" BASIS,
12006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian * See the License for the specific language governing permissions and
14006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian * limitations under the License.
15006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian */
16006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian
179857d99eecc389389da261a72461322d5cfb8eebMathias Agopian#ifndef ANDROID_PIXELFLINGER_SORTED_VECTOR_H
189857d99eecc389389da261a72461322d5cfb8eebMathias Agopian#define ANDROID_PIXELFLINGER_SORTED_VECTOR_H
19006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian
20006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian#include <assert.h>
21006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian#include <stdint.h>
22006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian#include <sys/types.h>
23006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian
249857d99eecc389389da261a72461322d5cfb8eebMathias Agopian#include "Vector.h"
259857d99eecc389389da261a72461322d5cfb8eebMathias Agopian#include "VectorImpl.h"
269857d99eecc389389da261a72461322d5cfb8eebMathias Agopian#include "TypeHelpers.h"
27006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian
28006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian// ---------------------------------------------------------------------------
29006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian
30006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopiannamespace android {
319857d99eecc389389da261a72461322d5cfb8eebMathias Agopiannamespace tinyutils {
32006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian
33006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopiantemplate <class TYPE>
34006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopianclass SortedVector : private SortedVectorImpl
35006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian{
36006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopianpublic:
37006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian            typedef TYPE    value_type;
38006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian
39006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian    /*!
40006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian     * Constructors and destructors
41006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian     */
42006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian
43006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian                            SortedVector();
44006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian                            SortedVector(const SortedVector<TYPE>& rhs);
45006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian    virtual                 ~SortedVector();
46006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian
47006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian    /*! copy operator */
48006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian    const SortedVector<TYPE>&   operator = (const SortedVector<TYPE>& rhs) const;
49006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian    SortedVector<TYPE>&         operator = (const SortedVector<TYPE>& rhs);
50006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian
51006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian    /*
52006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian     * empty the vector
53006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian     */
54006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian
55006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian    inline  void            clear()             { VectorImpl::clear(); }
56006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian
57006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian    /*!
58006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian     * vector stats
59006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian     */
60006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian
61006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian    //! returns number of items in the vector
62006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian    inline  size_t          size() const                { return VectorImpl::size(); }
63006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian    //! returns wether or not the vector is empty
64006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian    inline  bool            isEmpty() const             { return VectorImpl::isEmpty(); }
65006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian    //! returns how many items can be stored without reallocating the backing store
66006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian    inline  size_t          capacity() const            { return VectorImpl::capacity(); }
67006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian    //! setst the capacity. capacity can never be reduced less than size()
68006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian    inline  ssize_t         setCapacity(size_t size)    { return VectorImpl::setCapacity(size); }
69006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian
70006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian    /*!
71006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian     * C-style array access
72006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian     */
73006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian
74006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian    //! read-only C-style access
75006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian    inline  const TYPE*     array() const;
76006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian
77006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian    //! read-write C-style access. BE VERY CAREFUL when modifying the array
78006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian    //! you ust keep it sorted! You usually don't use this function.
79006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian            TYPE*           editArray();
80006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian
81006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian            //! finds the index of an item
82006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian            ssize_t         indexOf(const TYPE& item) const;
83006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian
84006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian            //! finds where this item should be inserted
85006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian            size_t          orderOf(const TYPE& item) const;
86006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian
87006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian
88006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian    /*!
89006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian     * accessors
90006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian     */
91006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian
92006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian    //! read-only access to an item at a given index
93006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian    inline  const TYPE&     operator [] (size_t index) const;
94006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian    //! alternate name for operator []
95006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian    inline  const TYPE&     itemAt(size_t index) const;
96006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian    //! stack-usage of the vector. returns the top of the stack (last element)
97006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian            const TYPE&     top() const;
98006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian    //! same as operator [], but allows to access the vector backward (from the end) with a negative index
99006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian            const TYPE&     mirrorItemAt(ssize_t index) const;
100006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian
101006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian    /*!
102006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian     * modifing the array
103006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian     */
104006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian
105006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian            //! add an item in the right place (and replace the one that is there)
106006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian            ssize_t         add(const TYPE& item);
107006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian
108006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian            //! editItemAt() MUST NOT change the order of this item
109006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian            TYPE&           editItemAt(size_t index) {
110006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian                return *( static_cast<TYPE *>(VectorImpl::editItemLocation(index)) );
111006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian            }
112006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian
113006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian            //! merges a vector into this one
114006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian            ssize_t         merge(const Vector<TYPE>& vector);
115006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian            ssize_t         merge(const SortedVector<TYPE>& vector);
116006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian
117006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian            //! removes an item
118006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian            ssize_t         remove(const TYPE&);
119006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian
120006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian    //! remove several items
121006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian    inline  ssize_t         removeItemsAt(size_t index, size_t count = 1);
122006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian    //! remove one item
123006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian    inline  ssize_t         removeAt(size_t index)  { return removeItemsAt(index); }
124006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian
125006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopianprotected:
126006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian    virtual void    do_construct(void* storage, size_t num) const;
127006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian    virtual void    do_destroy(void* storage, size_t num) const;
128006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian    virtual void    do_copy(void* dest, const void* from, size_t num) const;
129006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian    virtual void    do_splat(void* dest, const void* item, size_t num) const;
130006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian    virtual void    do_move_forward(void* dest, const void* from, size_t num) const;
131006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian    virtual void    do_move_backward(void* dest, const void* from, size_t num) const;
132006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian    virtual int     do_compare(const void* lhs, const void* rhs) const;
133006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian};
134006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian
135006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian
136006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian// ---------------------------------------------------------------------------
137006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian// No user serviceable parts from here...
138006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian// ---------------------------------------------------------------------------
139006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian
140006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopiantemplate<class TYPE> inline
141006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias AgopianSortedVector<TYPE>::SortedVector()
142006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian    : SortedVectorImpl(sizeof(TYPE),
143006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian                ((traits<TYPE>::has_trivial_ctor   ? HAS_TRIVIAL_CTOR   : 0)
144006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian                |(traits<TYPE>::has_trivial_dtor   ? HAS_TRIVIAL_DTOR   : 0)
145006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian                |(traits<TYPE>::has_trivial_copy   ? HAS_TRIVIAL_COPY   : 0)
146006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian                |(traits<TYPE>::has_trivial_assign ? HAS_TRIVIAL_ASSIGN : 0))
147006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian                )
148006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian{
149006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian}
150006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian
151006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopiantemplate<class TYPE> inline
152006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias AgopianSortedVector<TYPE>::SortedVector(const SortedVector<TYPE>& rhs)
153006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian    : SortedVectorImpl(rhs) {
154006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian}
155006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian
156006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopiantemplate<class TYPE> inline
157006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias AgopianSortedVector<TYPE>::~SortedVector() {
158006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian    finish_vector();
159006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian}
160006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian
161006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopiantemplate<class TYPE> inline
162006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias AgopianSortedVector<TYPE>& SortedVector<TYPE>::operator = (const SortedVector<TYPE>& rhs) {
163006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian    SortedVectorImpl::operator = (rhs);
164006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian    return *this;
165006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian}
166006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian
167006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopiantemplate<class TYPE> inline
168006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopianconst SortedVector<TYPE>& SortedVector<TYPE>::operator = (const SortedVector<TYPE>& rhs) const {
169006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian    SortedVectorImpl::operator = (rhs);
170006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian    return *this;
171006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian}
172006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian
173006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopiantemplate<class TYPE> inline
174006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopianconst TYPE* SortedVector<TYPE>::array() const {
175006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian    return static_cast<const TYPE *>(arrayImpl());
176006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian}
177006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian
178006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopiantemplate<class TYPE> inline
179006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias AgopianTYPE* SortedVector<TYPE>::editArray() {
180006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian    return static_cast<TYPE *>(editArrayImpl());
181006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian}
182006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian
183006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian
184006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopiantemplate<class TYPE> inline
185006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopianconst TYPE& SortedVector<TYPE>::operator[](size_t index) const {
186006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian    assert( index<size() );
187006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian    return *(array() + index);
188006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian}
189006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian
190006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopiantemplate<class TYPE> inline
191006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopianconst TYPE& SortedVector<TYPE>::itemAt(size_t index) const {
192006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian    return operator[](index);
193006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian}
194006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian
195006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopiantemplate<class TYPE> inline
196006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopianconst TYPE& SortedVector<TYPE>::mirrorItemAt(ssize_t index) const {
197006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian    assert( (index>0 ? index : -index)<size() );
198006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian    return *(array() + ((index<0) ? (size()-index) : index));
199006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian}
200006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian
201006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopiantemplate<class TYPE> inline
202006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopianconst TYPE& SortedVector<TYPE>::top() const {
203006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian    return *(array() + size() - 1);
204006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian}
205006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian
206006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopiantemplate<class TYPE> inline
207006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopianssize_t SortedVector<TYPE>::add(const TYPE& item) {
208006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian    return SortedVectorImpl::add(&item);
209006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian}
210006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian
211006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopiantemplate<class TYPE> inline
212006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopianssize_t SortedVector<TYPE>::indexOf(const TYPE& item) const {
213006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian    return SortedVectorImpl::indexOf(&item);
214006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian}
215006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian
216006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopiantemplate<class TYPE> inline
217006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopiansize_t SortedVector<TYPE>::orderOf(const TYPE& item) const {
218006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian    return SortedVectorImpl::orderOf(&item);
219006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian}
220006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian
221006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopiantemplate<class TYPE> inline
222006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopianssize_t SortedVector<TYPE>::merge(const Vector<TYPE>& vector) {
223006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian    return SortedVectorImpl::merge(reinterpret_cast<const VectorImpl&>(vector));
224006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian}
225006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian
226006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopiantemplate<class TYPE> inline
227006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopianssize_t SortedVector<TYPE>::merge(const SortedVector<TYPE>& vector) {
228006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian    return SortedVectorImpl::merge(reinterpret_cast<const SortedVectorImpl&>(vector));
229006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian}
230006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian
231006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopiantemplate<class TYPE> inline
232006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopianssize_t SortedVector<TYPE>::remove(const TYPE& item) {
233006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian    return SortedVectorImpl::remove(&item);
234006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian}
235006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian
236006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopiantemplate<class TYPE> inline
237006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopianssize_t SortedVector<TYPE>::removeItemsAt(size_t index, size_t count) {
238006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian    return VectorImpl::removeItemsAt(index, count);
239006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian}
240006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian
241006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian// ---------------------------------------------------------------------------
242006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian
243006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopiantemplate<class TYPE>
244006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopianvoid SortedVector<TYPE>::do_construct(void* storage, size_t num) const {
245006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian    construct_type( reinterpret_cast<TYPE*>(storage), num );
246006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian}
247006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian
248006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopiantemplate<class TYPE>
249006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopianvoid SortedVector<TYPE>::do_destroy(void* storage, size_t num) const {
250006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian    destroy_type( reinterpret_cast<TYPE*>(storage), num );
251006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian}
252006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian
253006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopiantemplate<class TYPE>
254006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopianvoid SortedVector<TYPE>::do_copy(void* dest, const void* from, size_t num) const {
255006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian    copy_type( reinterpret_cast<TYPE*>(dest), reinterpret_cast<const TYPE*>(from), num );
256006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian}
257006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian
258006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopiantemplate<class TYPE>
259006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopianvoid SortedVector<TYPE>::do_splat(void* dest, const void* item, size_t num) const {
260006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian    splat_type( reinterpret_cast<TYPE*>(dest), reinterpret_cast<const TYPE*>(item), num );
261006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian}
262006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian
263006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopiantemplate<class TYPE>
264006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopianvoid SortedVector<TYPE>::do_move_forward(void* dest, const void* from, size_t num) const {
265006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian    move_forward_type( reinterpret_cast<TYPE*>(dest), reinterpret_cast<const TYPE*>(from), num );
266006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian}
267006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian
268006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopiantemplate<class TYPE>
269006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopianvoid SortedVector<TYPE>::do_move_backward(void* dest, const void* from, size_t num) const {
270006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian    move_backward_type( reinterpret_cast<TYPE*>(dest), reinterpret_cast<const TYPE*>(from), num );
271006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian}
272006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian
273006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopiantemplate<class TYPE>
274006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopianint SortedVector<TYPE>::do_compare(const void* lhs, const void* rhs) const {
275006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian    return compare_type( *reinterpret_cast<const TYPE*>(lhs), *reinterpret_cast<const TYPE*>(rhs) );
276006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian}
277006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian
2789857d99eecc389389da261a72461322d5cfb8eebMathias Agopian} // namespace tinyutils
2799857d99eecc389389da261a72461322d5cfb8eebMathias Agopian} // namespace android
280006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian
281006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian
282006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian// ---------------------------------------------------------------------------
283006ba85e981d66ecf262a0ba0b2a6160b1923f24Mathias Agopian
2849857d99eecc389389da261a72461322d5cfb8eebMathias Agopian#endif // ANDROID_PIXELFLINGER_SORTED_VECTOR_H
285