In one of the controllers of my angular application i have a variable set as follows.
SomeService.get({}, function(data){
// this sets xyz as the list of
No, you can't really avoid looping (O(n)
) unless there are some preconditions met.
O(log n)
).O(1)
.If those conditions are not fulfilled initially, but you need to access the items by id multiple times, it could be helpful to bring them in that form (sorting/building a hash map).