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 6002581
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T00:59:56+00:00 2026-05-23T00:59:56+00:00

public class Example { public Example duplicate; public void duplicateState() { this.example = this.clone();

  • 0
public class Example {
    public Example duplicate;

    public void duplicateState() {
        this.example = this.clone();
    }

    public void loadDuplicate() {
        // implementation
    }
}

Looking at the above example, you can see that I need to duplicate the Example instance. This is so that objects that want to modify Example must instead modify the duplicate, allowing the main instance to run routines without critical variables being changed. Periodically, the Example will load the duplicate’s values and so that it can perform the routines with updated variables. Performance is critical in this. Does anyone know how to implement the loadDuplicate function in the fastest possible way, or are there any other ways to approach this problem?

  • 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-23T00:59:57+00:00Added an answer on May 23, 2026 at 12:59 am

    If you really need the fastest performance, then both duplicateState() and loadDuplicate() should consist of a sequence of assignments of the fields of Example.

    Both cloning and serialization will be significantly slower, though “how much” will depend on the number of fields and their types.

    The other question is whether you need to do a deep or shallow copy of the state of an Example. Clone (using the default clone() method will give you a shallow copy, and serialization will give you a (recursively) deep copy.

    (FWIW – the last point is a reason why serialization will be slower than cloning. Another is that serialization also needs to include metadata in the serial form … and that’s more data to be copied.)

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

Sidebar

Related Questions

Earlier I asked why this is considered bad: class Example { public: Example(void); ~Example(void);
Please consider this example class: [Serializable] public class SomeClass { private DateTime _SomeDateTime; public
Consider following example : public class SomeBusinessLayerService : DataService<MyEntityContainer> { [WebInvoke] void DoSomething(string someParam)
What does it mean to call a class like this: class Example { public:
take a look at this example code: public class Comment { private Comment() {
Possible Duplicate: String equality vs equality of location public class AboutStrings{ public static void
I have an example class defined like below: public class FooBar { void method1(Foo
Suppose I've got the following program: namespace ReflectionTest { public class Example { private
As an example: public class Foo { private Foo() {} } public class Bar
For example: public class A : A.B { public class B { } }

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.