• 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
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

finding class attributes in a hash set

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I need help with HashSets
I have classes A with a String attribue "name".
I have a Hash set that contains a set of different classes B
each B is instantiated by passing A (to be stored as an attribute of B) along with other data.
I need to be able to change the name of an instance of A and have this change propogated to change the A attribute in all classes of B using that instance.
Does anyone know of a method to do this without iterating through the hashset of B's, as it's a big hash set?
Thanks in advance
luke
 
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


I need to be able to change the name of an instance of A and have this change propogated to change the A attribute in all classes of B using that instance.


Do you know the instance you want to modify?
If you already have a variable that reference it, then just do (suppose a is the variable that holds a reference to an instance of A):

Since you are only changing the state of the object, this modification will be "seen" by any other variables that point to this object's reference, even on class variable of B's intances in an HashSet.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic