ImageViewerForm::CreateShuffledList(int count)
{
AppLogDebug("ENTER");
+
+ int origIndex = 0;
+ int curPos = 0;
if (__pShuffledList == null)
{
__pShuffledList = new (std::nothrow) int[count];
__pShuffledList[i] = i;
}
}
+ origIndex = __shuffelStartIndex;
+
for(int i = count - 1; i > 1; --i)
{
int randomNum = Math::Rand() % (i+1);
- int t = __pShuffledList[randomNum];
+ int shuffleIndex = __pShuffledList[randomNum];
__pShuffledList[randomNum] = __pShuffledList[i];
- __pShuffledList[i] = t;
+ __pShuffledList[i] = shuffleIndex;
+
+ if(shuffleIndex == origIndex)
+ {
+ curPos = i;
+ }
}
+
+ if(origIndex != __pShuffledList[__shuffelStartIndex])
+ {
+ int tempIndex = __pShuffledList[__shuffelStartIndex];
+ __pShuffledList[__shuffelStartIndex] = origIndex;
+ __pShuffledList[curPos] = tempIndex;
+ }
+
AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
}