Question in the Lounge
-
Here. I'm mulling over an idea that requires merging multiple lists. At some point in their history, the lists diverge and I need to make sure that when they combine, lists contain all the items. The sizes of the lists are in the thousands and are persisted. I just need to work out a way to merge them efficiently. Ideas? Name for the concept?
veni bibi saltavi
Nagy Vilmos wrote:
Name for the concept
Assuming no duplicates? So, what, "add distinct by"?
public static void AddRangeDistinctBy(this List target, IEnumerable src, Func equalityComparer)
{
src.ForEach(item =>
{
// no items in the list must match the item.
if (target.None(q => equalityComparer(q, item)))
{
target.Add(item);
}
});
}Inefficient and not thread safe but gets the job done.
Latest Article - Class-less Coding - Minimalist C# and Why F# and Function Programming Has Some Advantages Learning to code with python is like learning to swim with those little arm floaties. It gives you undeserved confidence and will eventually drown you. - DangerBunny Artificial intelligence is the only remedy for natural stupidity. - CDP1802
-
Here. I'm mulling over an idea that requires merging multiple lists. At some point in their history, the lists diverge and I need to make sure that when they combine, lists contain all the items. The sizes of the lists are in the thousands and are persisted. I just need to work out a way to merge them efficiently. Ideas? Name for the concept?
veni bibi saltavi
-
1. No programming questions in the lounge, and that is what is being asked for despite the wording. 2. Dump the data into a single list and select back only distinct items - the platform, tools, etc. are your choice.
Tim Carmichael wrote:
No programming questions in the lounge, and that is what is being asked for despite the wording.
That rule does not apply to members above a certain point level. :rolleyes:
There are two kinds of people in the world: those who can extrapolate from incomplete data. There are only 10 types of people in the world, those who understand binary and those who don't.
-
Here. I'm mulling over an idea that requires merging multiple lists. At some point in their history, the lists diverge and I need to make sure that when they combine, lists contain all the items. The sizes of the lists are in the thousands and are persisted. I just need to work out a way to merge them efficiently. Ideas? Name for the concept?
veni bibi saltavi
Wouldn't this simply be a "Union"? At least in SQL Server a union merges multiple result sets and filters out duplicate results (unless you use
UNION ALL
instead of justUNION
). I'd assume most frameworks employ a similiar concept (at the .Net Linq Method "Union" does this as well) -
I have a similar hell, myself. The company is spinning off a subsidiary and employees are being transferred to the subsidiary. The management hierarchy, during the transition, is such that a manage in one 'company' may be managing employees from the other or both. There's also a third 'company' which, except for a list of employees, is still a mystery to me. Meanwhile, people get privileges based upon their department and their group. If you picture these as Venn diagrams, they don't necessarily fully overlap - and the can cross over boundaries. Spread across multiple locations. Essentially, it's mapping an every changing number of many-to-many lists. The obvious answer is, of course, a view that lets you find all of each employees relationships. A long list, each employee (by uid, for example) occurring many times, mapping them to an ever changing state. The key to this is that the view, itself, needs to be modified as the management changes the rules and shuffles people about. Partly, it's manipulating/adding to UNION's - but also, how selections are made, and creating/destroying columns as nuances erupt. It's a game of whack-a-mole, but, once in place - and one bites the bullet that the solution will break - the logic of the view (views?) does the deed without causing damage.
"The difference between genius and stupidity is that genius has its limits." - Albert Einstein
"If you are searching for perfection in others, then you seek disappointment. If you are seek perfection in yourself, then you will find failure." - Balboos HaGadol Mar 2010
That's a great response to a question that should have been asked in another forum !
«While I complain of being able to see only a shadow of the past, I may be insensitive to reality as it is now, since I'm not at a stage of development where I'm capable of seeing it.» Claude Levi-Strauss (Tristes Tropiques, 1955)
-
Tim Carmichael wrote:
No programming questions in the lounge, and that is what is being asked for despite the wording.
That rule does not apply to members above a certain point level. :rolleyes:
There are two kinds of people in the world: those who can extrapolate from incomplete data. There are only 10 types of people in the world, those who understand binary and those who don't.
HappyFestivus wrote:
That rule does not apply to members above a certain point level.
Wrong !
«While I complain of being able to see only a shadow of the past, I may be insensitive to reality as it is now, since I'm not at a stage of development where I'm capable of seeing it.» Claude Levi-Strauss (Tristes Tropiques, 1955)
-
Here. I'm mulling over an idea that requires merging multiple lists. At some point in their history, the lists diverge and I need to make sure that when they combine, lists contain all the items. The sizes of the lists are in the thousands and are persisted. I just need to work out a way to merge them efficiently. Ideas? Name for the concept?
veni bibi saltavi
What do you think the Algorithms, Linq, and QA, forums are for ?
«While I complain of being able to see only a shadow of the past, I may be insensitive to reality as it is now, since I'm not at a stage of development where I'm capable of seeing it.» Claude Levi-Strauss (Tristes Tropiques, 1955)
-
Nagy Vilmos wrote:
Name for the concept
Assuming no duplicates? So, what, "add distinct by"?
public static void AddRangeDistinctBy(this List target, IEnumerable src, Func equalityComparer)
{
src.ForEach(item =>
{
// no items in the list must match the item.
if (target.None(q => equalityComparer(q, item)))
{
target.Add(item);
}
});
}Inefficient and not thread safe but gets the job done.
Latest Article - Class-less Coding - Minimalist C# and Why F# and Function Programming Has Some Advantages Learning to code with python is like learning to swim with those little arm floaties. It gives you undeserved confidence and will eventually drown you. - DangerBunny Artificial intelligence is the only remedy for natural stupidity. - CDP1802
That's a great response to a question that should have been asked in another forum !
«While I complain of being able to see only a shadow of the past, I may be insensitive to reality as it is now, since I'm not at a stage of development where I'm capable of seeing it.» Claude Levi-Strauss (Tristes Tropiques, 1955)
-
That's a great response to a question that should have been asked in another forum !
«While I complain of being able to see only a shadow of the past, I may be insensitive to reality as it is now, since I'm not at a stage of development where I'm capable of seeing it.» Claude Levi-Strauss (Tristes Tropiques, 1955)
BillWoodruff wrote:
That's a great response to a question that should have been asked in another forum !
We'll let it slide for Nagy. Heaven knows, I've gotten away with it. :laugh:
Latest Article - Class-less Coding - Minimalist C# and Why F# and Function Programming Has Some Advantages Learning to code with python is like learning to swim with those little arm floaties. It gives you undeserved confidence and will eventually drown you. - DangerBunny Artificial intelligence is the only remedy for natural stupidity. - CDP1802
-
BillWoodruff wrote:
That's a great response to a question that should have been asked in another forum !
We'll let it slide for Nagy. Heaven knows, I've gotten away with it. :laugh:
Latest Article - Class-less Coding - Minimalist C# and Why F# and Function Programming Has Some Advantages Learning to code with python is like learning to swim with those little arm floaties. It gives you undeserved confidence and will eventually drown you. - DangerBunny Artificial intelligence is the only remedy for natural stupidity. - CDP1802
Marc Clifton wrote:
We'll let it slide for Nagy
You walk on water, Nagy walks on air :)
«While I complain of being able to see only a shadow of the past, I may be insensitive to reality as it is now, since I'm not at a stage of development where I'm capable of seeing it.» Claude Levi-Strauss (Tristes Tropiques, 1955)
-
HappyFestivus wrote:
That rule does not apply to members above a certain point level.
Wrong !
«While I complain of being able to see only a shadow of the past, I may be insensitive to reality as it is now, since I'm not at a stage of development where I'm capable of seeing it.» Claude Levi-Strauss (Tristes Tropiques, 1955)
BillWoodruff wrote:
Wrong !
He meant to say reputation, and no I don't mean the numerical thing in our profiles. I get away with lots of things that are supposedly against the rules. Nothing to do with Maunder twice leaving a drinking session before it had really even begun.
Michael Martin Australia "I controlled my laughter and simple said "No,I am very busy,so I can't write any code for you". The moment they heard this all the smiling face turned into a sad looking face and one of them farted. So I had to leave the place as soon as possible." - Mr.Prakash One Fine Saturday. 24/04/2004