Chris
Member
|
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 |
|
Esenthel
Administrator
|
RE: Copy two Memb<UInt> without duplicates
simple solution: REPA(b)a.include(b[i]);
|
|
01-26-2011 03:30 PM |
|
Chris
Member
|
RE: Copy two Memb<UInt> without duplicates
Neat trick! I missed that one in the header
Will try this, if performance is an issue will see if it can be optimized with sorting.
Thanks
|
|
01-26-2011 03:35 PM |
|