I have a list<MyObject>
(java LinkedList
). Each object has a key and a value property.
Client 1 need the entire list.
Client 2 will pass a key and expect a value in return
Client 3 will pass a value and expect a key in return.
The question is, since Java collections use pointers to actual objects rather than store the object, would it worthwhile storing two more maps.
Map<key, MyObject>
to serve Client 2.(java HashMap
)
Map<value, MyObject>
to serve Client 3. (java HashMap
)
This would save processing time involved in iterating through the entire list (list<MyObject>
) and finding the matching key or value.