• 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

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.
 
WARNING! Do not activate jet boots indoors or you will see a tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic