Home | History | Annotate | Download | only in utils
      1 /*
      2  * Copyright (C) 2010 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_HWUI_SORTED_LIST_IMPL_H
     18 #define ANDROID_HWUI_SORTED_LIST_IMPL_H
     19 
     20 #include <utils/VectorImpl.h>
     21 
     22 namespace android {
     23 namespace uirenderer {
     24 
     25 class SortedListImpl: public VectorImpl {
     26 public:
     27     SortedListImpl(size_t itemSize, uint32_t flags);
     28     SortedListImpl(const VectorImpl& rhs);
     29     virtual ~SortedListImpl();
     30 
     31     SortedListImpl& operator =(const SortedListImpl& rhs);
     32 
     33     ssize_t indexOf(const void* item) const;
     34     size_t orderOf(const void* item) const;
     35     ssize_t add(const void* item);
     36     ssize_t merge(const VectorImpl& vector);
     37     ssize_t merge(const SortedListImpl& vector);
     38     ssize_t remove(const void* item);
     39 
     40 protected:
     41     virtual int do_compare(const void* lhs, const void* rhs) const = 0;
     42 
     43 private:
     44     ssize_t _indexOrderOf(const void* item, size_t* order = 0) const;
     45 
     46     // these are made private, because they can't be used on a SortedVector
     47     // (they don't have an implementation either)
     48     ssize_t add();
     49     void pop();
     50     void push();
     51     void push(const void* item);
     52     ssize_t insertVectorAt(const VectorImpl& vector, size_t index);
     53     ssize_t appendVector(const VectorImpl& vector);
     54     ssize_t insertArrayAt(const void* array, size_t index, size_t length);
     55     ssize_t appendArray(const void* array, size_t length);
     56     ssize_t insertAt(size_t where, size_t numItems = 1);
     57     ssize_t insertAt(const void* item, size_t where, size_t numItems = 1);
     58     ssize_t replaceAt(size_t index);
     59     ssize_t replaceAt(const void* item, size_t index);
     60 };
     61 
     62 }; // namespace uirenderer
     63 }; // namespace android
     64 
     65 #endif // ANDROID_HWUI_SORTED_LIST_IMPL_H
     66