File tree Expand file tree Collapse file tree 1 file changed +6
-1
lines changed
cabal-install/src/Distribution/Client Expand file tree Collapse file tree 1 file changed +6
-1
lines changed Original file line number Diff line number Diff line change @@ -480,8 +480,13 @@ safeRead s
480
480
| [(x, " " )] <- reads s = Just x
481
481
| otherwise = Nothing
482
482
483
-
484
483
-- | @hasElem xs x = elem x xs@ except that @xs@ is turned into a 'Set' first.
485
484
-- Use underapplied to speed up subsequent lookups, e.g. @filter (hasElem xs) ys@.
485
+ -- 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).
486
491
hasElem :: Ord a => [a ] -> a -> Bool
487
492
hasElem xs = (`Set.member` Set. fromList xs)
You can’t perform that action at this time.
0 commit comments