From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by walapai.inria.fr (8.13.6/8.13.6) with ESMTP id q3306beP022381 for ; Tue, 3 Apr 2012 02:06:38 +0200 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Av0BADw+ek+GoCGhmWdsb2JhbABFgw+xbIMmAQEBAQEICwsHFCeCCQEBBAE4QAYLCxgJFg8JAwIBAgFFEwgBAYgABbsLjUqDJASIVo0LhXCNNQ X-IronPort-AV: E=Sophos;i="4.75,359,1330902000"; d="scan'208";a="138780386" Received: from postman1.riken.jp (HELO postman.riken.jp) ([134.160.33.161]) by mail4-smtp-sop.national.inria.fr with ESMTP; 03 Apr 2012 02:06:31 +0200 Received: from postman.riken.jp (postman1.riken.jp [127.0.0.1]) by postman.riken.jp (Postfix) with SMTP id CC0EE32C0160 for ; Tue, 3 Apr 2012 09:06:27 +0900 (JST) Received: from [172.27.98.103] (rikad98.riken.jp [134.160.214.98]) by postman.riken.jp (Postfix) with ESMTPA id AD7E732A008B for ; Tue, 3 Apr 2012 09:06:27 +0900 (JST) Message-ID: <4F7A3F00.3070709@riken.jp> Date: Tue, 03 Apr 2012 09:06:24 +0900 From: Francois Berenger User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.28) Gecko/20120313 Thunderbird/3.1.20 MIME-Version: 1.0 To: caml-list@inria.fr References: <4F79B858.2090502@gmail.com> In-Reply-To: <4F79B858.2090502@gmail.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-PMX-Version: 5.6.0.2009776, Antispam-Engine: 2.7.2.376379, Antispam-Data: 2012.4.2.100040 Subject: Re: [Caml-list] How could I implement an efficient ring buffer? 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 to roll your own, someone suggested Janestreet's core's Dequeue module and Gabriel sent you some implementation. Regards, F. > 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 have an array a of type int array, you can not do > things like this *(&a+5). > Many thanks > >