I have a key object that uses some of the proper memory also hash value in the key object and an equal method is applicable .
Now I want to put every unique key object in my memory only once and do not want to use the context of this object in the case of equality (equal ==).
I thought I could use a set but I could not find the original key object. I can only replace the existing one with a new one.
Keybject b = new keybiz ("a"); Boolean isiStrue = a.equals (b); Boolean is Is Flasse A == B; Maps & lt; Key object, value & gt; Bigmap = new hashmap & lt; & Gt; (); Maps & lt; Key object, value & gt; BigMapB = new hashmap & lt; & Gt; (); Largemapapp (A, "value A"); BigMapB.put (b, "value b");
Now I have two major key objects- one for each large map, but it will be enough for only one key object (a.equals (b)) and for this Use the reference map 2.
So I want something like this:
keyObject b = If there is already an equal item ("a") in my "cache" then "one" BigmapEpput (A, "value one"); BigMapB.put (b, "value b"); // Now I have a big key object / this is only a reference to
, the only solution to meditate is the loop entering the loopmapet and finds an equal key and Then it changes:
(Main Object: Bigmate.Cisat ()) {if (ko.equals (b)) {b = ko; break; }}
But this is not an executable solution ...
hashmap < KeyObject, KeyObject & gt;
, which is similar to the key value. -
if (map.contains (b))
will tell you that the key is in your cache. -
map.get (b)
will give you that key. - If the key is not included in the map, then you can put it there -
map.put (b, b)
Comments
Post a Comment