compact-sequences-0.1.0.0: Stacks and queues with compact representations.

Safe Haskell Trustworthy Haskell2010

Data.CompactSequence.Stack.Simple

Description

Space-efficient stacks with amortized $$O(\log n)$$ operations. These directly use an underlying array-based implementation, without doing any special optimization for the very top of the stack.

Synopsis

# Documentation

data Stack a where Source #

Bundled Patterns

 pattern Empty :: Stack a pattern (:<) :: a -> Stack a -> Stack a infixr 4
Instances
 Source # Instance detailsDefined in Data.CompactSequence.Stack.Simple Methodsfmap :: (a -> b) -> Stack a -> Stack b #(<\$) :: a -> Stack b -> Stack a # Source # Instance detailsDefined in Data.CompactSequence.Stack.Simple Methodsfold :: Monoid m => Stack m -> m #foldMap :: Monoid m => (a -> m) -> Stack a -> m #foldr :: (a -> b -> b) -> b -> Stack a -> b #foldr' :: (a -> b -> b) -> b -> Stack a -> b #foldl :: (b -> a -> b) -> b -> Stack a -> b #foldl' :: (b -> a -> b) -> b -> Stack a -> b #foldr1 :: (a -> a -> a) -> Stack a -> a #foldl1 :: (a -> a -> a) -> Stack a -> a #toList :: Stack a -> [a] #null :: Stack a -> Bool #length :: Stack a -> Int #elem :: Eq a => a -> Stack a -> Bool #maximum :: Ord a => Stack a -> a #minimum :: Ord a => Stack a -> a #sum :: Num a => Stack a -> a #product :: Num a => Stack a -> a # Source # Instance detailsDefined in Data.CompactSequence.Stack.Simple Methodstraverse :: Applicative f => (a -> f b) -> Stack a -> f (Stack b) #sequenceA :: Applicative f => Stack (f a) -> f (Stack a) #mapM :: Monad m => (a -> m b) -> Stack a -> m (Stack b) #sequence :: Monad m => Stack (m a) -> m (Stack a) # IsList (Stack a) Source # Instance detailsDefined in Data.CompactSequence.Stack.Simple Associated Typestype Item (Stack a) :: Type # MethodsfromList :: [Item (Stack a)] -> Stack a #fromListN :: Int -> [Item (Stack a)] -> Stack a #toList :: Stack a -> [Item (Stack a)] # Eq a => Eq (Stack a) Source # Instance detailsDefined in Data.CompactSequence.Stack.Simple Methods(==) :: Stack a -> Stack a -> Bool #(/=) :: Stack a -> Stack a -> Bool # Ord a => Ord (Stack a) Source # Instance detailsDefined in Data.CompactSequence.Stack.Simple Methodscompare :: Stack a -> Stack a -> Ordering #(<) :: Stack a -> Stack a -> Bool #(<=) :: Stack a -> Stack a -> Bool #(>) :: Stack a -> Stack a -> Bool #(>=) :: Stack a -> Stack a -> Bool #max :: Stack a -> Stack a -> Stack a #min :: Stack a -> Stack a -> Stack a # Show a => Show (Stack a) Source # Instance detailsDefined in Data.CompactSequence.Stack.Simple MethodsshowsPrec :: Int -> Stack a -> ShowS #show :: Stack a -> String #showList :: [Stack a] -> ShowS # Source # Instance detailsDefined in Data.CompactSequence.Stack.Simple Methods(<>) :: Stack a -> Stack a -> Stack a #sconcat :: NonEmpty (Stack a) -> Stack a #stimes :: Integral b => b -> Stack a -> Stack a # Monoid (Stack a) Source # Instance detailsDefined in Data.CompactSequence.Stack.Simple Methodsmempty :: Stack a #mappend :: Stack a -> Stack a -> Stack a #mconcat :: [Stack a] -> Stack a # type Item (Stack a) Source # Instance detailsDefined in Data.CompactSequence.Stack.Simple type Item (Stack a) = a

cons :: a -> Stack a -> Stack a infixr 4 Source #

(<|) :: a -> Stack a -> Stack a infixr 4 Source #

uncons :: Stack a -> Maybe (a, Stack a) Source #

fromListN :: Int -> [a] -> Stack a Source #

$$O(n)$$. Convert a list of known length to a stack, with the first element of the list as the top of the stack.