I have a list of objects like this:
ArrayList<Phone> list = new ArrayList();
list.add(new Phone("+44 20 8765 4321", "mobile", "26"));
list.add(new Phone("+44 20 8765 4322", "home", "23"));
list.add(new Phone("+44 20 8765 4323", "mobile", "27"));
list.add(new Phone("+44 20 8765 4324", "work", "26"));
list.add(new Phone("+44 20 8765 4325", "home", "27"));
list.add(new Phone("+44 20 8765 4326", "home", "26"));
(23, 26, 27 being id's of the contact). How can I "query" this list to get ids of the contacts that have more than one telephone number {"26", "27"}
?
I need the optimal solution that doesn't store many small objects to memory (my poor implementation causes GC to run frequently, freezing the phone for a long periods of time).