does c++ offer diffs of datastrucures?

This is a discussion on does c++ offer diffs of datastrucures? within the C++ Programming forums, part of the General Programming Boards category; Hi all, I'm facing the following situation: I've a complex simulation model of a type of vehicle. Inside a distributed ...

  1. #1
    Registered User
    Join Date
    Nov 2006
    Posts
    519

    does c++ offer diffs of datastrucures?

    Hi all,

    I'm facing the following situation:
    I've a complex simulation model of a type of vehicle. Inside a distributed simulation environment client A updates the model in every cycle. That can be a lot of updates per step for a fast driving, steering, braking, firing, jumping, sliding vehicle object. on the other side, if it just stands still, nearly no updates take place.

    a good simulation of course offers the possibility to slide through time. for example you can command it to go back to the last point in time then the speed equals 50 km/h. To implement such a feature excessive state logging is needed.
    normally the model controller would log together with updating the model state (position of wheel 1 changed -> log that fact).
    In a distributed environment this approach has the drawback that the logging data of all clients has to be consistent. this can become hard if vehicles can be hot-swapped due to last-balancing constraints from client A to B while the simulation runs.

    The easier looking approach is to have a single client looking up the shared memory holding the simulation state gathered by all clients and log them every cycle. but because of the high model complexity, this can be a very disc intensive task. fortunately the number of unchanged model data is much higher than the number of changed model data in average, so it would be a lot faster to just log the differences.
    For a model with 1000 data entries this means 1000 comparisons to code. Thats nothing for a lazy programmer. My approach for now is to use regular-expressions to transform the data model into the comparison code. Thats easy, but I'm asking myself if C++ maybe offers some elegant technique to do diffs on data structures itself?

  2. #2
    Ethernal Noob
    Join Date
    Nov 2001
    Posts
    1,901

  3. #3
    Registered User
    Join Date
    Nov 2006
    Posts
    519
    The link says:

    The header <algorithm> defines a collection of functions especially designed to be used on ranges of elements.

    A range is any sequence of objects that can be accessed through iterators or pointers, such as an array or an instance of some of the STL containers.
    So does that also apply to structures? Can I for example use for_each to iterate through the member of structs? That would be great. And would that also respect alignment issues?

  4. #4
    Ethernal Noob
    Join Date
    Nov 2001
    Posts
    1,901
    Well, you can give iterator like access to your struct/class and the algorithms could be used on it.

  5. #5
    Registered User
    Join Date
    Nov 2006
    Posts
    519
    Ok, thanks. But could adding members to a struct change the way the struct is represented in RAM? On constraint I've to respect are other subsystems which does rely on a constant memory representation of all data structures. for example there is a client which renders the images and another which calculates viewability constraints between dynamic objects and so on. all of that just grab the data structure and rely on that on offset 50 is the position of wheel 1 for example

  6. #6
    Registered User
    Join Date
    Nov 2006
    Posts
    519
    Oh and does anybody know a good reference how to implement own iterators?
    I guess they have to be derived from a abstract base and need some operators (++, --) ?

  7. #7
    Ethernal Noob
    Join Date
    Nov 2001
    Posts
    1,901

  8. #8
    Registered User
    Join Date
    Nov 2006
    Posts
    519
    Great, thank you very much!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. why doesnt the C++ standard library committee offer any AUI related libararie?
    By Masterx in forum A Brief History of Cprogramming.com
    Replies: 3
    Last Post: 02-13-2009, 01:48 PM
  2. SMS provider that offer SMS shipping world-wide for under 0,05 ???
    By gicio in forum A Brief History of Cprogramming.com
    Replies: 1
    Last Post: 05-26-2003, 09:26 PM
  3. Can anyone offer an example on this?
    By drdroid in forum C++ Programming
    Replies: 8
    Last Post: 10-09-2002, 01:16 AM
  4. My job offer!!
    By Inept Pig in forum A Brief History of Cprogramming.com
    Replies: 4
    Last Post: 07-09-2002, 10:19 AM
  5. What dose C# offer over C++?
    By Eber Kain in forum C# Programming
    Replies: 8
    Last Post: 11-27-2001, 05:15 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21