* Data structure efficiency questions
@ 2000-09-18 15:19 David Mentré
2000-09-19 7:41 ` Jean-Christophe Filliatre
0 siblings, 1 reply; 3+ messages in thread
From: David Mentré @ 2000-09-18 15:19 UTC (permalink / raw)
To: caml-list
Hello all camlists,
1. Is the @ operator costly or is it implemented as a simple pointers
manipulation?
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)
Thanks a lot,
d.
--
David.Mentre@irisa.fr -- http://www.irisa.fr/prive/dmentre/
Opinions expressed here are only mine.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Data structure efficiency questions
2000-09-18 15:19 Data structure efficiency questions David Mentré
@ 2000-09-19 7:41 ` Jean-Christophe Filliatre
2000-09-19 20:07 ` Stefan Monnier
0 siblings, 1 reply; 3+ messages in thread
From: Jean-Christophe Filliatre @ 2000-09-19 7:41 UTC (permalink / raw)
To: David Mentré; +Cc: caml-list
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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Data structure efficiency questions
2000-09-19 7:41 ` Jean-Christophe Filliatre
@ 2000-09-19 20:07 ` Stefan Monnier
0 siblings, 0 replies; 3+ messages in thread
From: Stefan Monnier @ 2000-09-19 20:07 UTC (permalink / raw)
To: caml-list
>>>>> "Jean-Christophe" == Jean-Christophe Filliatre <Jean-Christophe.Filliatre@lri.fr> writes:
> 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?
I'm not sure what you mean by "not costly" since the "pointer manipulation"
still requires to go down one of the lists.
> @ 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.
You could of course have a list datatype as (pardon the SML syntax):
datatype 'a list = Nil | Cons of 'a * 'a list | @ of 'a list * 'a list
Although this probably wouldn't be described as "pointer manipulation".
Stefan
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2000-09-20 19:50 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-09-18 15:19 Data structure efficiency questions David Mentré
2000-09-19 7:41 ` Jean-Christophe Filliatre
2000-09-19 20:07 ` Stefan Monnier
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox