Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 571557
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T13:31:11+00:00 2026-05-13T13:31:11+00:00

We have all read about or heard about the stack class, but many of

  • 0

We have all read about or heard about the stack class, but many of us have probably never found a reason to use the LIFO object. I am curious to hear of real world solutions that used this object and why.

http://msdn.microsoft.com/en-us/library/system.collections.stack.aspx

I recently saw an example where a programmer used a stack to keep track of his current position while traversing a hierarchical data source. As he moved down the hierarchy, he pushed his position identifier on to the stack and as he moved back up he popped items off the stack. I thought this was a very efficent way to keep track of his current position in a mamoth hierarchy. I had never seen this before.

Anyone else have any examples?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T13:31:11+00:00Added an answer on May 13, 2026 at 1:31 pm

    I’ve used them to keep track of Undo and Redo actions.

    I use an interface something like this:

    interface ICommand
    {
        void Execute();
        void Undo();
        string Description { get; }
    }
    

    Undo and Redo are both of type Stack<ICommand>. Then I create a concrete class for a given action. In the class’s constructor, I pass in any information I’d need to hold on to. Execute does the action initially, and also redoes it; Undo undoes it, obviously. It works like this:

    • Undo an action: Pop the Undo stack and add to the Redo stack.
    • Redo an undone action: Pop the Redo stack and add to the Undo stack again.
    • Perform a new action: Add to the Undo stack and clear the Redo stack (since the state is no longer consistent).

    I found that you have to take care that you’re really undoing what was done. For instance, say you have a UI with two listboxes, and each has five items in it. Your action might be to click a button to move everything on the left list to the right list (so it now has ten, and the left list has zero).

    The undo action is not to move everything back; the undo action is to move back only the five you actually moved, and leave the others.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 275k
  • Answers 275k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer cd /tmp find . -maxdepth 1 -mindepth 1 -type d… May 13, 2026 at 2:40 pm
  • Editorial Team
    Editorial Team added an answer I found the problem , my created certificate was out… May 13, 2026 at 2:40 pm
  • Editorial Team
    Editorial Team added an answer Ideally, you would use the MVVM design pattern to do… May 13, 2026 at 2:40 pm

Related Questions

I have always loved the idea of AI and evolutionary algorithms. Unfortunately, as we
The problem: We use a program written by our biggest customer to receive orders,
Ok as programmers we all follow programming standards (as in W3 standards, or C++
I'm working on an application that has to process audio files. When using mp3
We have a large application mainly written in SQL Server 7.0, where all database

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.