Replying to a message of Darryl Gregorash to James Vahn:
DG> If you have a stack, then you only need one pointer, unless
DG> you absolutely must preserve the first unread byte written
DG> to the stack (and I don't know why anyone would want to do
DG> that).. you always read and write using it. Increment and
DG> write, read and decrement.
Well, this is of course incorrect even for a circular stack.. there must be
some condition to determine stack underflow. Overflow isn't a problem with a
circular stack, unless you need to check if it has happened for some reason..
but to determine underflow in a circular stack, either you need a second
pointer, or you need a DB containing the number of elements currently on the
stack. I prefer the second method myself.
--- FleetStreet 1.21 NR
---------------
* Origin: BIG BANG Burger Bar: Regina SK Canada (1:140/86)
|