* cleanup
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27882 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
+18
-18
@@ -272,29 +272,29 @@ BList::SwapItems(int32 indexA, int32 indexB)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//MoveItem
|
// MoveItem
|
||||||
//This moves a list item from posititon a to position b, moving the appropriate block of
|
// This moves a list item from posititon a to position b, moving the appropriate
|
||||||
// list elements to make up for the move. For example, in the array:
|
// 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
|
// A B C D E F G H I J
|
||||||
// Moveing 1(B)->6(G) would result in this:
|
// Moveing 1(B)->6(G) would result in this:
|
||||||
// A C D E F G B H I J
|
// A C D E F G B H I J
|
||||||
bool
|
bool
|
||||||
BList::MoveItem(int32 fromIndex, int32 toIndex)
|
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;
|
return false;
|
||||||
|
|
||||||
if (fromIndex < toIndex)
|
if (fromIndex < toIndex) {
|
||||||
{
|
void * tmpMover = fObjectList[fromIndex];
|
||||||
void * tmp_mover = fObjectList[fromIndex];
|
memmove(fObjectList + fromIndex + 1, fObjectList + fromIndex,
|
||||||
memmove(fObjectList + fromIndex + 1, fObjectList + fromIndex, (toIndex - fromIndex) * sizeof(void *));
|
(toIndex - fromIndex) * sizeof(void *));
|
||||||
fObjectList[toIndex] = tmp_mover;
|
fObjectList[toIndex] = tmpMover;
|
||||||
}
|
} else if (fromIndex > toIndex) {
|
||||||
else if (fromIndex > toIndex)
|
void * tmpMover = fObjectList[fromIndex];
|
||||||
{
|
memmove(fObjectList + toIndex + 1, fObjectList + toIndex,
|
||||||
void * tmp_mover = fObjectList[fromIndex];
|
(fromIndex - toIndex) * sizeof(void *));
|
||||||
memmove(fObjectList + toIndex + 1, fObjectList + toIndex, (fromIndex - toIndex) * sizeof(void *));
|
fObjectList[toIndex] = tmpMover;
|
||||||
fObjectList[toIndex] = tmp_mover;
|
|
||||||
};
|
};
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user