Android Question Group records in a List

ThePuiu

Active Member
Licensed User
Longtime User
I have a List structure in which there are 4 columns.
id no customerid price
1 100 201 100
2 101 202 150
1 100 201 120

I'm interested in getting another list just to have only unique records:
id nr customerid
1 100 201
2 101 202

How to get that result as efficiently as possible? Thank you!
 

nwhitfield

Active Member
Licensed User
Longtime User
Are there any criteria for which instance of an id you want?

If not, how about making an empty map. Iterate over the list, and for each value, check if the map contansKey(id); if not, put it
 
Upvote 0

ThePuiu

Active Member
Licensed User
Longtime User
Are there any criteria for which instance of an id you want?

If not, how about making an empty map. Iterate over the list, and for each value, check if the map contansKey(id); if not, put it

No criteria. Iteration method is slow for a large number of recordings ...although it's probably the only way ...
 
Upvote 0

stevel05

Expert
Licensed User
Longtime User
A couple of questions. Where does the data come from? The list contains strings? If you want to search the data, you would be far better putting it into a SQLite database, then what you want to do is relatively simple.
 
Upvote 0

ThePuiu

Active Member
Licensed User
Longtime User
The data comes from a POST call through HttpJob (a Json string). After deserialization, a List object is obtained. Data from it is going to save the two local tables in SQLLite!
 
Upvote 0

stevel05

Expert
Licensed User
Longtime User
Probably fill the full table first, then fill the second table with the results from an SQL query using the DISTINCT method.
 
Upvote 0

ThePuiu

Active Member
Licensed User
Longtime User
I preferred to change the part of the webserver so that the computing power is superior.
 
Upvote 0

eps

Expert
Licensed User
Longtime User
If it were me... and there was 'no way' to get the unique customer ids from anywhere else as part of the web service I would do the following...

Create the Order table as it is.

Then scan the Order table and build a unique customer table.

Actually that's what @stevel05 recommended.

You have to do the first part anyway, the second part is an extra process but a really small one.

How many records are we talking about?

Can you not interrogate the web service to give you just unique customer ids or something? I guess this is outside of your control?
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…