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

  • SEARCH
  • Home
  • 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 6227573
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T09:14:56+00:00 2026-05-24T09:14:56+00:00

In my application there is a multidimensional array with potentially a lot of data

  • 0

In my application there is a multidimensional array with potentially a lot of data so completely saving that object every time the user changes it seems unfeasible.

I read about the Command pattern and eventually found this article but I do not quite understand it. I’m not sure about how his code example works and whether or not this will work in my application. Also, is this “new” method preferable to the GoF pattern?

My application has tools like a brush and fill tool that work on the current document and I’m not really sure how to best implement undo/redo functionality but I know saving the state of the object for every operation would not allow for infinite undo’s and redo’s which is what I’m after. I’m not sure if the Command pattern can be used in this context or whether or not and how the article’s implementation works.

Hopefully someone can elaborate upon the article or perhaps explain how the Command pattern could be adapted to my needs. Thanks for reading!

  • 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-24T09:14:56+00:00Added an answer on May 24, 2026 at 9:14 am

    Create a class with three values (location, oldvalue, and newvalue, where location points to an element in your multidimensional array) and two methods (undo, redo). The on each operation, creat an array of these object for each element in your large array that changes, and push it onto an undo stack. When popping off the undo stack, call undo, and then push to a redo stack. Opposite for redo pop. Just remember to clear the redo stack with new actions.

    EDIT:

    Sample:

    public void undo()
    {
        location = oldvalue;
    }
    
    public void redo()
    {
        location = newvalue;
    }
    

    And then an example of the stacks:

    command = undoStack.Pop();
    command.undo();
    redoStack.Push(command);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my web application there is a process that queries data from all over
For my application there are several entity classes, User, Customer, Post, and so on
In my Rails application there is a model that has some has_one associations (this
In my application there are some configuration data, such as ipaddress, portno, title and
In every large application there is an ADMIN section. In such cases, when not
In the application there is a default report the user see's listing all the
In the app.config file of a .NET application there is a <runtime> element that
In my application there are courses which have steps. (A user proceeds though the
In my application there is a LabelField with text www.google.com When the user clicks,
In my application there are some cases that relatively small objects, (max 50 bytes)

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.