About Store Forum Documentation Contact



Post Reply 
Copy two Memb<UInt> without duplicates
Author Message
Chris Offline
Member

Post: #1
Copy two Memb<UInt> without duplicates
Hi, I have lots of tiny Memb<UInt> containers. Each contain about 5-8 elements. There are already several duplicate UInts in the containers. I want a function:

void copy(Memb<UInt> &a, C Memb<UInt> &b) {
// copy contents from b into a, but don't allow for duplicate UInts
}

This will likely be called 5 to 30 times for each container.

Any ideas on an elegant way to do this? Should I consider sorting? Or is my only option checking each element in two nested loops.

Thanks for your thoughts,
Chris
01-26-2011 03:06 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #2
RE: Copy two Memb<UInt> without duplicates
simple solution: REPA(b)a.include(b[i]);
01-26-2011 03:30 PM
Find all posts by this user Quote this message in a reply
Chris Offline
Member

Post: #3
RE: Copy two Memb<UInt> without duplicates
Neat trick! I missed that one in the header smile
Will try this, if performance is an issue will see if it can be optimized with sorting.

Thanks
01-26-2011 03:35 PM
Find all posts by this user Quote this message in a reply
Post Reply