tatara 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.circleci/config.yml +23 -0
- data/Gemfile.lock +2 -2
- data/README.md +4 -0
- data/docs/_config.yml +1 -0
- data/docs/index.md +100 -0
- data/docs/tatara/float.md +425 -0
- data/docs/tatara/float_array.md +256 -0
- data/docs/tatara/float_float_map.md +52 -0
- data/docs/tatara/float_integer_map.md +52 -0
- data/docs/tatara/float_string_map.md +52 -0
- data/docs/tatara/float_vector.md +269 -0
- data/docs/tatara/integer.md +480 -0
- data/docs/tatara/integer_array.md +256 -0
- data/docs/tatara/integer_float_map.md +52 -0
- data/docs/tatara/integer_integer_map.md +52 -0
- data/docs/tatara/integer_string_map.md +52 -0
- data/docs/tatara/integer_vector.md +268 -0
- data/docs/tatara/string.md +223 -0
- data/docs/tatara/string_array.md +254 -0
- data/docs/tatara/string_float_map.md +56 -0
- data/docs/tatara/string_int_map.md +55 -0
- data/docs/tatara/string_string_map.md +55 -0
- data/docs/tatara/string_vector.md +270 -0
- data/ext/tatara/array/array.hpp +60 -0
- data/ext/tatara/float/float.hpp +51 -0
- data/ext/tatara/integer/integer.hpp +67 -0
- data/ext/tatara/string/string.hpp +28 -0
- data/ext/tatara/tatara.cpp +138 -9
- data/ext/tatara/vector/vector.hpp +60 -0
- data/lib/tatara.rb +2 -0
- data/lib/tatara/array/array.rb +37 -0
- data/lib/tatara/tatara_ext.rb +6 -0
- data/lib/tatara/vector/vector.rb +37 -0
- data/lib/tatara/version.rb +1 -1
- metadata +27 -3
@@ -1,6 +1,8 @@
|
|
1
1
|
#ifndef VEC_TEMPLATE_H_
|
2
2
|
#define VEC_TEMPLATE_H_
|
3
3
|
|
4
|
+
#include <algorithm>
|
5
|
+
#include <iterator>
|
4
6
|
#include <vector>
|
5
7
|
|
6
8
|
template <class T>
|
@@ -18,6 +20,12 @@ class Vector {
|
|
18
20
|
constexpr int size();
|
19
21
|
constexpr void clear();
|
20
22
|
T sum();
|
23
|
+
constexpr Vector<T>& push_back_object(const T var);
|
24
|
+
constexpr Vector<T> intersection(const Vector<T> vec);
|
25
|
+
constexpr Vector<T> sort();
|
26
|
+
constexpr Vector<T>& destructive_sort();
|
27
|
+
constexpr Vector<T> reverse();
|
28
|
+
constexpr Vector<T>& destructive_reverse();
|
21
29
|
};
|
22
30
|
|
23
31
|
template <class T>
|
@@ -71,4 +79,56 @@ T Vector<T>::sum() {
|
|
71
79
|
return sum;
|
72
80
|
}
|
73
81
|
|
82
|
+
template <class T>
|
83
|
+
constexpr Vector<T>& Vector<T>::push_back_object(const T var) {
|
84
|
+
this->container.emplace_back(std::move(var));
|
85
|
+
return *this;
|
86
|
+
}
|
87
|
+
|
88
|
+
template <class T>
|
89
|
+
constexpr Vector<T> Vector<T>::intersection(const Vector<T> vec) {
|
90
|
+
|
91
|
+
std::vector<T> result;
|
92
|
+
|
93
|
+
std::set_intersection(
|
94
|
+
this->container.begin(), this->container.end(),
|
95
|
+
vec.container.begin(), vec.container.end(),
|
96
|
+
std::inserter(result, result.end())
|
97
|
+
);
|
98
|
+
|
99
|
+
Vector<T> object;
|
100
|
+
|
101
|
+
object.container = std::move(result);
|
102
|
+
|
103
|
+
return object;
|
104
|
+
}
|
105
|
+
|
106
|
+
template <class T>
|
107
|
+
constexpr Vector<T> Vector<T>::sort() {
|
108
|
+
Vector<T> object;
|
109
|
+
object.container = this->container;
|
110
|
+
std::sort(object.container.begin(), object.container.end());
|
111
|
+
return object;
|
112
|
+
}
|
113
|
+
|
114
|
+
template <class T>
|
115
|
+
constexpr Vector<T>& Vector<T>::destructive_sort() {
|
116
|
+
std::sort(this->container.begin(), this->container.end());
|
117
|
+
return *this;
|
118
|
+
}
|
119
|
+
|
120
|
+
template <class T>
|
121
|
+
constexpr Vector<T> Vector<T>::reverse() {
|
122
|
+
Vector<T> object;
|
123
|
+
object.container = this->container;
|
124
|
+
std::reverse(object.container.begin(), object.container.end());
|
125
|
+
return object;
|
126
|
+
}
|
127
|
+
|
128
|
+
template <class T>
|
129
|
+
constexpr Vector<T>& Vector<T>::destructive_reverse() {
|
130
|
+
std::reverse(this->container.begin(), this->container.end());
|
131
|
+
return *this;
|
132
|
+
}
|
133
|
+
|
74
134
|
#endif
|
data/lib/tatara.rb
CHANGED
@@ -0,0 +1,37 @@
|
|
1
|
+
require "tatara/tatara"
|
2
|
+
|
3
|
+
module Tatara
|
4
|
+
module Array
|
5
|
+
def map(&block)
|
6
|
+
(0...(self.size)).each{|i| block.call(self[i])}
|
7
|
+
end
|
8
|
+
|
9
|
+
def map!(&block)
|
10
|
+
(0...(self.size)).each{|i| self[i] = block.call(self[i]) }
|
11
|
+
end
|
12
|
+
|
13
|
+
def each(&block)
|
14
|
+
(0...(self.size)).each{|i| block.call(self[i])}
|
15
|
+
end
|
16
|
+
|
17
|
+
def each_with_index(&block)
|
18
|
+
(0...(self.size)).each{|i| block.call(self[i], i)}
|
19
|
+
end
|
20
|
+
|
21
|
+
def &(other)
|
22
|
+
self.intersection other
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
class IntArray
|
27
|
+
include Array
|
28
|
+
end
|
29
|
+
|
30
|
+
class FloatArray
|
31
|
+
include Array
|
32
|
+
end
|
33
|
+
|
34
|
+
class StringArray
|
35
|
+
include Array
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require "tatara/tatara"
|
2
|
+
|
3
|
+
module Tatara
|
4
|
+
module Vector
|
5
|
+
def map(&block)
|
6
|
+
(0...(self.size)).each{|i| block.call(self[i])}
|
7
|
+
end
|
8
|
+
|
9
|
+
def map!(&block)
|
10
|
+
(0...(self.size)).each{|i| self[i] = block.call(self[i]) }
|
11
|
+
end
|
12
|
+
|
13
|
+
def each(&block)
|
14
|
+
(0...(self.size)).each{|i| block.call(self[i])}
|
15
|
+
end
|
16
|
+
|
17
|
+
def each_with_index(&block)
|
18
|
+
(0...(self.size)).each{|i| block.call(self[i], i)}
|
19
|
+
end
|
20
|
+
|
21
|
+
def &(other)
|
22
|
+
self.intersection other
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
class IntVector
|
27
|
+
include Vector
|
28
|
+
end
|
29
|
+
|
30
|
+
class FloatVector
|
31
|
+
include Vector
|
32
|
+
end
|
33
|
+
|
34
|
+
class StringVector
|
35
|
+
include Vector
|
36
|
+
end
|
37
|
+
end
|
data/lib/tatara/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tatara
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- S-H-GAMELINKS
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-11-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -60,6 +60,7 @@ extensions:
|
|
60
60
|
- ext/tatara/extconf.rb
|
61
61
|
extra_rdoc_files: []
|
62
62
|
files:
|
63
|
+
- ".circleci/config.yml"
|
63
64
|
- ".gitignore"
|
64
65
|
- ".travis.yml"
|
65
66
|
- Gemfile
|
@@ -71,6 +72,26 @@ files:
|
|
71
72
|
- benchmark/benchmark.rb
|
72
73
|
- bin/console
|
73
74
|
- bin/setup
|
75
|
+
- docs/_config.yml
|
76
|
+
- docs/index.md
|
77
|
+
- docs/tatara/float.md
|
78
|
+
- docs/tatara/float_array.md
|
79
|
+
- docs/tatara/float_float_map.md
|
80
|
+
- docs/tatara/float_integer_map.md
|
81
|
+
- docs/tatara/float_string_map.md
|
82
|
+
- docs/tatara/float_vector.md
|
83
|
+
- docs/tatara/integer.md
|
84
|
+
- docs/tatara/integer_array.md
|
85
|
+
- docs/tatara/integer_float_map.md
|
86
|
+
- docs/tatara/integer_integer_map.md
|
87
|
+
- docs/tatara/integer_string_map.md
|
88
|
+
- docs/tatara/integer_vector.md
|
89
|
+
- docs/tatara/string.md
|
90
|
+
- docs/tatara/string_array.md
|
91
|
+
- docs/tatara/string_float_map.md
|
92
|
+
- docs/tatara/string_int_map.md
|
93
|
+
- docs/tatara/string_string_map.md
|
94
|
+
- docs/tatara/string_vector.md
|
74
95
|
- ext/tatara/array/array.hpp
|
75
96
|
- ext/tatara/extconf.rb
|
76
97
|
- ext/tatara/float/float.hpp
|
@@ -80,6 +101,9 @@ files:
|
|
80
101
|
- ext/tatara/tatara.cpp
|
81
102
|
- ext/tatara/vector/vector.hpp
|
82
103
|
- lib/tatara.rb
|
104
|
+
- lib/tatara/array/array.rb
|
105
|
+
- lib/tatara/tatara_ext.rb
|
106
|
+
- lib/tatara/vector/vector.rb
|
83
107
|
- lib/tatara/version.rb
|
84
108
|
- tatara.gemspec
|
85
109
|
homepage: https://github.com/S-H-GAMELINKS/tatara
|
@@ -100,7 +124,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
100
124
|
- !ruby/object:Gem::Version
|
101
125
|
version: '0'
|
102
126
|
requirements: []
|
103
|
-
rubygems_version: 3.0.
|
127
|
+
rubygems_version: 3.0.3
|
104
128
|
signing_key:
|
105
129
|
specification_version: 4
|
106
130
|
summary: Simple type declaration lib
|