Lasty, I tried to implement a hybrid structure in Java, something similar:
public class MapOfSet<K, V extends HasKey<K>> implements Set<V>, Map<K, Set<V>>
Where HasKey is the following interface:
public interface HasKey<K> {
public K getKey();
}
Unfortunately, there are some conflicts between the methos signature of the Set interface and the Map interface in Java. I finally decided to implement only the Set interface and add the Map method without implementing this interface.
Do you see a more pleasant solution?
In response to the first comments, here is my goal:
Have a set structure and you can effectively access a subset of the values of this set that correspond to a given key value. At first I created a map and a set, but I tried to combine the two structures to optimize performance.
source
share