java - how to compare a set of characters with a map which keys are characters? -


If I have a set of characters that are called characters and contain the following characters (not Sorted) / P>

  'c'h' 'r' '' '' '' '' '' '' '' '' '/  
< P> And I have a map in which charts and strings of charts are set as values ​​for example

  Maps & lt; Set & lt; Character & gt; >, & Lt; String & gt; AMAP = new Hashmop & lt; Set & lt; Character & gt; >, & Lt; String & gt; (); Amap.put ('a''h''t', 'hat'); Amap.put ('o''g'd', 'dog'); Amap.put ('c''r' '' '' '' '' e ',' response ');  

I would use the Javasod method to compare the characters because they are both in a set, then walk through the key again. In order to compare the letters to use the loop, to compare only those keys, the first entry in the above example ('o'g' '' d ',' dog ' ') Will be eliminated.

Thanks

Andy

To make something comparable Your set call map.kitset ()

  public square setstates {public static zero main (string [] args) {set & lt; Characters & gt; Set = new hashet & lt; Character & gt; (); Hashmap & lt; Character, String & gt; Map = new hashmop & lt; Character, String & gt; (); (Four c: "Character". Cochrane ()) {set.add (c); Map.put (c, "some values"); } System.out.println (set + "==" + map.keySet () + set.containsAll (map.keySet ())); Set.remove ('C'); System.out.println (set + "+" "+ map.keySet () + set.containsAll (map.keySet ());}} [E, T, C, R, A, C, H] == [E, T, C, R, A, C, H] true [E, T, C, R, A, H] == [E, T, C, R, A, C, H] False > 

Comments