Re: Efficiency of linq expression
Frans Bouma <[email protected]>
| Newsgroups | gmane.comp.windows.devel.dotnet.advanced |
|---|---|
| Message-ID | <001001c97404$aac2e3c0$0048ab40$@nl> |
Use Except()
(Intersect is its opposite method, they're efficient (done with an internal
(why would anyone want to use it, MS?) set class which is similar to a
hashset))
FB
> Here is the updated version:
>
> public override List<Callee> CalleesForInitialSend() {
> var mobile = new List<Callee>(Callees.Where(x => (x is
> MobileVoiceCallee)));
> var landLine = new List<Callee>(Callees.Where(x => (x is
> LandLineVoiceCallee)));
>
> var union = new List<Callee>();
> union.AddRange(mobile);
> union.AddRange(landLine);
>
> mobile.Join
> (
> landLine,
> mob => mob.Contact.Uid,
> land => land.Contact.Uid,
> (m, l) => l
> )
> .ForEach(x => union.Remove(x));
> return union;
> }
>
> 2009/1/11 Paul Cowan <[email protected]>
>
> > Hi,
> >
> > I have the following method that needs to run as fast as possible
> > (don't they all).
> >
> > I hope it is obvious that I want all mobile users and all landline
> > users who are not in the mobile list.
> >
> > I sincerelly doubt this is as efficient as it could be.
> >
> > Maybe somebody can point out a faster way of doing this:
> >
> > public override List<Callee> CalleesForInitialSend() {
> > var mobile = new List<Callee>(Callees.Where(x => (x is
> > MobileVoiceCallee)));
> > var landLine = new List<Callee>(Callees.Where(x => (x is
> > LandLineVoiceCallee)));
> >
> > mobile.Join
> > (
> > landLine,
> > mob => mob.Contact.Uid,
> > land => land.Contact.Uid,
> > (m, l) => l
> > )
> > .ForEach(x => mobile.Remove(x));
> >
> > return mobile;
> > }
> >
> >
> >
>
> ===================================
> View archives and manage your subscription(s) at
> http://peach.ease.lsoft.com/archives
===================================
View archives and manage your subscription(s) at http://peach.ease.lsoft.com/archives