summaryrefslogtreecommitdiff
path: root/lib/hj/pyutils.h
diff options
context:
space:
mode:
Diffstat (limited to 'lib/hj/pyutils.h')
-rw-r--r--lib/hj/pyutils.h23
1 files changed, 23 insertions, 0 deletions
diff --git a/lib/hj/pyutils.h b/lib/hj/pyutils.h
new file mode 100644
index 0000000..c5da4ee
--- /dev/null
+++ b/lib/hj/pyutils.h
@@ -0,0 +1,23 @@
+#pragma once
+
+#include <vector>
+
+namespace PyUtils {
+template<typename T>
+std::vector<T> slice(std::vector<T> const &v, uint32_t m, uint32_t n = -1) {
+ auto first = v.cbegin() + m;
+ auto last = n == -1 ? v.cend() : v.cbegin() + n;
+
+ std::vector<T> vec(first, last);
+ return vec;
+}
+
+std::vector<uint32_t> range(uint32_t start, uint32_t end) {
+ std::vector<uint32_t> result;
+ for (uint32_t i = start; i < end; ++i) {
+ result.push_back(i);
+ }
+ return result;
+}
+
+} \ No newline at end of file