summaryrefslogtreecommitdiffstats
path: root/StackSet.hs
diff options
context:
space:
mode:
Diffstat (limited to 'StackSet.hs')
-rw-r--r--StackSet.hs4
1 files changed, 4 insertions, 0 deletions
diff --git a/StackSet.hs b/StackSet.hs
index 15788bc..1453c97 100644
--- a/StackSet.hs
+++ b/StackSet.hs
@@ -61,6 +61,10 @@ empty n = StackSet { current = 0
member :: Ord a => a -> StackSet a -> Bool
member a w = M.member a (cache w)
+-- | /O(log n)/. Looks up the stack that x is in, if it is in the StackSet
+lookup :: (Monad m, Ord a) => a -> StackSet a -> m Int
+lookup x w = M.lookup x (cache w)
+
-- | /O(n)/. Number of stacks
size :: StackSet a -> Int
size = M.size . stacks