Lasty, I tried to implements an hybrid structure in Java, something that looks like:
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 methos signature of the Set interface and the Map interface in Java. I've finally chosen to implements only the Set interface and to add the Map method without implementing this interface.
Do you see a nicer solution?
In response to the first comments, here is my goal:
Have a set structure and be able to efficiently access to a subset of values of this set, corresponding to a given key value. At the beginning I instantiated a map and a set, but I tried to joined the two structures to optimize performances.