This effective use of Hashmap?

I have never actually used Hashmaps, well I have but just normal 2 parameter Hashmaps with a key value and a variable (or object).

Currently I have a level that can consist of any xx amount of Doors, which are essentially Tiles. Therefore upon loading the level I just chuck literally every single Tile into the same array. However this seems to be bad, well not bad as that is required for rendering anyway. What is bad about it is, I need access to very specific tiles in order to do certain things.

An example would be, I have a sliding door. This may be a single door, or double doors together. Every door as an ID which will be used to compare with things such as a key to unlock it.

Now if the doors are together I group them and assign them the same ID, however this has me having to iterate over an array that has 1024 (this is JUST test level) tiles in it, find the doors, get the position of it, check for doors surrounding it, then set there ID’s to the same. This is horrible.

So I am thinking this instead but no idea if this is the way to do it:



/**
	 * All the doors currently loaded into the level, this is used to directly
	 * get a door and it's ID to match a key or way of unlocking it
	 */
	public static HashMap<Integer, HashMap<Vector2, Door>> doors = new HashMap<Integer, HashMap<Vector2, Door>>();


In my case this:



public static HashMap<ID Of Door, HashMap<Door Position, Door>> doors = new HashMap<ID Of Door, HashMap<Door Position, Door>>();


Will this give me any problems? I will have to constantly get the doors in order to control locks. Any other way of doing it? As it stands atm in order to group the doors I have like 5-6 nested loops which check top, bottom, left, right, created hinges, check ID’s…really it is very messy but it works but won’t be easy to manage in the future.

Ideas?