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