Galois
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Iterable.h
Go to the documentation of this file.
1 /*
2  * This file belongs to the Galois project, a C++ library for exploiting
3  * parallelism. The code is being released under the terms of the 3-Clause BSD
4  * License (a copy is located in LICENSE.txt at the top-level directory).
5  *
6  * Copyright (C) 2018, The University of Texas at Austin. All rights reserved.
7  * UNIVERSITY EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES CONCERNING THIS
8  * SOFTWARE AND DOCUMENTATION, INCLUDING ANY WARRANTIES OF MERCHANTABILITY,
9  * FITNESS FOR ANY PARTICULAR PURPOSE, NON-INFRINGEMENT AND WARRANTIES OF
10  * PERFORMANCE, AND ANY WARRANTY THAT MIGHT OTHERWISE ARISE FROM COURSE OF
11  * DEALING OR USAGE OF TRADE. NO WARRANTY IS EITHER EXPRESS OR IMPLIED WITH
12  * RESPECT TO THE USE OF THE SOFTWARE OR DOCUMENTATION. Under no circumstances
13  * shall University be liable for incidental, special, indirect, direct or
14  * consequential damages or loss of profits, interruption of business, or
15  * related expenses which may arise from use of Software or Documentation,
16  * including but not limited to those resulting from defects in Software and/or
17  * Documentation, or loss or inaccuracy of data of any kind.
18  */
19 
20 #ifndef GALOIS_RUNTIME_ITERABLE_H
21 #define GALOIS_RUNTIME_ITERABLE_H
22 
23 #include "galois/config.h"
24 
25 namespace galois {
26 namespace runtime {
27 
28 // iterable and make_iterable specific
29 // From:
30 // https://github.com/CppCon/CppCon2014/tree/master/Presentations/C%2B%2B11%20in%20the%20Wild%20-%20Techniques%20from%20a%20Real%20Codebase
31 // Author: Arthur O'Dwyer
32 // License: The C++ code in this directory is placed in the public domain and
33 // may be reused or modified for any purpose, commercial or non-commercial.
34 
35 template <class It>
36 class iterable {
37  It m_first, m_last;
38 
39 public:
40  iterable() = default;
41  iterable(It first, It last) : m_first(first), m_last(last) {}
42  It begin() const { return m_first; }
43  It end() const { return m_last; }
44 };
45 
46 template <class It>
47 static inline iterable<It> make_iterable(It a, It b) {
48  return iterable<It>(a, b);
49 }
50 
51 } // end namespace runtime
52 } // end namespace galois
53 
54 #endif // GALOIS_RUNTIME_ITERABLE_H
Definition: Iterable.h:36
iterable(It first, It last)
Definition: Iterable.h:41
It end() const
Definition: Iterable.h:43
It begin() const
Definition: Iterable.h:42