RxCpp
The Reactive Extensions for Native (RxCpp) is a library for composing asynchronous and event-based programs using observable sequences and LINQ-style query operators in both C and C++.
linq_skip.hpp
Go to the documentation of this file.
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 
17  linq_skip(const Collection& c, std::size_t n) : c(c), n(n) {}
18 
19  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 
cursor get_cursor() const
Definition: linq_skip.hpp:19
linq_skip(const Collection &c, std::size_t n)
Definition: linq_skip.hpp:17
Definition: linq.hpp:186
Definition: linq_skip.hpp:12
Collection::cursor cursor
Definition: linq_skip.hpp:15