title: Is it good practice to index a list of objects with a hashmap?
body: <p>I need to find objects by an attribute.</p>
  
  <p>One option is to iterate over an array of objects and check for each object that the attribute matches.</p>
  
  <p>The other option is to put the objects in a hashmap, with the attribute as key. Then one can simply retrieve the object by the attribute.</p>
  
  <p>Is the second option good practice, despite the fact that you duplicate the attribute data?</p>
  
  <p>Note: the attribute is assumed to be unique</p>