#include <SkDeque.h>
Definition at line 28 of file SkDeque.h.
◆ SkDeque() [1/2]
SkDeque::SkDeque |
( |
size_t |
elemSize, |
|
|
int |
allocCount = 1 |
|
) |
| |
|
explicit |
elemSize specifies the size of each individual element in the deque allocCount specifies how many elements are to be allocated as a block
Definition at line 31 of file SkDeque.cpp.
33 , fInitialStorage(nullptr)
34 , fCount(0)
35 , fAllocCount(allocCount) {
37 fFrontBlock = fBackBlock = nullptr;
38 fFront = fBack = nullptr;
39}
◆ SkDeque() [2/2]
SkDeque::SkDeque |
( |
size_t |
elemSize, |
|
|
void * |
storage, |
|
|
size_t |
storageSize, |
|
|
int |
allocCount = 1 |
|
) |
| |
Definition at line 41 of file SkDeque.cpp.
43 , fInitialStorage(storage)
44 , fCount(0)
45 , fAllocCount(allocCount) {
46 SkASSERT(storageSize == 0 || storage !=
nullptr);
48
50 fFrontBlock = (
Block*)storage;
51 fFrontBlock->
init(storageSize);
52 } else {
53 fFrontBlock = nullptr;
54 }
55 fBackBlock = fFrontBlock;
56 fFront = fBack = nullptr;
57}
◆ ~SkDeque()
Definition at line 59 of file SkDeque.cpp.
59 {
62
65 if (
head != initialHead) {
66 this->freeBlock(
head);
67 }
69 }
70}
static float next(float f)
◆ back() [1/2]
◆ back() [2/2]
const void * SkDeque::back |
( |
| ) |
const |
|
inline |
◆ count()
int SkDeque::count |
( |
| ) |
const |
|
inline |
◆ elemSize()
size_t SkDeque::elemSize |
( |
| ) |
const |
|
inline |
◆ empty()
bool SkDeque::empty |
( |
| ) |
const |
|
inline |
Definition at line 38 of file SkDeque.h.
38{ return 0 == fCount; }
◆ front() [1/2]
void * SkDeque::front |
( |
| ) |
|
|
inline |
◆ front() [2/2]
const void * SkDeque::front |
( |
| ) |
const |
|
inline |
◆ pop_back()
void SkDeque::pop_back |
( |
| ) |
|
Definition at line 187 of file SkDeque.cpp.
187 {
189 fCount -= 1;
190
191 Block* last = fBackBlock;
192
194
195 if (last->fEnd == nullptr) {
196 last = last->fPrev;
198 last->fNext = nullptr;
199 this->freeBlock(fBackBlock);
200 fBackBlock = last;
201 }
202
203 char*
end = last->fEnd - fElemSize;
205
206 if (
end > last->fBegin) {
209 fBack = last->fEnd - fElemSize;
210 } else {
211 last->fBegin = last->fEnd = nullptr;
212 if (nullptr == last->fPrev) {
213 fFront = fBack = nullptr;
214 } else {
216 fBack = last->fPrev->
fEnd - fElemSize;
217 }
218 }
219}
◆ pop_front()
void SkDeque::pop_front |
( |
| ) |
|
Definition at line 153 of file SkDeque.cpp.
153 {
155 fCount -= 1;
156
157 Block* first = fFrontBlock;
158
160
161 if (first->fBegin == nullptr) {
162 first = first->fNext;
164 first->fPrev = nullptr;
165 this->freeBlock(fFrontBlock);
166 fFrontBlock = first;
167 }
168
169 char*
begin = first->fBegin + fElemSize;
171
172 if (begin < fFrontBlock->fEnd) {
173 first->fBegin =
begin;
175 fFront = first->fBegin;
176 } else {
177 first->fBegin = first->fEnd = nullptr;
178 if (nullptr == first->fNext) {
179 fFront = fBack = nullptr;
180 } else {
182 fFront = first->fNext->fBegin;
183 }
184 }
185}
static const char * begin(const StringSlice &s)
◆ push_back()
void * SkDeque::push_back |
( |
| ) |
|
Definition at line 112 of file SkDeque.cpp.
112 {
113 fCount += 1;
114
115 if (nullptr == fBackBlock) {
116 fBackBlock = this->allocateBlock(fAllocCount);
117 fFrontBlock = fBackBlock;
118 }
119
120 Block* last = fBackBlock;
122
123 if (nullptr == last->fBegin) {
124 INIT_CHUNK:
125 last->fBegin = last->start();
126 end = last->fBegin + fElemSize;
127 } else {
128 end = last->fEnd + fElemSize;
129 if (
end > last->fStop) {
130
131 last = this->allocateBlock(fAllocCount);
132 last->fPrev = fBackBlock;
133 fBackBlock->
fNext = last;
134 fBackBlock = last;
135 goto INIT_CHUNK;
136 }
137 }
138
141
142 if (nullptr == fBack) {
144 fFront = fBack =
end;
145 } else {
148 }
149
151}
◆ push_front()
void * SkDeque::push_front |
( |
| ) |
|
push_front and push_back return a pointer to the memory space for the new element
Definition at line 72 of file SkDeque.cpp.
72 {
73 fCount += 1;
74
75 if (nullptr == fFrontBlock) {
76 fFrontBlock = this->allocateBlock(fAllocCount);
77 fBackBlock = fFrontBlock;
78 }
79
80 Block* first = fFrontBlock;
82
83 if (nullptr == first->fBegin) {
84 INIT_CHUNK:
85 first->fEnd = first->fStop;
86 begin = first->fStop - fElemSize;
87 } else {
88 begin = first->fBegin - fElemSize;
89 if (begin < first->
start()) {
90
91 first = this->allocateBlock(fAllocCount);
92 first->fNext = fFrontBlock;
93 fFrontBlock->
fPrev = first;
94 fFrontBlock = first;
95 goto INIT_CHUNK;
96 }
97 }
98
99 first->fBegin =
begin;
100
101 if (nullptr == fFront) {
103 fFront = fBack =
begin;
104 } else {
107 }
108
110}
◆ DequeUnitTestHelper
The documentation for this class was generated from the following files: