all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Pascal J. Bourguignon" <pjb@informatimago.com>
To: emacs-devel@gnu.org
Subject: Re: remove-duplicates performances
Date: Fri, 20 May 2011 23:57:45 +0200	[thread overview]
Message-ID: <877h9lm3vq.fsf@kuiper.lan.informatimago.com> (raw)
In-Reply-To: jwvzkmhtfst.fsf-monnier+emacs@gnu.org

Stefan Monnier <monnier@iro.umontreal.ca> writes:

>>> Yes, i understand that, what i mean is you have to write a predicate
>>> each time, which could be inconvenient, instead of using :test 'equal.
>> With all due respect, you are proposing a hashtable as an alternate
>> mechanism.  A hashtable requires a hash function and an equality test.
>
> We do have a built-in hash function that corresponds to the `equal'
> equality test, as well as one for the `eq' equality test.
>
> Total ordering predicates consistent with `eq' or `equal' OTOH are not
> currently provided, so the use of `sort' requires extra work.

We can use a hash table when the test is eq, eql or equal (and
corresponding special cases when test-not is specified), or when the
user has defined a hash-table test with define-hash-table-test.  This
can be tested with (get test 'hash-table-test).

In the other cases, we cannot use a hash-table.

Notably, CL remove-duplicates and delete-duplicates are specified in
such a way that they can produce (sometimes) useful result when given
non equivalence relationships as test function.  I guess in those case
we have to fall back to the O(n²) algorithm.


And notice that the function to re-implement is cl-delete-duplicates,
since it's used by both remove-duplicates and delete-duplicates.

-- 
__Pascal Bourguignon__                     http://www.informatimago.com/
A bad day in () is better than a good day in {}.




  reply	other threads:[~2011-05-20 21:57 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-20 13:51 remove-duplicates performances Thierry Volpiatto
2011-05-20 14:09 ` Stefan Monnier
2011-05-20 14:39   ` Thierry Volpiatto
2011-05-20 16:14     ` Stefan Monnier
2011-05-20 17:46       ` Thierry Volpiatto
2011-05-20 15:16   ` Ted Zlatanov
2011-05-20 14:28 ` David Kastrup
2011-05-20 16:00   ` Thierry Volpiatto
2011-05-20 17:01     ` David Kastrup
2011-05-20 17:31       ` Thierry Volpiatto
2011-05-20 17:46         ` David Kastrup
2011-05-20 18:01           ` Stefan Monnier
2011-05-20 21:57             ` Pascal J. Bourguignon [this message]
2011-05-20 17:57       ` Ted Zlatanov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=877h9lm3vq.fsf@kuiper.lan.informatimago.com \
    --to=pjb@informatimago.com \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.