lcd wrote:

> On 21 March 2014, Cade Forester <ahx2...@gmail.com> wrote:
> > >     How about separating it from sort()?  That is, an uniq()
> > > function that would remove duplicates from an already sorted list
> > > (results would be undefined if the input list is not sorted).  That
> > > would be consistent with how uniq(1) works on UNIX.
> >
> > This patch add uniq() function. uniq(list) will remove copies of
> > repeated adjacent items
> 
>     There is a problem with this patch: it removes the duplicates on the
> fly, so if the comparison function fails on the second or subsequent
> call the list is still modified.  In contrast, sort() restores the list
> to the initial state if the comparison fails at some point.
> 
>     I'm attaching bellow my attempt to a fix.  I also merged f_sort()
> and f_uniq() in a single function, and made some minor optimisations.
> 
>     On a related topic: adding an efficient "stable unique" would be
> relatively straightforward too, using plain red-black trees.  Now,
> red-black trees are implemented as a header (namely sys/tree.h) on *BSD,
> but not on other systems.  Any comment on the preferred way to handle
> this?  I'd suggest testing for the existence of sys/tree.h in autoconf,
> and also including a stripped down copy of it from, say, OpenBSD, for
> the systems that don't have it.

There are a few problems with this implementation.

The li_prev pointer is not updated.  

When the first item is not a list the error is for sort(), even when
uniq() is used.


-- 
It is too bad that the speed of light hasn't kept pace with the
changes in CPU speed and network bandwidth. -- <wie...@porcupine.org>

 /// Bram Moolenaar -- b...@moolenaar.net -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to