1 import "Prelude" as Prelude
2 import "JavaBuiltin" as Java
3 import "Iterator" as Iterator
5 importJava "java.util.List" where
8 contains :: T a -> a -> <Proc> Boolean
9 size :: T a -> <Proc> Integer
10 isEmpty :: T a -> <Proc> Boolean
11 get :: T a -> Integer -> <Proc> a
12 set :: T a -> Integer -> a -> <Proc> Maybe a
14 add :: T a -> a -> <Proc> ()
15 addAll :: T a -> [a] -> <Proc> ()
16 remove :: T a -> Integer -> <Proc> a
17 clear :: T a -> <Proc> ()
20 iterator :: T a -> <Proc> Iterator.T a
22 removeLast :: T a -> <Proc> Maybe a
23 removeLast l = if isEmpty l
25 else Just (remove l (Java.isub (size l) 1))
28 iter :: (a -> <e> ()) -> T a -> <e,Proc> ()
29 iter f s = Iterator.iter f (iterator s)
32 iterB :: (a -> <e> Boolean) -> T a -> <e,Proc> Boolean
33 iterB f s = Iterator.iterB f (iterator s)
36 fold :: (a -> b -> <e> a) -> a -> T b -> <Proc,e> a
37 fold f init s = Iterator.fold f init (iterator s)
39 importJava "java.util.ArrayList" where
41 create :: () -> <Proc> T a
43 createC :: Integer -> <Proc> T a
45 fromList :: [a] -> <Proc> T a
47 result = createC (Prelude.length l)
48 Prelude.iter (\x -> Prelude.ignore (add result x)) l
51 singleton :: a -> <Proc> T a
58 freeze :: T a -> <Proc> [a]
59 freeze = Java.unsafeCoerce