Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

info on stack structure  RSS feed

 
fred fredricks
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello!
could someone help me out a little, i have to dig up information on Stack structure..ir its features and its main operations...
where can i find this kind of information??
or could some1 who knows a lot help me out???
thanks!!
ahhh, another question i have to answer is about run-time activation record stack?
my text book is not that good.....thanks!!!
 
Joel McNary
Bartender
Posts: 1840
Eclipse IDE Java Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A stack is simply an ordered collection of objects in which only the "top" object is accessable.
You can add an object to the stack, making that object the new "top" object. This is called "pushing."
You can remove the "top" object from the stack, revealing the next object as the "top" object. This is called "popping."
The easiest way to envision this is a stack of playing cards. You start with an empty stack. Then push the Ace of diamonds onto the stack (lay it face up on the table.) Push the Three of Clubs onto the stack (put the Three down overtop the Ace; only the Three is visible). Push the Queen of Hearts onto the stack. Now, pop off the Queen. The Three is now the "top" card. Push the Jack of Spades. etc.
This is usually/most easily implemented as a List that prevents access to any object but the first. The class usually defines a "void push(Object)" and an "Object pop()" method; an "Object view()" is optional but useful (This would look at the top object without removing it from the stack- essentially, a call to "get(0)").
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also, in my experience, Stacks often provide an isEmpty() or empty() method to let the user know whether the Stack is empty.
 
Amit Gulhane
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For the Stack sample code.
For Stack trace tutotrial
Amit Gulhane
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!