aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/SkDeque.cpp
diff options
context:
space:
mode:
authorGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2011-02-22 13:16:38 +0000
committerGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2011-02-22 13:16:38 +0000
commit4c09d5cd4b9e6f0be1352f62288efdedc1bc3de3 (patch)
tree5dc6c6edc01fe1e0e970e9befadc0859f2d26a81 /src/core/SkDeque.cpp
parentaff86f3fe3f286c5e93cb1f9d3f1c3a819b8cc12 (diff)
rename SkDeque::Iter to SkDeque::F2BIter, since it runs front-to-back (in preparation
for another iter that runs back-to-front (B2FIter). add unittest for Deque git-svn-id: http://skia.googlecode.com/svn/trunk@821 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/core/SkDeque.cpp')
-rw-r--r--src/core/SkDeque.cpp42
1 files changed, 21 insertions, 21 deletions
diff --git a/src/core/SkDeque.cpp b/src/core/SkDeque.cpp
index 4f15051012..2c6ce64fae 100644
--- a/src/core/SkDeque.cpp
+++ b/src/core/SkDeque.cpp
@@ -2,16 +2,16 @@
**
** Copyright 2006, The Android Open Source Project
**
-** Licensed under the Apache License, Version 2.0 (the "License");
-** you may not use this file except in compliance with the License.
-** You may obtain a copy of the License at
+** Licensed under the Apache License, Version 2.0 (the "License");
+** you may not use this file except in compliance with the License.
+** You may obtain a copy of the License at
**
-** http://www.apache.org/licenses/LICENSE-2.0
+** http://www.apache.org/licenses/LICENSE-2.0
**
-** Unless required by applicable law or agreed to in writing, software
-** distributed under the License is distributed on an "AS IS" BASIS,
-** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-** See the License for the specific language governing permissions and
+** Unless required by applicable law or agreed to in writing, software
+** distributed under the License is distributed on an "AS IS" BASIS,
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+** See the License for the specific language governing permissions and
** limitations under the License.
*/
@@ -25,10 +25,10 @@ struct SkDeque::Head {
char* fBegin; // start of used section in this chunk
char* fEnd; // end of used section in this chunk
char* fStop; // end of the allocated chunk
-
+
char* start() { return (char*)(this + 1); }
const char* start() const { return (const char*)(this + 1); }
-
+
void init(size_t size) {
fNext = fPrev = NULL;
fBegin = fEnd = NULL;
@@ -44,7 +44,7 @@ SkDeque::SkDeque(size_t elemSize)
SkDeque::SkDeque(size_t elemSize, void* storage, size_t storageSize)
: fElemSize(elemSize), fInitialStorage(storage), fCount(0) {
SkASSERT(storageSize == 0 || storage != NULL);
-
+
if (storageSize >= sizeof(Head) + elemSize) {
fFront = (Head*)storage;
fFront->init(storageSize);
@@ -69,7 +69,7 @@ SkDeque::~SkDeque() {
const void* SkDeque::front() const {
Head* front = fFront;
-
+
if (NULL == front) {
return NULL;
}
@@ -108,7 +108,7 @@ void* SkDeque::push_front() {
fFront->init(sizeof(Head) + INIT_ELEM_COUNT * fElemSize);
fBack = fFront; // update our linklist
}
-
+
Head* first = fFront;
char* begin;
@@ -144,7 +144,7 @@ void* SkDeque::push_back() {
fBack->init(sizeof(Head) + INIT_ELEM_COUNT * fElemSize);
fFront = fBack; // update our linklist
}
-
+
Head* last = fBack;
char* end;
@@ -178,7 +178,7 @@ void SkDeque::pop_front() {
Head* first = fFront;
SkASSERT(first != NULL);
-
+
if (first->fBegin == NULL) { // we were marked empty from before
first = first->fNext;
first->fPrev = NULL;
@@ -202,9 +202,9 @@ void SkDeque::pop_back() {
fCount -= 1;
Head* last = fBack;
-
+
SkASSERT(last != NULL);
-
+
if (last->fEnd == NULL) { // we were marked empty from before
last = last->fPrev;
last->fNext = NULL;
@@ -212,7 +212,7 @@ void SkDeque::pop_back() {
fBack = last;
SkASSERT(last != NULL); // else we popped too far
}
-
+
char* end = last->fEnd - fElemSize;
SkASSERT(end >= last->fBegin);
@@ -225,7 +225,7 @@ void SkDeque::pop_back() {
///////////////////////////////////////////////////////////////////////////////
-SkDeque::Iter::Iter(const SkDeque& d) : fElemSize(d.fElemSize) {
+SkDeque::F2BIter::F2BIter(const SkDeque& d) : fElemSize(d.fElemSize) {
fHead = d.fFront;
while (fHead != NULL && fHead->fBegin == NULL) {
fHead = fHead->fNext;
@@ -233,9 +233,9 @@ SkDeque::Iter::Iter(const SkDeque& d) : fElemSize(d.fElemSize) {
fPos = fHead ? fHead->fBegin : NULL;
}
-void* SkDeque::Iter::next() {
+void* SkDeque::F2BIter::next() {
char* pos = fPos;
-
+
if (pos) { // if we were valid, try to move to the next setting
char* next = pos + fElemSize;
SkASSERT(next <= fHead->fEnd);