ringbuffer doc updates

This commit is contained in:
carm 2015-02-22 21:03:16 -05:00
parent 7c0ed782e4
commit 6f788d3a2a
2 changed files with 34 additions and 3 deletions

View file

@ -2,7 +2,7 @@
* CCRingBuffer - Polymorphic circular buffer with * CCRingBuffer - Polymorphic circular buffer with
* deque semantics for accessing both the head and tail. * deque semantics for accessing both the head and tail.
* *
* Copyright (C) 2014 Simon Cruanes * Copyright (C) 2015 Simon Cruanes, Carmelo Piccione
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public

View file

@ -1,6 +1,6 @@
(** (**
* CCRingBuffer - Polymorphic Circular Buffer * CCRingBuffer - Polymorphic Circular Buffer
* Copyright (C) 2014 Simon Cruanes * Copyright (C) 2015 Simon Cruanes, Carmelo Piccione
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
@ -20,53 +20,82 @@
(** Circular Polymorphic Buffer for IO *) (** Circular Polymorphic Buffer for IO *)
(** The array module, with optimized versions of [Byte], [Float], and
[Int], [Bool]. A [Make] functor is provided for polymorphic types. *)
module Array : sig module Array : sig
(** The abstract type for arrays *)
module type S = sig module type S = sig
(** The element type *)
type elt type elt
(** The type of an array instance *)
type t type t
val empty : t val empty : t
(** The empty array *)
val make: int -> elt -> t val make: int -> elt -> t
(** [make s e] makes an array of size [s] with [e] elements *)
val length: t -> int val length: t -> int
(** [length t] gets the total number of elements currently in [t] *)
val get: t -> int -> elt val get: t -> int -> elt
(** [get t i] gets the element at position [i] *)
val set: t -> int -> elt -> unit val set: t -> int -> elt -> unit
(** [set t i e] sets the element at position [i] to [e] *)
val sub: t -> int -> int -> t val sub: t -> int -> int -> t
(** [sub t i len] gets the subarray of [t] from
position [i] to [i + len] *)
val copy : t -> t val copy : t -> t
(** [copy t] makes a fresh copy of the array [t] *)
val blit : t -> int -> t -> int -> int -> unit val blit : t -> int -> t -> int -> int -> unit
(** [blit t s arr i len] copies [len] elements from [arr] starting at [i]
to position [s] from [t] *)
val iter : (elt -> unit) -> t -> unit val iter : (elt -> unit) -> t -> unit
(** [iter f t] iterates over the array [t] invoking [f] with
the current element, in array order *)
end end
(** Efficient array version for the [char] type *)
module ByteArray : module ByteArray :
S with type elt = char and type t = bytes S with type elt = char and type t = bytes
(** Efficient array version for the [float] type *)
module FloatArray : module FloatArray :
S with type elt = float and type t = float array S with type elt = float and type t = float array
(** Efficient array version for the [int] type *)
module IntArray : module IntArray :
S with type elt = int and type t = int array S with type elt = int and type t = int array
(** Efficient array version for the [bool] type *)
module BoolArray : module BoolArray :
S with type elt = bool and type t = bool array S with type elt = bool and type t = bool array
(** Makes an array given an arbitrary element type *)
module Make : module Make :
functor (Elt:sig type t end) -> functor (Elt:sig type t end) ->
S with type elt = Elt.t and type t = Elt.t array S with type elt = Elt.t and type t = Elt.t array
end end
(** The abstract ring buffer type, made concrete by choice of
[Array] module implementation *)
module type S = module type S =
sig sig
(** The module type of Array for this ring buffer *)
module Array : Array.S module Array : Array.S
(** Defines the ring buffer type, with both bounded and
unbounded flavors *)
type t = private { type t = private {
mutable start : int; mutable start : int;
mutable stop : int; (* excluded *) mutable stop : int; (* excluded *)
@ -74,6 +103,8 @@ sig
bounded: bool; bounded: bool;
size : int size : int
} }
(** Raised in querying functions when the buffer is empty *)
exception Empty exception Empty
val create : ?bounded:bool -> int -> t val create : ?bounded:bool -> int -> t