Re: [Caml-list] How could I implement an efficient ring buffer?

2012-04-02 Thread Francois Berenger
On 04/02/2012 11:31 PM, Hongbo Zhang wrote: Hi List, I want to implement sliding window algorithm (in place, no memory copy), I wonder whether I need to write c code. Queues are described in Chris Okasaki's book, with a functional implementation in all senses of the term. If you don't want t

RE: [Caml-list] How could I implement an efficient ring buffer?

2012-04-02 Thread Jon Harrop
:dra-n...@metastack.com] > Sent: 02 April 2012 16:05 > To: Hongbo Zhang; Caml List > Subject: RE: [Caml-list] How could I implement an efficient ring buffer? > > Hongbo Zhang wrote: > > Hi List, > > I want to implement sliding window algorithm (in place, no

Re: [Caml-list] How could I implement an efficient ring buffer?

2012-04-02 Thread Benedikt Grundmann
Use core's Dequeue module. Cheers, Bene On 2 April 2012 15:31, Hongbo Zhang wrote: > Hi List, >   I want to implement sliding window algorithm (in place, no memory copy), I > wonder whether I need to write c code. > >   To make it clear and simple, >      In c, you can record the head pointer o

Re: [Caml-list] How could I implement an efficient ring buffer?

2012-04-02 Thread Gabriel Scherer
A small implementation of a FIFO queue implemented as a circular buffer of fixed length: type 'a circular_buffer = { mutable pos : int; mutable count : int; data : 'a array; size : int; } let create size dummy = { pos = 0; count = 0; data = Array.make size dummy; size; } let push

RE: [Caml-list] How could I implement an efficient ring buffer?

2012-04-02 Thread David Allsopp
Hongbo Zhang wrote: > Hi List, > I want to implement sliding window algorithm (in place, no memory > copy), I wonder whether I need to write c code. > > To make it clear and simple, >In c, you can record the head pointer of the array, and do the > modulo operations when get and set

[Caml-list] How could I implement an efficient ring buffer?

2012-04-02 Thread Hongbo Zhang
Hi List, I want to implement sliding window algorithm (in place, no memory copy), I wonder whether I need to write c code. To make it clear and simple, In c, you can record the head pointer of the array, and do the modulo operations when get and set In ocaml, it seems you hav