I have a little bit of a confusion when it comes to what is considered the better implementation.
One the one hand,
LinkedHashMap provides the following benefits:
- Prevents duplicate items (I need to be able to prevent a scanned Bluetooth device to not repeatedly enter the list.)
- Provides easy access to items for updating values.
And the following pitfalls:
- Not supported naturally by the
BaseAdapterclass? I cannot seem to retrieve elements using
getItemfor a custom
However with an
- I can easily access items via their indices.
- Can easily replace items for updating values.
Works easily with custom
I receive duplicated items.
- I cannot easily compare or check with the
ArrayList.containsmethod unless I implement some custom
ArrayList's objects' parameters.
Is there an easier way to achieve the following:
- Scan via BLE, construct a custom object from the scan results. (already complete).
- Stick that custom object in an array list if it isn't already in it.
- If it is already in the array list, replace the previous object with the new one?