1 2 /* 3 * Copyright 2006 The Android Open Source Project 4 * 5 * Use of this source code is governed by a BSD-style license that can be 6 * found in the LICENSE file. 7 */ 8 9 10 #ifndef SkDeque_DEFINED 11 #define SkDeque_DEFINED 12 13 #include "SkTypes.h" 14 15 class SK_API SkDeque : SkNoncopyable { 16 public: 17 explicit SkDeque(size_t elemSize); 18 SkDeque(size_t elemSize, void* storage, size_t storageSize); 19 ~SkDeque(); 20 empty()21 bool empty() const { return 0 == fCount; } count()22 int count() const { return fCount; } elemSize()23 size_t elemSize() const { return fElemSize; } 24 25 const void* front() const; 26 const void* back() const; 27 front()28 void* front() { 29 return (void*)((const SkDeque*)this)->front(); 30 } 31 back()32 void* back() { 33 return (void*)((const SkDeque*)this)->back(); 34 } 35 36 void* push_front(); 37 void* push_back(); 38 39 void pop_front(); 40 void pop_back(); 41 42 private: 43 struct Head; 44 45 public: 46 class F2BIter { 47 public: 48 /** 49 * Creates an uninitialized iterator. Must be reset() 50 */ 51 F2BIter(); 52 53 F2BIter(const SkDeque& d); 54 void* next(); 55 56 void reset(const SkDeque& d); 57 58 private: 59 SkDeque::Head* fHead; 60 char* fPos; 61 size_t fElemSize; 62 }; 63 64 private: 65 Head* fFront; 66 Head* fBack; 67 size_t fElemSize; 68 void* fInitialStorage; 69 int fCount; 70 71 friend class Iter; 72 }; 73 74 #endif 75