java - Storing and comparing tree nodes in a Map -


i have following:

map<mynode, mynode> nodes = new hashmap<mynode, mynode>(); 

this map won't ever filled more 100 nodes @ time, don't have worry overhead. trying when create new node, , set contents of node. want check if node exact same contents exist in map. doing

maps.containskey();

but realized don't have same signature. though there might node exact same content, java different. question how can store node in map, , able check if node exact same contents exists?

class mynode     {         boolean end = false;         map<string, mynode> edges = new hashmap<string, mynode>();     } 

i haven't wrote own hashcode or equal. figured if use containskey tell me if equal

use own object. don't use node object unless can modify it. use own created object , override equals() (and hashcode()) methods determine if 2 such objects unique. work expected respect containskey() , other approach.


Comments

Popular posts from this blog

c++ - Delete matches in OpenCV (Keypoints and descriptors) -

java - Could not locate OpenAL library -

sorting - opencl Bitonic sort with 64 bits keys -