While hash tables are one way of handling this, Kol's suggestion makes a lot of sense.