Sorry.....

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 on January 7th 2008 at 14:43:48


Message Thread


Reply to Message

In order to add a post to the WotB Message Board you must be a registered WotB user.

If you are not yet registered then please visit the registration page. You should ensure that their browser is setup to accept cookies.

Log in