1 // Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information. 2 3 #if !defined(CPPLINQ_LINQ_SKIP_HPP) 4 #define CPPLINQ_LINQ_SKIP_HPP 5 #pragma once 6 7 #include <cstddef> 8 9 namespace cpplinq 10 { 11 template <class Collection> 12 struct linq_skip 13 { 14 public: 15 typedef typename Collection::cursor cursor; 16 linq_skipcpplinq::linq_skip17 linq_skip(const Collection& c, std::size_t n) : c(c), n(n) {} 18 get_cursorcpplinq::linq_skip19 cursor get_cursor() const { 20 std::size_t rem = n; 21 22 auto cur = c.get_cursor(); 23 while(rem-- && !cur.empty()) { 24 cur.inc(); 25 } 26 cur.forget(); 27 return cur; 28 } 29 30 private: 31 Collection c; 32 std::size_t n; 33 }; 34 } 35 #endif // !defined(CPPLINQ_LINQ_SKIP_HPP) 36 37 38