We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 1784dfb commit 76f6d3cCopy full SHA for 76f6d3c
cabal-install/src/Distribution/Client/Utils.hs
@@ -480,8 +480,13 @@ safeRead s
480
| [(x, "")] <- reads s = Just x
481
| otherwise = Nothing
482
483
-
484
-- | @hasElem xs x = elem x xs@ except that @xs@ is turned into a 'Set' first.
485
-- Use underapplied to speed up subsequent lookups, e.g. @filter (hasElem xs) ys@.
+-- Only amortized when used several times!
486
+--
487
+-- Time complexity \(O((n+m) \log(n))\) for \(m\) lookups in a list of length \(n\).
488
+-- (Compare this to 'elem''s \(O(nm)\).)
489
490
+-- This is [Agda.Utils.List.hasElem](https://hackage.haskell.org/package/Agda-2.6.2.2/docs/Agda-Utils-List.html#v:hasElem).
491
hasElem :: Ord a => [a] -> a -> Bool
492
hasElem xs = (`Set.member` Set.fromList xs)
0 commit comments