comparison lib/growvect.mli @ 0:bfdcc3820b32

Basis
author Mike Spivey <mike@cs.ox.ac.uk>
date Thu, 05 Oct 2017 08:04:15 +0100
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:bfdcc3820b32
1 (* growvect.mli *)
2 (* Copyright (c) 2017 J. M. Spivey *)
3
4 (* This module provides an alternative implementation of arrays that
5 grow as needed to accommodate the indices used in assignments. *)
6
7 type 'a t
8
9 (* create -- make an empty vector with a specified initial capacity *)
10 val create : int -> 'a t
11
12 (* make -- make a vector of specified size *)
13 val make : int -> 'a -> 'a t
14
15 (* clear -- make vector empty again *)
16 val clear : 'a t -> unit
17
18 (* get -- fetch element at given index *)
19 val get : 'a t -> int -> 'a
20
21 (* size -- get current number of elements *)
22 val size : 'a t -> int
23
24 (* set -- change existing element at given index *)
25 val set : 'a t -> int -> 'a -> unit
26
27 (* append -- add new element at the end *)
28 val append : 'a t -> 'a -> unit
29
30 (* to_list -- convert to list *)
31 val to_list : 'a t -> 'a list
32
33 (* iter -- apply function to each element *)
34 val iter : ('a -> unit) -> 'a t -> unit