1 import "Prelude" as Prelude
2 import "JavaBuiltin" as Java
3 import "Iterator" as Iterator
5 import "MList" as MList
7 importJava "java.util.Set" where
10 contains :: T a -> a -> <Proc> Boolean
11 size :: T a -> <Proc> Integer
12 isEmpty :: T a -> <Proc> Boolean
14 add :: T a -> a -> <Proc> Boolean
15 addAll :: T a -> [a] -> <Proc> Boolean
17 addAllS :: T a -> T a -> <Proc> Boolean
18 remove :: T a -> a -> <Proc> Boolean
19 removeAll :: T a -> [a] -> <Proc> Boolean
20 clear :: T a -> <Proc> ()
23 iterator :: T a -> <Proc> Iterator.T a
26 iter :: (a -> <e> b) -> T a -> <e,Proc> ()
27 iter f s = Iterator.iter f (iterator s)
30 iterB :: (a -> <e> Boolean) -> T a -> <e,Proc> Boolean
31 iterB f s = Iterator.iterB f (iterator s)
33 map :: (a -> <e> b) -> T a -> <e,Proc> T b
36 result = createC (size set)
37 iter (\x -> add result (f x)) set
40 mapFirst :: (a -> <e> Maybe b) -> T a -> <e,Proc> Maybe b
41 mapFirst f s = Iterator.mapFirst f (iterator s)
44 fold :: (a -> b -> <e> a) -> a -> T b -> <Proc,e> a
45 fold f init s = Iterator.fold f init (iterator s)
47 importJava "gnu.trove.set.hash.THashSet" where
49 create :: () -> <Proc> T a
51 createC :: Integer -> <Proc> T a
53 fromList :: [a] -> <Proc> T a
55 result = createC (Prelude.length l)
56 Prelude.iter (\x -> Prelude.ignore (add result x)) l
59 toList :: T a -> <Proc> [a]
61 result = MList.createC (size s)
62 iter (MList.add result) s
65 singleton :: a -> <Proc> T a
72 freeze :: T a -> <Proc> Set.T a
73 freeze = Java.unsafeCoerce
75 concatMap :: (a -> <e> T b) -> T a -> <Proc,e> T b
76 concatMap f s = result
79 iter (\el -> addAllS result (f el)) s
81 all :: (a -> <e> Boolean) -> T a -> <e,Proc> Boolean
82 all f s = Iterator.iterB f (iterator s)