What guarantees are there on the run-time complexity (Big-O) of LINQ methods?
问题 I\'ve recently started using LINQ quite a bit, and I haven\'t really seen any mention of run-time complexity for any of the LINQ methods. Obviously, there are many factors at play here, so let\'s restrict the discussion to the plain IEnumerable LINQ-to-Objects provider. Further, let\'s assume that any Func passed in as a selector / mutator / etc. is a cheap O(1) operation. It seems obvious that all the single-pass operations ( Select , Where , Count , Take/Skip , Any/All , etc.) will be O(n),