Hi,
I was wondering which implementation would have better performance:
I need to clear all items out of a stack except the first 10 at the head.
These 10 must then be placed into the stack in their orginal order.
I thought of 2 approaches
the first:
FilterRecord[] records = new FilterRecord[10];
for (int i = 0; i < records.Length; i++)
{
records[i] = _InternalCollection.Pop();
}
_InternalCollection.Clear();
for (int i = records.Length - 1; i >= 0; i--)
{
_InternalCollection.Push(records[i]);
}
The second:
int count = _InternalCollection.Count - 10;
_InternalCollection.Reverse();
for (int i = 0; i < count; i++)
{
_InternalCollection.Pop();
}
_InternalCollection.Reverse();
Any help or guidelines or other impemenations would be welcome.