|
Module MListThis module is undocumented. This is a list of its definitions. add :: MList.T a -> a -> <Proc> () Adds the given element to the end of the list. addAll :: MList.T a -> [a] -> <Proc> () Adds all elements of the given list to the end of the list. clear :: MList.T a -> <Proc> () Removes all elements from the list. contains :: MList.T a -> a -> <Proc> Boolean Returns create :: () -> <Proc> MList.T a Creates a new empty list. createC :: Integer -> <Proc> MList.T a Creates a new empty list with room for the given number of elements. first :: MList.T a -> <Proc> a Returns the first element of a list. Fails with an Example:
fold :: (a -> b -> <c> a) -> a -> MList.T b -> <Proc,c> a Folds over all elements of the list starting with the given initial value. freeze :: MList.T a -> <Proc> [a] Converts the mutable list into an immutable one without copying the underlying data. This only changes how the structure is treated by the SCL type system; it is an O(1) operation, not a copy. The original mutable list must not be used anymore after this. The result aliases the original: it is the same object, only retyped. Every
subsequent mutation of the mutable list is visible through the supposedly
immutable one, as the example shows. That is why the original must be dropped.
When both are needed, use Example:
fromList :: [a] -> <Proc> MList.T a Creates a new mutable list containing the elements of the given immutable list. get :: MList.T a -> Integer -> <Proc> a
isEmpty :: MList.T a -> <Proc> Boolean Returns iter :: (a -> <b> ()) -> MList.T a -> <b,Proc> () Calls the given function with all elements of the list. iterB :: (a -> <b> Boolean) -> MList.T a -> <b,Proc> Boolean Calls the given function with the elements of the list until it returns
The result means "was not interrupted", not "found something". See
last :: MList.T a -> <Proc> a Returns the last element of a list. Like Example:
remove :: MList.T a -> Integer -> <Proc> a Removes the element at the given index and returns it. Indexing starts from zero. The argument is an index, not a value to look for. For a list of integers
this is easy to get wrong, since Example:
removeLast :: MList.T a -> <Proc> Maybe a Removes the last element of the list and returns it, or returns Example:
set :: MList.T a -> Integer -> a -> <Proc> Maybe a
The previous element comes back wrapped in Example:
singleton :: a -> <Proc> MList.T a Creates a new mutable list containing just the given element. size :: MList.T a -> <Proc> Integer The number of elements in the list. toList :: MList.T a -> <Proc> [a] Creates an independent copy of the list as an immutable list. Unlike This is the O(n) alternative to Example:
|