forked from auduchinok/fsharp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathzset.fs
More file actions
56 lines (32 loc) · 1.82 KB
/
Copy pathzset.fs
File metadata and controls
56 lines (32 loc) · 1.82 KB
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
// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information.
namespace FSharp.Compiler.AbstractIL.Internal
open FSharp.Compiler.AbstractIL
open FSharp.Compiler.AbstractIL.Internal
open FSharp.Compiler.AbstractIL.Internal.Library
open Internal.Utilities
open Internal.Utilities.Collections.Tagged
open System.Collections.Generic
/// Sets with a specific comparison function
type internal Zset<'T> = Internal.Utilities.Collections.Tagged.Set<'T>
[<CompilationRepresentation(CompilationRepresentationFlags.ModuleSuffix)>]
module internal Zset =
let empty (ord : IComparer<'T>) = Internal.Utilities.Collections.Tagged.Set<_,_>.Empty(ord)
let isEmpty (s: Zset<_>) = s.IsEmpty
let contains x (s: Zset<_>) = s.Contains(x)
let add x (s: Zset<_>) = s.Add(x)
let addList xs a = List.fold (fun a x -> add x a) a xs
let singleton ord x = add x (empty ord)
let remove x (s: Zset<_>) = s.Remove(x)
let fold (f : 'T -> 'b -> 'b) (s: Zset<_>) b = s.Fold f b
let iter f (s: Zset<_>) = s.Iterate f
let forall p (s: Zset<_>) = s.ForAll p
let count (s: Zset<_>) = s.Count
let exists p (s: Zset<_>) = s.Exists p
let subset (s1: Zset<_>) (s2: Zset<_>) = s1.IsSubsetOf s2
let equal (s1: Zset<_>) (s2: Zset<_>) = Internal.Utilities.Collections.Tagged.Set<_,_>.Equality(s1,s2)
let elements (s: Zset<_>) = s.ToList()
let filter p (s: Zset<_>) = s.Filter p
let union (s1: Zset<_>) (s2: Zset<_>) = Internal.Utilities.Collections.Tagged.Set<_,_>.Union(s1,s2)
let inter (s1: Zset<_>) (s2: Zset<_>) = Internal.Utilities.Collections.Tagged.Set<_,_>.Intersection(s1,s2)
let diff (s1: Zset<_>) (s2: Zset<_>) = Internal.Utilities.Collections.Tagged.Set<_,_>.Difference(s1,s2)
let memberOf m k = contains k m