public void Add(TaggedVector obj) { if(previousEntityPosition.ContainsKey(obj.Identifier)) throw new Exception("The specified object is already being managed with this hashmap"); Point entityHash = Hash(obj); if(!cells.ContainsKey(entityHash)) cells.Add(entityHash, new List<TaggedVector>()); cells[entityHash].Add(obj); previousEntityPosition.Add(obj.Identifier, entityHash); }
private Point Hash(TaggedVector point) { Point p = new Point(((int)point.Position.X) / CellWidth, ((int)point.Position.Y) / CellHeight); return p; }