~ubuntu-branches/ubuntu/lucid/camomile/lucid

« back to all changes in this revision

Viewing changes to public/xArray.mli

  • Committer: Bazaar Package Importer
  • Author(s): Sylvain Le Gall
  • Date: 2005-12-03 01:18:55 UTC
  • Revision ID: james.westby@ubuntu.com-20051203011855-qzvwlld1xyqnl62t
Tags: upstream-0.6.3
ImportĀ upstreamĀ versionĀ 0.6.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
(* $Id: xArray.mli,v 1.2 2004/06/05 16:42:07 yori Exp $ *)
 
2
(* Copyright 2002, 2003 Yamagata Yoriyuki. distributed with LGPL *)
 
3
 
 
4
(** XArray will be replaced by Dynarray in future. *)
 
5
  type 'a xarray
 
6
  type 'a t = 'a xarray
 
7
 
 
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
 
15
 
 
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
 
21
      
 
22
  val get : 'a xarray -> int -> 'a
 
23
 
 
24
(* set x i e :
 
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
 
29
      
 
30
  type index
 
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
 
35
 
 
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
 
43
 
 
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
 
47
 
 
48
(* semantics of these functions are similar to equivalents of
 
49
 * Array or Buffer. *)
 
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
 
59
      
 
60
  val array_of : 'a xarray -> 'a array
 
61
 
 
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