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

« back to all changes in this revision

Viewing changes to public/uSet.ml

  • 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: uSet.ml,v 1.2 2004/09/04 16:07:38 yori Exp $ *)
 
2
(* Copyright 2002, 2003 Yamagata Yoriyuki. distributed with LGPL *)
 
3
 
 
4
include ISet
 
5
 
 
6
external uset_of_iset : ISet.t -> t = "%identity"
 
7
external iset_of_uset : t -> ISet.t = "%identity"
 
8
 
 
9
let mem u s = ISet.mem (UChar.uint_code u) s
 
10
 
 
11
let add u s = ISet.add (UChar.uint_code u) s
 
12
 
 
13
let add_range u1 u2 s = 
 
14
  ISet.add_range (UChar.uint_code u1) (UChar.uint_code u2) s
 
15
 
 
16
let singleton u = ISet.singleton (UChar.uint_code u)
 
17
 
 
18
let remove u s = ISet.remove (UChar.uint_code u) s
 
19
 
 
20
let remove_range u1 u2 s = 
 
21
  ISet.remove_range (UChar.uint_code u1) (UChar.uint_code u2) s
 
22
 
 
23
let from u s = ISet.from (UChar.uint_code u) s
 
24
let after u s = ISet.after (UChar.uint_code u) s
 
25
 
 
26
let until u s = ISet.until (UChar.uint_code u) s
 
27
let before u s = ISet.before (UChar.uint_code u) s
 
28
 
 
29
let iter f s = ISet.iter (fun n -> f (UChar.chr_of_uint n)) s
 
30
 
 
31
let iter_range f s =
 
32
  let f' n1 n2 = 
 
33
    f (UChar.chr_of_uint n1) (UChar.chr_of_uint n2) in
 
34
  ISet.iter_range f' s
 
35
 
 
36
let fold f s a =
 
37
  let f' n a = f (UChar.chr_of_uint n) a in
 
38
  ISet.fold f' s a
 
39
 
 
40
let fold_range f s a =
 
41
  let f' n1 n2 a = 
 
42
    f (UChar.chr_of_uint n1) (UChar.chr_of_uint n1) a in
 
43
  ISet.fold_range f' s a
 
44
 
 
45
let for_all p s =
 
46
  let p' n = p (UChar.chr_of_uint n) in
 
47
  ISet.for_all p' s
 
48
 
 
49
let exists p s =
 
50
  let p' n = p (UChar.chr_of_uint n) in
 
51
  ISet.exists p' s
 
52
 
 
53
let filter p s =
 
54
  let p' n = p (UChar.chr_of_uint n) in
 
55
  ISet.filter p' s
 
56
 
 
57
let partition p s =
 
58
  let p' n = p (UChar.chr_of_uint n) in
 
59
  ISet.partition p' s
 
60
 
 
61
let elements s =
 
62
  List.map UChar.chr_of_uint (ISet.elements s)
 
63
 
 
64
let ranges s =
 
65
  let f (n1, n2) = 
 
66
    (UChar.chr_of_uint n1, 
 
67
     UChar.chr_of_uint n2) in
 
68
  List.map f (ISet.ranges s)
 
69
 
 
70
let min_elt s = UChar.chr_of_uint (ISet.min_elt s)
 
71
let max_elt s = UChar.chr_of_uint (ISet.max_elt s)
 
72
let choose s = UChar.chr_of_uint (ISet.choose s)
 
73
 
 
74
let uset_of_iset s = s
 
75
let iset_of_uset s = s