135
Views
6
Comments
Maintain a unique list
I need a list of unique records. I can either check for duplicacy before entering a new record, OR I could remove all the duplicates at the end.

What's the most efficient way to do it? Is there a implementation available for the SET abstract data type?
2020-09-15 13-07-23
Kilian Hekhuis
 
MVP
It depends I think what kind of unique record list this is, how many elements it has etc. For example, you could use the TextDictionary system extension to maintain in parallel a dictionary for easy and efficient checking of duplicates.
UserImage.jpg
Vinay T
It is a record list. And it'll have 0-100 elements.
2020-09-15 13-07-23
Kilian Hekhuis
 
MVP
And how often do you need to insert one, i.e. how often do you need to check for duplicates? And where are those records coming from?
UserImage.jpg
Vinay T
The records are coming from different aggregates. Also, I don't really need to check for duplicates after every insert, I just need a unique list at the end.

The insert operation doesn't happen frequently as it is a small list. 

2016-04-21 20-09-55
J.
 
MVP
Imho make it simple with a for each check. If that is becoming too slow, refactor it.
2020-09-15 13-07-23
Kilian Hekhuis
 
MVP
Vinay,

The easiest way to ensure there are not duplicates is to check before adding. You can indeed follow up J's recommendation if it's infrequent and the list small, or when that becomes too slow, use TextDictionary to avoid duplicates.
Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.