caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Brian Hurt <bhurt@janestcapital.com>
To: Luca de Alfaro <luca@dealfaro.org>
Cc: Jon Harrop <jon@ffconsultancy.com>, caml-list@yquem.inria.fr
Subject: Re: [Caml-list] Vec: a functional implementation of extensible arrays
Date: Fri, 20 Jul 2007 12:45:04 -0400	[thread overview]
Message-ID: <46A0E690.2060805@janestcapital.com> (raw)
In-Reply-To: <28fa90930707200842q742d5f77y29885d0c7ebcc74c@mail.gmail.com>

Luca de Alfaro wrote:

>
>
> This is almost easy.  I would need to add a bit to each node to keep 
> track of whether it's balanced...
> The penalty would be that the balancing function would need to do 
> slightly more work to find out what has to be balanced.
> So perhaps it's not a good idea for append, insert, but it could make 
> sense for concat (?), and especially for filter and sub...
> But I am hesitant.  If one does concat, or one does sub to extract a 
> sub-array, I wrote the code already so that sharing is maximized. What 
> is the percentage of cases in which you get a Vec, but then don't do 
> any get/set on it, and only iterate?
> Especially since you already have iterators on subranges?  Do you 
> think it's worth it?  Anyone has advice?

I don't think that with laziness you can avoid enough work to make 
inserts O(1).

On the other hand, sub and filter can be done in O(M + log N) easily 
enough, see:
http://citeseer.ist.psu.edu/236207.html

The paper is about red-black trees, but it's applicable to all 
rotation-balanced trees.

Brian


      reply	other threads:[~2007-07-20 16:45 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-07-18 17:32 Luca de Alfaro
2007-07-19  7:45 ` [Caml-list] " Loup Vaillant
2007-07-19  8:17   ` Hugo Ferreira
2007-07-19 16:51     ` Luca de Alfaro
2007-07-19 17:13     ` Luca de Alfaro
2007-07-19 16:59   ` Luca de Alfaro
2007-07-20  7:35     ` Loup Vaillant
2007-07-20  8:14       ` Jon Harrop
2007-07-20 15:42         ` Luca de Alfaro
2007-07-20 16:45           ` Brian Hurt [this message]

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=46A0E690.2060805@janestcapital.com \
    --to=bhurt@janestcapital.com \
    --cc=caml-list@yquem.inria.fr \
    --cc=jon@ffconsultancy.com \
    --cc=luca@dealfaro.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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).