i'm looking to use the least resources for determining in what "area" (house) an event is. the best i came up with is only to check entrances and exists of houses, while the event is moving.
hash ENTRANCES holds all [x,y] of entrances as keys with the house number as value.
array EXITS holds only [x,y] of exits as its values.
now is there a speed/resource difference between:
1.for e in ENTRANCES.keys, if e == [x,y] HOME = ENTRANCES[e], then through EXIT hash setting value to 0 if found.
2.if ENTRANCE.include?([x,y]) HOUSE = ENTRANCE[x,y], elseif EXIT.include?([x,y]) HOUSE = 0.
my (fairly limited) understanding of hashes is telling me in method 2 it would determine the value same way as method 1 does. but i don't know if it really does. which might make the second slower because that would mean it checks it twice, once in include? and once in setting the value?
so is include? faster than the for loop?
is each faster than for?
also if there is a cleverer way anyone feels like sharing, i'm open to it.:p