Re: what is a stack
thufir.hawat_at_mail.com
Date: 07/16/04
- Next message: Tor Iver Wilhelmsen: "Re: test if a string is an integer?"
- Previous message: Tony Morris: "Re: test if a string is an integer?"
- In reply to: Liz: "Re: what is a stack"
- Next in thread: Sam: "Re: what is a stack"
- Reply: Sam: "Re: what is a stack"
- Reply: thufir.hawat_at_mail.com: "Re: what is a stack"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Thu, 15 Jul 2004 22:10:11 -0700
There's FILO and FIFO, they're both implemented as a regular old array (at
least as I learned it in FORTRAN).
////////////////////////////begin trivia///////////////////
FILO
if you enter [a,b,c,d] into a FILO array and then remove the elements,
you'll remove them as [d,c,b,a], which'd be how they were entered. this is
a stack. Consider a stack of plates in a cafeteria, plate "a" was put on
the stack first so it's on the bottom, and is the last one off.
FIFO
The reverse of a stack, aka a queue. If you enter [a,b,c,d] into a queue
you'd access them by pop(queue) which'd return an element. the element's
be returned in order of [a,b,c,d]. Think of standing in a queue at a bank
(as lotsa foreigners use the word queue (no offense to you foreigners
intended)): whoever's standing in line longest get's to the teller. The
inverse function of pop(queue) is push(element); ie push(e) would put "e"
at the end of the queue.
It get's more interesting when you use a second array to keep the place of
the nodes, which allows you to make circular lists, or even circular
linked lists.
In java, nowadays, it's all academic. The collections do all this
low-level stuff behind the scenes and use a consistent API to make it
portable.
/////////////////////////end trivia/////////////////
I think you're not really referring to stacks and queues in java per se,
but the heap and queue's in memory or something. AFAIK this is totally
opaque in java, so, in a sense, isn't "necesarry" to know. I think it's
related to garbage collection, which, in general, you're not supposed to
have to deal with. OTOH the more you know the better.
HTH,
Thufir Hawat
- Next message: Tor Iver Wilhelmsen: "Re: test if a string is an integer?"
- Previous message: Tony Morris: "Re: test if a string is an integer?"
- In reply to: Liz: "Re: what is a stack"
- Next in thread: Sam: "Re: what is a stack"
- Reply: Sam: "Re: what is a stack"
- Reply: thufir.hawat_at_mail.com: "Re: what is a stack"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|