-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/
-- | Permutations and combinations
--
-- A library for representing and applying permutations.
@package permutation
@version 0.1
module Data.Permutation
-- | Represents a permutation of the integers [0..n).
data Permutation
-- | Create a permutation from a list of values. The list must be of length
-- n and contain each integer in {0, 1, ..., (n-1) }
-- exactly once. The permutation that is returned will send the integer
-- i to its index in the list.
permutation :: Int -> [Int] -> Permutation
-- | Create an identity permutation of the given size.
identity :: Int -> Permutation
-- | Get the inverse of a permutation.
inverse :: Permutation -> Permutation
-- | Get the size of the permutation.
size :: Permutation -> Int
-- | Apply a permutation to an integer. The integer must be in the range
-- [0..n).
apply :: Permutation -> Int -> Int
-- | applyWith swap perm applies the permutation as a sequence of
-- swaps. After this function is applied, OUT[i] = IN[P[i]]
applyWith :: (Monad m) => (Int -> Int -> m ()) -> Permutation -> m ()
-- | invertWith swap p applies the inverse of the permutation as a
-- sequence of swaps. After this function is applied, OUT[P[i]] =
-- IN[i]
invertWith :: (Monad m) => (Int -> Int -> m ()) -> Permutation -> m ()
-- | Convert size and raw array to a permutation. No validation is
-- performed on the arguments.
fromForeignPtr :: Int -> ForeignPtr Int -> Int -> Permutation
-- | Get the size, raw data array and offset
toForeignPtr :: Permutation -> (Int, ForeignPtr Int, Int)
toList :: Permutation -> [Int]
fromList :: [Int] -> Permutation
-- | Perform an operation, given a pointer to the start of the permutation
-- data
withPermutationPtr :: Permutation -> (Ptr Int -> IO a) -> IO a
-- | Same as permutation, but does not check that the inputs are
-- valid.
unsafePermutation :: Int -> [Int] -> Permutation
-- | Same as apply but does not range-check the argument.
unsafeApply :: Permutation -> Int -> Int
instance Eq Permutation
instance Show Permutation