emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: Suggestions to remove one alist's members from another


From: Drew Adams
Subject: RE: Suggestions to remove one alist's members from another
Date: Fri, 9 Apr 2010 07:45:19 -0700

> >> If not, my thought is this: when the list was over some size
> >> I'd determine experimentally, it would instead build a hash
> >> table from in-list and hit the not-alist against that.  When
> >> complete it would unfortunately require a second pass
> >> through the in-alist to return it maintaining the original
> >> order.
> >
> >Why not build a hash table (of the cars of the elements) 
> >from not-alist instead?  Then you can just walk in-alist,
> >skipping elements that are in the hash (that is, whose
> >cars are in it) and adding the rest to out-alist
> >and (their cars to) the hash.
> 
> Thanks, that's a good improvement. I also would add each
> in-list element after each test for hash membership, as I
> want to eliminate duplicates.
> 
> It still seems like this should already exist somewhere...

Well, there are the `[n]set-difference' sequence functions (in cl-seq.el), but
they're not O(1). You might want to take a look at them anyway.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]