title: Circular dependency with the relationships "contains" and "is in"
body: <p>I would like to gather opinion from you about the following problem.</p>
  
  <p>We have a class called "Room". Each room may contain zero or more instances of a class "Person", so the Room stores a collection of Persons (e.g. vector). It <strong>owns</strong> them. However, there is some time-consuming logic related to moving Persons between Rooms, so the Person also contains current Room they are in. It is just a <strong>pointer without ownership</strong>. This information is theoretically redundant, because one could derive it from the collections of Persons in rooms, but assuming large number of rooms >> number of people, such an operation would be slow...</p>
  
  <pre><code>class Room {
  std::vector&lt;Person&gt; peopleInside;
  };
  
  class Person {
  Room* currentRoom; //could be shared_ptr to avoid raw pointers
  };
  </code></pre>
  
  <p>Naturally, it is more complex (classes have more than this) but I have simplified it as much as possible.</p>
  
  <p>My questions are:</p>
  
  <p>1) In this situation, is this a circular dependency per se?</p>
  
  <p>2) Is this solution dirty/inelegant for you?</p>
  
  <p>3) Is it worth changing to something else?</p>