From: Jean-Christophe Filliatre <Jean-Christophe.Filliatre@lri.fr>
To: David.Mentre@irisa.fr (David Mentré)
Cc: caml-list@inria.fr
Subject: Re: Data structure efficiency questions
Date: Tue, 19 Sep 2000 09:41:34 +0200 (MEST) [thread overview]
Message-ID: <14791.6318.709323.906054@pc803> (raw)
In-Reply-To: <wd88zspohhq.fsf@parate.irisa.fr>
In his message of September 18, 2000, David=?iso-8859-1?Q?_Mentr=E9?= writes:
>
> 1. Is the @ operator costly or is it implemented as a simple pointers
> manipulation?
@ cannot be implemented as a simple pointer manipulation, because
lists are persistent data structures. It means that l1 and l2 must
remain the same lists after the evaluation of l1 @ l2.
If you look at the code of @ (in stdlib/pervasives.ml) you'll see that
the cons of l1 are duplicated. You cannot do otherwise to maintain the
persistence of lists. So the complexity of @ is linear in time and
space in the size of its first argument.
But, of course, you may define your own type of mutable lists, and
have a faster implementation of append in that case.
> 2. Somebody on this list told about a set-like data structure that was
> very efficient to give an answer when an element is NOT in the
> set. What is the name of this structure? Patricia tree? (I wasn't
> able to figure it out looking at the ml archives)
I distribute an implementation of sets and maps using Patricia trees
(when elements and keys are integers). They are not particularly fast
at determining that an element is NOT in the set (resp. the map). But
it is true that membership test is roughly twice faster than the
corresponding test with the ocaml standard library's AVL.
If you are interested, the code is here:
http://www.lri.fr/~filliatr/software.en.html
Best regards,
--
Jean-Christophe FILLIATRE
mailto:Jean-Christophe.Filliatre@lri.fr
http://www.lri.fr/~filliatr
next prev parent reply other threads:[~2000-09-19 17:44 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2000-09-18 15:19 David Mentré
2000-09-19 7:41 ` Jean-Christophe Filliatre [this message]
2000-09-19 20:07 ` Stefan Monnier
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=14791.6318.709323.906054@pc803 \
--to=jean-christophe.filliatre@lri.fr \
--cc=David.Mentre@irisa.fr \
--cc=caml-list@inria.fr \
/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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox