title: Procedural Generation of 2D Rooms
body: <p>I want to generate a complex of connected rooms. Every room can have 1-4 rooms next to it.</p>
  
  <p><img src="https://i.stack.imgur.com/lOaGo.jpg" alt="Room complex"></p>
  
  <p>My algorythm generates this complex of connected rooms.</p>
  
  <pre><code>public class Room
  {
      private Room top = null; //Connected rooms
      private Room right = null;
      private Room bottom = null;
      private Room left = null;
      private Vector2 roomOffset; //Position of the room
  }
  </code></pre>
  
  <p>Before creating a new room I want to check if there is already a room at the position of the new room. Is there an easier way than going through all rooms and checking if the position matches the position of the new room?</p>