1
(* $Id: xArray.mli,v 1.2 2004/06/05 16:42:07 yori Exp $ *)
2
(* Copyright 2002, 2003 Yamagata Yoriyuki. distributed with LGPL *)
4
(** XArray will be replaced by Dynarray in future. *)
8
(* init ~bufsize len default f :
9
* returned xarray has length [len], its nth-element is [f n],
10
* its default value is [default]. The size of the internal buffer
11
* is initially ~bufsize. However, accessible elements are only up to [len].
12
* [f] is called with integers [0 ... len - 1], only once for each integer.
13
* The call is in the increasing order f 0, f1, f2, ... *)
14
val init : ?bufsize:int -> int -> 'a -> (int -> 'a) -> 'a xarray
16
(* make ~bufsize len default :
17
* returns xarray filled with [default], whose default value is [default],
18
* size of the internal buffer is [bufsize]. *)
19
val make : ?bufsize:int -> int -> 'a -> 'a xarray
20
val length : 'a xarray -> int
22
val get : 'a xarray -> int -> 'a
25
* set the [i]-th element of [x] to [e].
26
* The length of [x] is automatically extended to [i], and
27
* intermediate elements are set to the default value of [x] *)
28
val set : 'a xarray -> int -> 'a -> unit
31
val nth : 'a xarray -> int -> index
32
val first : 'a xarray -> index
33
val last : 'a xarray -> index
34
val look : 'a xarray -> index -> 'a
36
(* next x i, prev x i :
37
* operation is valid if [i] points the valid element, i.e.
38
* returned value may point the location beyond valid elements by one.
39
* If [i] does not point a valid element, the results are unspecified. *)
40
val next : 'a t -> index -> index
41
val prev : 'a t -> index -> index
42
val move : 'a t -> index -> int -> index
44
(* test whether the given index points the valid element. *)
45
val out_of_range : 'a xarray -> index -> bool
46
val compare_index : 'a xarray -> index -> index -> int
48
(* semantics of these functions are similar to equivalents of
50
val clear : 'a xarray -> unit
51
val reset : 'a xarray -> unit
52
val copy : 'a xarray -> 'a xarray
53
val sub : 'a xarray -> int -> int -> 'a xarray
54
val add_element : 'a xarray -> 'a -> unit
55
val add_array : 'a xarray -> 'a array -> unit
56
val add_xarray : 'a xarray -> 'a xarray -> unit
57
val append : 'a xarray -> 'a xarray -> 'a xarray
58
val iter : ('a -> unit) -> 'a xarray -> unit
60
val array_of : 'a xarray -> 'a array
62
(* shrink x len : reduce the length of [x] to [len].
63
* If there is an element beyond [len], such elements are discarded. *)
64
val shrink : 'a xarray -> int -> unit