~ubuntu-branches/ubuntu/hardy/ocaml-doc/hardy

« back to all changes in this revision

Viewing changes to examples/compress/fileprio.ml

  • Committer: Bazaar Package Importer
  • Author(s): Samuel Mimram
  • Date: 2007-09-08 01:49:22 UTC
  • mfrom: (0.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20070908014922-lvihyehz0ndq7suu
Tags: 3.10-1
* New upstream release.
* Removed camlp4 documentation since it is not up-to-date.
* Updated to standards version 3.7.2, no changes needed.
* Updated my email address.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
(***********************************************************************)
2
 
(*                                                                     *)
3
 
(*                           Objective Caml                            *)
4
 
(*                                                                     *)
5
 
(*               Pierre Weis, projet Cristal, INRIA Rocquencourt       *)
6
 
(*                                                                     *)
7
 
(*  Copyright 2001 Institut National de Recherche en Informatique et   *)
8
 
(*  en Automatique.  All rights reserved.  This file is distributed    *)
9
 
(*  only by permission.                                                *)
10
 
(*                                                                     *)
11
 
(***********************************************************************)
12
 
exception File_vide;;
13
 
 
14
 
type 'a t =
15
 
   | Vide | File of int * 'a * 'a t * 'a t;;
16
 
 
17
 
let vide = Vide;;
18
 
 
19
 
let rec enl�ve_sommet = function
20
 
  | Vide -> raise File_vide
21
 
  | File(prio, elt, Vide, Vide) -> Vide
22
 
  | File(prio, elt, gauche, Vide) -> gauche
23
 
  | File(prio, elt, Vide, droite) -> droite
24
 
  | File(prio, elt, (File(prio_g, elt_g, _, _) as gauche),
25
 
                    (File(prio_d, elt_d, _, _) as droite)) ->
26
 
      if prio_g < prio_d
27
 
      then File(prio_g, elt_g, enl�ve_sommet gauche, droite)
28
 
      else File(prio_d, elt_d, gauche, enl�ve_sommet droite);;
29
 
 
30
 
let extraire = function
31
 
  | Vide -> raise File_vide
32
 
  | File(prio, elt, _, _) as file -> (prio, elt, enl�ve_sommet file);;
33
 
 
34
 
let rec ajoute file prio elt =
35
 
  match file with
36
 
  | Vide ->
37
 
      File(prio, elt, Vide, Vide)
38
 
  | File(prio1, elt1, gauche, droite) ->
39
 
      if prio <= prio1
40
 
      then File(prio, elt, ajoute droite prio1 elt1, gauche)
41
 
      else File(prio1, elt1, ajoute droite prio elt, gauche);;