File: defstrat.ml

package info (click to toggle)
ocaml-res 5.0.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 304 kB
  • sloc: ml: 1,479; makefile: 22
file content (17 lines) | stat: -rw-r--r-- 402 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
(* Demonstration of the default reallocation strategy in action *)

open Res.Array

let info v r = Printf.printf "virtual length: %3d  real length: %3d\n" v r

let _ =
  let ar = empty () in
  for _i = 1 to 100 do
    info (length ar) (real_length ar);
    add_one ar 42
  done;
  for _i = 1 to 20 do
    info (length ar) (real_length ar);
    remove_n ar 5
  done;
  info (length ar) (real_length ar)