title: Data structure: Is there something like a two way observer pattern?
body: <p>So I have a scenario like this with classes Student and Course</p>
  
  <p>Student A is enrolled in Course 1, 2</p>
  
  <p>Student B is enrolled in Course 1, 2, 3</p>
  
  <p>Student C is enrolled in Course 2</p>
  
  <p>So there are two kinds of events:</p>
  
  <p>Student A is deleted -> need to notify two objects: Course 1 and Course 2 </p>
  
  <p>Course 1 is canceled -> need to notify two objects: Student A and Student B</p>
  
  <p>I know that the Observer pattern can work if each Student can be only enrolled in 1 Course, in which case I have a list of Student for each Course object in the Observer Pattern.</p>
  
  <p>I am wondering if I should do some two way Observer Pattern (Student keeps a list of Courses and the Course also keeps a list of students). So would be a good way to deal with this problem? Main concern is speed/space tradeoff (what I can think of at best now is a two way hash/tree from 1 Student to 1 set of Courses and 1 Course to 1 set of Students). Any pointer will be appreciated!! </p>