I lied.
I forgot that I need to resize the stack if I make it smaller.
What I meant was............
using System;
using System.Collections;
namespace System.Collections
{
///
/// Stack class which when it reaches a given size drops the oldest item in the stack to allow the newest item to be pushed on.
///
public class MaxSizedStack: Stack
{
private int maxSize;
public MaxSizedStack(int maxSize)
{
this.maxSize = maxSize;
}
public int MaxSize {
get
{
return maxSize;
}
set
{
if(value0);
//Discard oldest item
invert.Pop();
do
{
base.Push(invert.Pop());
} while(invert.Count>0);
}
base.Push(obj);
}
}
}
Obviously.
Posted By: Johnny Comecardiff, Jan 7, 14:43:48
Written & Designed By Ben Graves 1999-2025