From 68f40fccf7e7ce4ffb12353d066fa896745bd4eb Mon Sep 17 00:00:00 2001 From: Karsten Heimrich Date: Sun, 5 Oct 2008 22:41:36 +0000 Subject: [PATCH] * cleanup git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27882 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kits/support/List.cpp | 58 +++++++++++++++++++-------------------- 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/src/kits/support/List.cpp b/src/kits/support/List.cpp index 80334f82db..f64eb9a0b1 100644 --- a/src/kits/support/List.cpp +++ b/src/kits/support/List.cpp @@ -224,7 +224,7 @@ bool BList::ReplaceItem(int32 index, void *newItem) { bool result = false; - + if (index >= 0 && index < fItemCount) { fObjectList[index] = newItem; result = true; @@ -257,44 +257,44 @@ bool BList::SwapItems(int32 indexA, int32 indexB) { bool result = false; - + if (indexA >= 0 && indexA < fItemCount && indexB >= 0 && indexB < fItemCount) { - + void *tmpItem = fObjectList[indexA]; fObjectList[indexA] = fObjectList[indexB]; fObjectList[indexB] = tmpItem; - + result = true; - } - + } + return result; } -//MoveItem - //This moves a list item from posititon a to position b, moving the appropriate block of - // list elements to make up for the move. For example, in the array: - // A B C D E F G H I J - // Moveing 1(B)->6(G) would result in this: - // A C D E F G B H I J +// MoveItem +// This moves a list item from posititon a to position b, moving the appropriate +// block of list elements to make up for the move. For example, in the array: +// A B C D E F G H I J +// Moveing 1(B)->6(G) would result in this: +// A C D E F G B H I J bool BList::MoveItem(int32 fromIndex, int32 toIndex) { - if ((fromIndex >= fItemCount) || (toIndex >= fItemCount) || (fromIndex < 0) || (toIndex < 0)) + if ((fromIndex >= fItemCount) || (toIndex >= fItemCount) || (fromIndex < 0) + || (toIndex < 0)) return false; - - if (fromIndex < toIndex) - { - void * tmp_mover = fObjectList[fromIndex]; - memmove(fObjectList + fromIndex + 1, fObjectList + fromIndex, (toIndex - fromIndex) * sizeof(void *)); - fObjectList[toIndex] = tmp_mover; - } - else if (fromIndex > toIndex) - { - void * tmp_mover = fObjectList[fromIndex]; - memmove(fObjectList + toIndex + 1, fObjectList + toIndex, (fromIndex - toIndex) * sizeof(void *)); - fObjectList[toIndex] = tmp_mover; + + if (fromIndex < toIndex) { + void * tmpMover = fObjectList[fromIndex]; + memmove(fObjectList + fromIndex + 1, fObjectList + fromIndex, + (toIndex - fromIndex) * sizeof(void *)); + fObjectList[toIndex] = tmpMover; + } else if (fromIndex > toIndex) { + void * tmpMover = fObjectList[fromIndex]; + memmove(fObjectList + toIndex + 1, fObjectList + toIndex, + (fromIndex - toIndex) * sizeof(void *)); + fObjectList[toIndex] = tmpMover; }; return true; } @@ -390,7 +390,7 @@ BList::IsEmpty() const /* Iterating over the list. */ //iterate a function over the whole list. If the function outputs a true //value, then the process is terminated. - + void BList::DoForEach(bool (*func)(void *)) { @@ -415,7 +415,7 @@ BList::DoForEach(bool (*func)(void *, void*), void * arg) if (func != NULL) { while ((!terminate) && (index < fItemCount)) - { + { terminate = func(fObjectList[index], arg); index++; }; @@ -478,9 +478,9 @@ BList::_ResizeArray(int32 count) if (newObjectList) { fObjectList = newObjectList; fPhysicalSize = newSize; - // set our lower bound to either 1/4 + // set our lower bound to either 1/4 //of the current physical size, or 0 - fResizeThreshold = fPhysicalSize >> 2 >= fBlockSize + fResizeThreshold = fPhysicalSize >> 2 >= fBlockSize ? fPhysicalSize >> 2 : 0; } else result = false;