Is there a a container in Java to store objects with many-to-many relations?
As an example I want to implement a students - subjects database. A student can choose more than one subject and any subject can be studied by unlimited number of students. I want to do search of students by subject with constant or logarithmic time and the same applies to search of subjects by student.