package tablecloth-native

  1. Overview
  2. Docs

Source file TableclothSet.ml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
module Comparator = TableclothComparator

type ('a, 'id) t = ('a, 'id) Base.Set.t

module Of (M : TableclothComparator.S) = struct
  type nonrec t = (M.t, M.identity) t
end

let empty comparator = Base.Set.empty (Internal.toBaseComparator comparator)

let singleton
    (comparator : ('a, 'identity) TableclothComparator.s) (element : 'a) :
    ('a, 'identity) t =
  Base.Set.of_list (Internal.toBaseComparator comparator) [ element ]


let fromArray
    (comparator : ('a, 'identity) TableclothComparator.s) (elements : 'a array)
    : ('a, 'identity) t =
  Base.Set.of_list
    (Internal.toBaseComparator comparator)
    (Array.to_list elements)


let from_array = fromArray

let fromList
    (comparator : ('a, 'identity) TableclothComparator.s) (elements : 'a list) :
    ('a, 'identity) t =
  Base.Set.of_list (Internal.toBaseComparator comparator) elements


let from_list = fromList

let length = Base.Set.length

let isEmpty = Base.Set.is_empty

let is_empty = isEmpty

let includes = Base.Set.mem

let ( .?{} ) (set : ('element, _) t) (element : 'element) : bool =
  includes set element


let add = Base.Set.add

let remove = Base.Set.remove

let difference = Base.Set.diff

let intersection = Base.Set.inter

let union = Base.Set.union

let filter = Base.Set.filter

let partition = Base.Set.partition_tf

let find = Base.Set.find

let all = Base.Set.for_all

let any = Base.Set.exists

let forEach = Base.Set.iter

let for_each = forEach

let fold s ~initial ~f = Base.Set.fold s ~init:initial ~f

let toArray = Base.Set.to_array

let to_array = toArray

let toList = Base.Set.to_list

let to_list = toList

module Poly = struct
  type identity = Base.Comparator.Poly.comparator_witness

  type nonrec 'a t = ('a, identity) t

  let empty () = Base.Set.Poly.empty

  let singleton = Base.Set.Poly.singleton

  let fromArray = Base.Set.Poly.of_array

  let from_array = fromArray

  let fromList = Base.Set.Poly.of_list

  let from_list = fromList
end

module Int = struct
  type nonrec t = Of(TableclothInt).t

  let empty = empty (module TableclothInt)

  let singleton = singleton (module TableclothInt)

  let fromArray = fromArray (module TableclothInt)

  let from_array = fromArray

  let fromList = fromList (module TableclothInt)

  let from_list = fromList
end

module String = struct
  type nonrec t = Of(TableclothString).t

  let empty = empty (module TableclothString)

  let singleton = singleton (module TableclothString)

  let fromArray = fromArray (module TableclothString)

  let from_array = fromArray

  let fromList = fromList (module TableclothString)

  let from_list = fromList
end