import "JavaBuiltin" as Java import "Java/Iterator" as Iterator importJava "java.util.Collection" where data Collection a contains :: Collection a -> a -> Boolean isEmpty :: Collection a -> Boolean size :: Collection a -> Integer @private iterator :: Collection a -> Iterator.Iterator a @inline iter :: (a -> dummy) -> Collection a -> () iter f c = runProc (Iterator.iter f (iterator c)) @inline any :: (a -> Boolean) -> Collection a -> Boolean any f c = runProc (Iterator.any f (iterator c)) @inline all :: (a -> Boolean) -> Collection a -> Boolean all f c = runProc (Iterator.all f (iterator c)) @inline foldl :: (a -> b -> a) -> a -> Collection b -> a foldl f i c = runProc (Iterator.foldl f i (iterator c)) @inline foldl1 :: (a -> a -> a) -> Collection a -> a foldl1 f c = runProc (Iterator.foldl1 f (iterator c)) @inline mapFirst :: (a -> Maybe b) -> Collection a -> Maybe b mapFirst f c = runProc (Iterator.mapFirst f (iterator c)) @inline find :: (a -> Boolean) -> Collection a -> Maybe a find f c = runProc (Iterator.find f (iterator c)) @inline uniqueElement :: Collection a -> a uniqueElement c = if Java.icmpeq (size c) 1 then runProc (Iterator.next (iterator c)) else fail "Collection is not a singleton."