• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How can I do this..?

 
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello There,
I have a hashtable (say H) which is accessed by other objects. The access to H is read only.
At a later point of execution,I change the data stored in H . So any NEW object accessing H will get the latest data, the same applies to any object already refering H. How can I impose that any object already refering H ,should get access only to the old data, and not the changed data.
One way to do this is, instead of sharing H, each object which want to access H, is given a new cloned copy of H, so even if the data in H is changed, they can still get access to old data.
But if the size of H is considerably high, then creating a copy everytime will involve huge memory.
Any alternative way to achieve this..
Mohamed Zafer
 
author
Posts: 14112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You could use a chain of hashtables. Every time you change the data, you create a new hashtable with the changed data and a reference to the previous one. If the new hashtable doesn't find an object among its own data, it had to delegate the request to the previous one.
This way objects with old references wouldn't see the new data and you wouldn't have to duplicate the old data.
 
reply
    Bookmark Topic Watch Topic
  • New Topic