From: "Frédéric Bour" <frederic.bour@lakaban.net>
To: Francois Berenger <francois.berenger@inria.fr>
Cc: OCaml List <caml-list@inria.fr>
Subject: Re: [Caml-list] Do we have a B-tree implementation in ocaml?
Date: Thu, 05 Nov 2015 11:34:34 +0100 [thread overview]
Message-ID: <1446719674.22101.0@mail.lakaban.net> (raw)
In-Reply-To: <563A42E9.7010008@inria.fr>
[-- Attachment #1: Type: text/plain, Size: 1460 bytes --]
If I understand well, you want an efficient rank function on a
sequence, you are not particularly interested in B-trees.
I have an implementation of balanced trees you might be interested into:
https://github.com/def-lkb/grenier/blob/master/baltree/bt1.mli
It is a binary tree with a smart constructor to ensure only balanced
trees are built.
Beside that, no other constraints are applied. In particular these are
not search trees although those can easily be implemented on top.
O(1) access to the size (number of items) is provided, and as such an
O(log n) rank function.
Performance is also quite competitive: although I did not push the code
yet, I implemented Map and Set from the standard library using these
trees. On a small set of benchmarks I ran, these were at worst 10%
slower than the standard ones.
On Wed, Nov 4, 2015 at 6:39 PM, Francois Berenger
<francois.berenger@inria.fr> wrote:
> Hello,
>
> I am looking for even a simple implementation with at
> least the following operations:
>
> insert/add, remove, mem/contains and at_rank.
>
> The at_rank is especially important since it is inefficient
> to implement it using fold in a set like the ones from the stdlib.
>
> Thanks a lot,
> F.
>
> --
> Caml-list mailing list. Subscription management and archives:
> https://sympa.inria.fr/sympa/arc/caml-list
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> Bug reports: http://caml.inria.fr/bin/caml-bugs
[-- Attachment #2: Type: text/html, Size: 1961 bytes --]
next prev parent reply other threads:[~2015-11-05 10:35 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-04 17:39 Francois Berenger
2015-11-05 10:34 ` Frédéric Bour [this message]
2015-11-06 21:04 ` Tom Ridge
2015-11-10 14:37 ` Simon Cruanes
2015-11-10 23:11 ` Hendrik Boom
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=1446719674.22101.0@mail.lakaban.net \
--to=frederic.bour@lakaban.net \
--cc=caml-list@inria.fr \
--cc=francois.berenger@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