Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 110 lines (95 sloc) 4.474 kb
fccc685 Initial open-source release
MLstate authored
1 (*
2 Copyright © 2011 MLstate
3
4 This file is part of OPA.
5
6 OPA is free software: you can redistribute it and/or modify it under the
7 terms of the GNU Affero General Public License, version 3, as published by
8 the Free Software Foundation.
9
10 OPA is distributed in the hope that it will be useful, but WITHOUT ANY
11 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
13 more details.
14
15 You should have received a copy of the GNU Affero General Public License
16 along with OPA. If not, see <http://www.gnu.org/licenses/>.
17 *)
18 external length : 'a array -> int = "%array_length"
19 external get : 'a array -> int -> 'a = "%array_safe_get"
20 external set : 'a array -> int -> 'a -> unit = "%array_safe_set"
21 external make : int -> 'a -> 'a array = "caml_make_vect"
22 external create : int -> 'a -> 'a array = "caml_make_vect"
23 val is_empty: 'a array -> bool
24 val init : int -> (int -> 'a) -> 'a array
25 val make_matrix : int -> int -> 'a -> 'a array array
26 val create_matrix : int -> int -> 'a -> 'a array array
27 val append : 'a array -> 'a array -> 'a array
28
29 (** [unsafe_create len] returns an ['a array] of length [len] *)
30 val unsafe_create : int -> 'a array
31 (**
32 Append two memory buffers.
33 By opposition to [append], this function does not attempt to be smart
34 and to optimize memory representation of arrays.
35
36 Do not use this on regular arrays.*)
37 val append_memory : 'a array -> 'a array -> 'a array
38 val concat : 'a array list -> 'a array
39 val sub : 'a array -> int -> int -> 'a array
40 val copy : 'a array -> 'a array
41
42 (** Return a copy of a memory buffer.
43 By opposition to [copy], this function does not attempt to be smart
44 and to optimize memory representation of arrays.
45
46 Do not use this on regular arrays.*)
47 val copy_memory: 'a array -> 'a array
48 val fill : 'a array -> int -> int -> 'a -> unit
49 val blit : 'a array -> int -> 'a array -> int -> int -> unit
50 (** Same as Array.blit but doesn't check anything on offsets or length *)
51 val unsafe_blit : 'a array -> int -> 'a array -> int -> int -> unit
52 val to_list : 'a array -> 'a list
53 val of_list : 'a list -> 'a array
54 val iter : ('a -> unit) -> 'a array -> unit
55 val map : ('a -> 'b) -> 'a array -> 'b array
56 val iteri : (int -> 'a -> unit) -> 'a array -> unit
57 val mapi : (int -> 'a -> 'b) -> 'a array -> 'b array
58 val fold_left : ('a -> 'b -> 'a) -> 'a -> 'b array -> 'a
59 val fold_right : ('a -> 'b -> 'b) -> 'a array -> 'b -> 'b
60 val sort : ('a -> 'a -> int) -> 'a array -> unit
61 val stable_sort : ('a -> 'a -> int) -> 'a array -> unit
62 val fast_sort : ('a -> 'a -> int) -> 'a array -> unit
63 external unsafe_get : 'a array -> int -> 'a = "%array_unsafe_get"
64 external unsafe_set : 'a array -> int -> 'a -> unit = "%array_unsafe_set"
65 val swap : 'a array -> int -> int -> unit
66
67 (**
68 Insert an element at the right place in an array, preserving the array sorted.
69 By default, there is no duplication, and in case of conflict, the returned array
70 is exactly the one taken as argument (no replace)
71 *)
72 val insert_sorted : ?cmp:('a -> 'a -> int) -> ?dupl:(bool) -> 'a -> 'a array -> 'a array
73
74 val fold_left_i : ('a -> 'b -> int -> 'a) -> 'a -> 'b array -> 'a
75 val max : 'a array -> 'a
76 val min : 'a array -> 'a
77 val argmax : 'a array -> int
78 val argmin : 'a array -> int
79 val map_some : ('a -> 'b option) -> 'a array -> 'b array
80 val mapi_some : (int -> 'a -> 'b option) -> 'a array -> 'b array
81 val map2 : ('a -> 'b -> 'c) -> 'a array -> 'b array -> 'c array
82 val fill_some : 'a option array -> 'a -> int -> int -> unit
83 val mem : 'a -> 'a array -> bool
84 val exists : ('a -> bool) -> 'a array -> bool
85 val split: ('a * 'b) array -> 'a array * 'b array
86 val find: 'a array -> 'a -> int (** May raise [Not_found] *)
87
88 (**
89 the function given in argument should return exactly -1, 0 or 1
90 *)
91 val compare : ('a -> 'a -> int) -> 'a array -> 'a array -> int
92
93 val to_string : ('a -> string) -> 'a array -> string
94 (** Print on array format; i.e. [|a;b;c;...|] *)
95 val print : ('a -> string) -> 'a array -> string
96
97 (**
98 [filter fct a]
99 Reallocate a new array with only filtered fields of a
100 such than [fct a = true].
101 <!> if the array is empty, returns the same array,
102 and the function [fct] is never called
103 *)
104 val filter : ('a -> bool) -> 'a array -> 'a array
105
106 (**
107 Same than [filter] but give acces to the index of the filtered item.
108 *)
109 val filteri : (int -> 'a -> bool) -> 'a array -> 'a array
Something went wrong with that request. Please try again.