tatara 0.2.0 → 0.3.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.
Files changed (41) hide show
  1. checksums.yaml +4 -4
  2. data/.circleci/config.yml +17 -1
  3. data/.gitignore +1 -0
  4. data/Gemfile +0 -1
  5. data/Gemfile.lock +0 -2
  6. data/Makefile +11 -73
  7. data/README.md +2 -1
  8. data/docs/tatara/float_array.md +65 -0
  9. data/docs/tatara/float_vector.md +64 -0
  10. data/docs/tatara/integer_array.md +64 -0
  11. data/docs/tatara/integer_vector.md +64 -0
  12. data/docs/tatara/string_array.md +64 -0
  13. data/docs/tatara/string_vector.md +64 -0
  14. data/ext/tatara/array/array.hpp +5 -119
  15. data/ext/tatara/array/float/float_array.hpp +132 -0
  16. data/ext/tatara/array/integer/int_array.hpp +132 -0
  17. data/ext/tatara/array/string/string_array.hpp +133 -0
  18. data/ext/tatara/extconf.rb +1 -1
  19. data/ext/tatara/float/float.hpp +148 -0
  20. data/ext/tatara/integer/integer.hpp +164 -0
  21. data/ext/tatara/map/float/float_float_map.hpp +66 -0
  22. data/ext/tatara/map/float/float_int_map.hpp +66 -0
  23. data/ext/tatara/map/float/float_string_map.hpp +67 -0
  24. data/ext/tatara/map/integer/int_float_map.hpp +66 -0
  25. data/ext/tatara/map/integer/int_int_map.hpp +66 -0
  26. data/ext/tatara/map/integer/int_string_map.hpp +67 -0
  27. data/ext/tatara/map/map.hpp +14 -27
  28. data/ext/tatara/map/string/string_float_map.hpp +67 -0
  29. data/ext/tatara/map/string/string_int_map.hpp +67 -0
  30. data/ext/tatara/map/string/string_string_map.hpp +67 -0
  31. data/ext/tatara/string/string.hpp +105 -0
  32. data/ext/tatara/tatara.cpp +245 -244
  33. data/ext/tatara/vector/float/float_vector.hpp +132 -0
  34. data/ext/tatara/vector/integer/int_vector.hpp +132 -0
  35. data/ext/tatara/vector/string/string_vector.hpp +133 -0
  36. data/ext/tatara/vector/vector.hpp +4 -0
  37. data/lib/tatara/array/array.rb +73 -0
  38. data/lib/tatara/vector/vector.rb +77 -0
  39. data/lib/tatara/version.rb +1 -1
  40. data/tatara.gemspec +1 -0
  41. metadata +31 -2
@@ -0,0 +1,66 @@
1
+ #ifndef FLOAT_FLOAT_MAP_HPP_
2
+ #define FLOAT_FLOAT_MAP_HPP_
3
+
4
+ #include <ruby.h>
5
+ #include <unordered_map>
6
+
7
+ class FloatFloatMap {
8
+ std::unordered_map<double, double> container;
9
+
10
+ public:
11
+ FloatFloatMap();
12
+ ~FloatFloatMap();
13
+ double bracket(const double key);
14
+ double bracket_equal(const double key, const double value);
15
+ };
16
+
17
+ FloatFloatMap::FloatFloatMap() {}
18
+
19
+ FloatFloatMap::~FloatFloatMap() {}
20
+
21
+ double FloatFloatMap::bracket(const double key) {
22
+ return this->container[key];
23
+ }
24
+
25
+ double FloatFloatMap::bracket_equal(const double key, const double value) {
26
+ return this->container[key] = value;
27
+ }
28
+
29
+ static FloatFloatMap *getFloatFloatMap(VALUE self) {
30
+ FloatFloatMap *ptr;
31
+ Data_Get_Struct(self, FloatFloatMap, ptr);
32
+ return ptr;
33
+ }
34
+
35
+ static void wrap_float_float_map_free(FloatFloatMap *ptr) {
36
+ ptr->~FloatFloatMap();
37
+ ruby_xfree(ptr);
38
+ }
39
+
40
+ static VALUE wrap_float_float_map_alloc(VALUE klass) {
41
+ void *p = ruby_xmalloc(sizeof(FloatFloatMap));
42
+ p = new FloatFloatMap;
43
+ return Data_Wrap_Struct(klass, NULL, wrap_float_float_map_free, p);
44
+ }
45
+
46
+ static VALUE wrap_float_float_map_init(VALUE self) {
47
+ FloatFloatMap *p = getFloatFloatMap(self);
48
+ p = new FloatFloatMap;
49
+ return Qnil;
50
+ }
51
+
52
+ static VALUE wrap_float_float_map_bracket(VALUE self, VALUE key) {
53
+ const double k = NUM2DBL(key);
54
+ const double value = getFloatFloatMap(self)->bracket(k);
55
+ VALUE result = DBL2NUM(value);
56
+ return result;
57
+ }
58
+
59
+ static VALUE wrap_float_float_map_bracket_equal(VALUE self, VALUE key, VALUE value) {
60
+ const double k = NUM2DBL(key);
61
+ const double v = NUM2DBL(value);
62
+ getFloatFloatMap(self)->bracket_equal(k, v);
63
+ return value;
64
+ }
65
+
66
+ #endif
@@ -0,0 +1,66 @@
1
+ #ifndef FLOAT_INT_MAP_HPP_
2
+ #define FLOAT_INT_MAP_HPP_
3
+
4
+ #include <ruby.h>
5
+ #include <unordered_map>
6
+
7
+ class FloatIntMap {
8
+ std::unordered_map<double, int> container;
9
+
10
+ public:
11
+ FloatIntMap();
12
+ ~FloatIntMap();
13
+ int bracket(const double key);
14
+ int bracket_equal(const double key, const int value);
15
+ };
16
+
17
+ FloatIntMap::FloatIntMap() {}
18
+
19
+ FloatIntMap::~FloatIntMap() {}
20
+
21
+ int FloatIntMap::bracket(const double key) {
22
+ return this->container[key];
23
+ }
24
+
25
+ int FloatIntMap::bracket_equal(const double key, const int value) {
26
+ return this->container[key] = value;
27
+ }
28
+
29
+ static FloatIntMap *getFloatIntMap(VALUE self) {
30
+ FloatIntMap *ptr;
31
+ Data_Get_Struct(self, FloatIntMap, ptr);
32
+ return ptr;
33
+ }
34
+
35
+ static void wrap_float_int_map_free(FloatIntMap *ptr) {
36
+ ptr->~FloatIntMap();
37
+ ruby_xfree(ptr);
38
+ }
39
+
40
+ static VALUE wrap_float_int_map_alloc(VALUE klass) {
41
+ void *p = ruby_xmalloc(sizeof(FloatIntMap));
42
+ p = new FloatIntMap;
43
+ return Data_Wrap_Struct(klass, NULL, wrap_float_int_map_free, p);
44
+ }
45
+
46
+ static VALUE wrap_float_int_map_init(VALUE self) {
47
+ FloatIntMap *p = getFloatIntMap(self);
48
+ p = new FloatIntMap;
49
+ return Qnil;
50
+ }
51
+
52
+ static VALUE wrap_float_int_map_bracket(VALUE self, VALUE key) {
53
+ const double k = NUM2DBL(key);
54
+ const int value = getFloatIntMap(self)->bracket(k);
55
+ VALUE result = INT2NUM(value);
56
+ return result;
57
+ }
58
+
59
+ static VALUE wrap_float_int_map_bracket_equal(VALUE self, VALUE key, VALUE value) {
60
+ const double k = NUM2DBL(key);
61
+ const int v = NUM2INT(value);
62
+ getFloatIntMap(self)->bracket_equal(k, v);
63
+ return value;
64
+ }
65
+
66
+ #endif
@@ -0,0 +1,67 @@
1
+ #ifndef FLOAT_STRING_MAP_HPP_
2
+ #define FLOAT_STRING_MAP_HPP_
3
+
4
+ #include <ruby.h>
5
+ #include <unordered_map>
6
+ #include <string>
7
+
8
+ class FloatStringMap {
9
+ std::unordered_map<double, std::string> container;
10
+
11
+ public:
12
+ FloatStringMap();
13
+ ~FloatStringMap();
14
+ std::string bracket(const double key);
15
+ std::string bracket_equal(const double key, const std::string value);
16
+ };
17
+
18
+ FloatStringMap::FloatStringMap() {}
19
+
20
+ FloatStringMap::~FloatStringMap() {}
21
+
22
+ std::string FloatStringMap::bracket(const double key) {
23
+ return this->container[key];
24
+ }
25
+
26
+ std::string FloatStringMap::bracket_equal(const double key, const std::string value) {
27
+ return this->container[key] = value;
28
+ }
29
+
30
+ static FloatStringMap* getFloatStringMap(VALUE self) {
31
+ FloatStringMap *ptr;
32
+ Data_Get_Struct(self, FloatStringMap, ptr);
33
+ return ptr;
34
+ }
35
+
36
+ static void wrap_float_string_map_free(FloatStringMap *ptr) {
37
+ ptr->~FloatStringMap();
38
+ ruby_xfree(ptr);
39
+ }
40
+
41
+ static VALUE wrap_float_string_map_alloc(VALUE klass) {
42
+ void *p = ruby_xmalloc(sizeof(FloatStringMap));
43
+ p = new FloatStringMap;
44
+ return Data_Wrap_Struct(klass, NULL, wrap_float_string_map_free, p);
45
+ }
46
+
47
+ static VALUE wrap_float_string_map_init(VALUE self) {
48
+ FloatStringMap *p = getFloatStringMap(self);
49
+ p = new FloatStringMap;
50
+ return Qnil;
51
+ }
52
+
53
+ static VALUE wrap_float_string_map_bracket(VALUE self, VALUE key) {
54
+ const double k = NUM2DBL(key);
55
+ const std::string value = getFloatStringMap(self)->bracket(k);
56
+ VALUE result = rb_str_new(value.c_str(), value.size());
57
+ return result;
58
+ }
59
+
60
+ static VALUE wrap_float_string_map_bracket_equal(VALUE self, VALUE key, VALUE value) {
61
+ const double k = NUM2DBL(key);
62
+ const std::string v = StringValueCStr(value);
63
+ getFloatStringMap(self)->bracket_equal(k, v);
64
+ return value;
65
+ }
66
+
67
+ #endif
@@ -0,0 +1,66 @@
1
+ #ifndef INT_FLOAT_MAP_HPP_
2
+ #define INT_FLOAT_MAP_HPP_
3
+
4
+ #include <ruby.h>
5
+ #include <unordered_map>
6
+
7
+ class IntFloatMap {
8
+ std::unordered_map<int, double> container;
9
+
10
+ public:
11
+ IntFloatMap();
12
+ ~IntFloatMap();
13
+ double bracket(const int key);
14
+ double bracket_equal(const int key, const double value);
15
+ };
16
+
17
+ IntFloatMap::IntFloatMap() {}
18
+
19
+ IntFloatMap::~IntFloatMap() {}
20
+
21
+ double IntFloatMap::bracket(const int key) {
22
+ return this->container[key];
23
+ }
24
+
25
+ double IntFloatMap::bracket_equal(const int key, const double value) {
26
+ return this->container[key] = value;
27
+ }
28
+
29
+ static IntFloatMap *getIntFloatMap(VALUE self) {
30
+ IntFloatMap *ptr;
31
+ Data_Get_Struct(self, IntFloatMap, ptr);
32
+ return ptr;
33
+ }
34
+
35
+ static void wrap_int_float_map_free(IntFloatMap *ptr) {
36
+ ptr->~IntFloatMap();
37
+ ruby_xfree(ptr);
38
+ }
39
+
40
+ static VALUE wrap_int_float_map_alloc(VALUE klass) {
41
+ void *p = ruby_xmalloc(sizeof(IntFloatMap));
42
+ p = new IntFloatMap;
43
+ return Data_Wrap_Struct(klass, NULL, wrap_int_float_map_free, p);
44
+ }
45
+
46
+ static VALUE wrap_int_float_map_init(VALUE self) {
47
+ IntFloatMap *p = getIntFloatMap(self);
48
+ p = new IntFloatMap;
49
+ return Qnil;
50
+ }
51
+
52
+ static VALUE wrap_int_float_map_bracket(VALUE self, VALUE key) {
53
+ const int k = NUM2INT(key);
54
+ const double value = getIntFloatMap(self)->bracket(k);
55
+ VALUE result = DBL2NUM(value);
56
+ return result;
57
+ }
58
+
59
+ static VALUE wrap_int_float_map_bracket_equal(VALUE self, VALUE key, VALUE value) {
60
+ const int k = NUM2INT(key);
61
+ const double v = NUM2DBL(value);
62
+ getIntFloatMap(self)->bracket_equal(k, v);
63
+ return value;
64
+ }
65
+
66
+ #endif
@@ -0,0 +1,66 @@
1
+ #ifndef INT_INT_MAP_HPP_
2
+ #define INT_INT_MAP_HPP_
3
+
4
+ #include <ruby.h>
5
+ #include <unordered_map>
6
+
7
+ class IntIntMap {
8
+ std::unordered_map<int, int> container;
9
+
10
+ public:
11
+ IntIntMap();
12
+ ~IntIntMap();
13
+ int bracket(const int key);
14
+ int bracket_equal(const int key, const int value);
15
+ };
16
+
17
+ IntIntMap::IntIntMap() {}
18
+
19
+ IntIntMap::~IntIntMap() {}
20
+
21
+ int IntIntMap::bracket(const int key) {
22
+ return this->container[key];
23
+ }
24
+
25
+ int IntIntMap::bracket_equal(const int key, const int value) {
26
+ return this->container[key] = value;
27
+ }
28
+
29
+ static IntIntMap *getIntIntMap(VALUE self) {
30
+ IntIntMap *ptr;
31
+ Data_Get_Struct(self, IntIntMap, ptr);
32
+ return ptr;
33
+ }
34
+
35
+ static void wrap_int_int_map_free(IntIntMap *ptr) {
36
+ ptr->~IntIntMap();
37
+ ruby_xfree(ptr);
38
+ }
39
+
40
+ static VALUE wrap_int_int_map_alloc(VALUE klass) {
41
+ void *p = ruby_xmalloc(sizeof(IntIntMap));
42
+ p = new IntIntMap;
43
+ return Data_Wrap_Struct(klass, NULL, wrap_int_int_map_free, p);
44
+ }
45
+
46
+ static VALUE wrap_int_int_map_init(VALUE self) {
47
+ IntIntMap *p = getIntIntMap(self);
48
+ p = new IntIntMap;
49
+ return Qnil;
50
+ }
51
+
52
+ static VALUE wrap_int_int_map_bracket(VALUE self, VALUE key) {
53
+ const int k = NUM2INT(key);
54
+ const int value = getIntIntMap(self)->bracket(k);
55
+ VALUE result = INT2NUM(value);
56
+ return result;
57
+ }
58
+
59
+ static VALUE wrap_int_int_map_bracket_equal(VALUE self, VALUE key, VALUE value) {
60
+ const int k = NUM2INT(key);
61
+ const int v = NUM2INT(value);
62
+ getIntIntMap(self)->bracket_equal(k, v);
63
+ return value;
64
+ }
65
+
66
+ #endif
@@ -0,0 +1,67 @@
1
+ #ifndef INT_STRING_MAP_HPP_
2
+ #define INT_STRING_MAP_HPP_
3
+
4
+ #include <ruby.h>
5
+ #include <unordered_map>
6
+ #include <string>
7
+
8
+ class IntStringMap {
9
+ std::unordered_map<int, std::string> container;
10
+
11
+ public:
12
+ IntStringMap();
13
+ ~IntStringMap();
14
+ std::string bracket(const int key);
15
+ std::string bracket_equal(const int key, const std::string value);
16
+ };
17
+
18
+ IntStringMap::IntStringMap() {}
19
+
20
+ IntStringMap::~IntStringMap() {}
21
+
22
+ std::string IntStringMap::bracket(const int key) {
23
+ return this->container[key];
24
+ }
25
+
26
+ std::string IntStringMap::bracket_equal(const int key, const std::string value) {
27
+ return this->container[key] = value;
28
+ }
29
+
30
+ static IntStringMap *getIntStringMap(VALUE self) {
31
+ IntStringMap *ptr;
32
+ Data_Get_Struct(self, IntStringMap, ptr);
33
+ return ptr;
34
+ }
35
+
36
+ static void wrap_int_string_map_free(IntStringMap *ptr) {
37
+ ptr->~IntStringMap();
38
+ ruby_xfree(ptr);
39
+ }
40
+
41
+ static VALUE wrap_int_string_map_alloc(VALUE klass) {
42
+ void *p = ruby_xmalloc(sizeof(IntStringMap));
43
+ p = new IntStringMap;
44
+ return Data_Wrap_Struct(klass, NULL, wrap_int_string_map_free, p);
45
+ }
46
+
47
+ static VALUE wrap_int_string_map_init(VALUE self) {
48
+ IntStringMap *p = getIntStringMap(self);
49
+ p = new IntStringMap;
50
+ return Qnil;
51
+ }
52
+
53
+ static VALUE wrap_int_string_map_bracket(VALUE self, VALUE key) {
54
+ const int k = NUM2INT(key);
55
+ const std::string value = getIntStringMap(self)->bracket(k);
56
+ VALUE result = rb_str_new(value.c_str(), value.size());
57
+ return result;
58
+ }
59
+
60
+ static VALUE wrap_int_string_map_bracket_equal(VALUE self, VALUE key, VALUE value) {
61
+ const int k = NUM2INT(key);
62
+ const std::string v = {StringValueCStr(value)};
63
+ getIntStringMap(self)->bracket_equal(k, v);
64
+ return value;
65
+ }
66
+
67
+ #endif
@@ -1,32 +1,19 @@
1
- #ifndef MAP_H_
2
- #define MAP_H_
1
+ #ifndef TATARA_MAP_HPP_
2
+ #define TATARA_MAP_HPP_
3
3
 
4
- #include <unordered_map>
4
+ // include String Key Map
5
+ #include "string/string_int_map.hpp"
6
+ #include "string/string_float_map.hpp"
7
+ #include "string/string_string_map.hpp"
5
8
 
6
- template <class K, class V>
7
- class Map {
8
- std::unordered_map<K, V> container;
9
- public:
10
- constexpr Map();
11
- ~Map();
12
- constexpr V bracket(const K key);
13
- constexpr V bracket_equal(const K key, const V value);
14
- };
9
+ // include Int Key Map
10
+ #include "integer/int_int_map.hpp"
11
+ #include "integer/int_float_map.hpp"
12
+ #include "integer/int_string_map.hpp"
15
13
 
16
- template <class K, class V>
17
- constexpr Map<K, V>::Map() {}
18
-
19
- template <class K, class V>
20
- Map<K, V>::~Map() {}
21
-
22
- template <class K, class V>
23
- constexpr V Map<K, V>::bracket(const K key) {
24
- return this->container[key];
25
- }
26
-
27
- template <class K, class V>
28
- constexpr V Map<K, V>::bracket_equal(const K key, const V value) {
29
- return this->container[key] = value;
30
- }
14
+ // include Float Key Map
15
+ #include "float/float_int_map.hpp"
16
+ #include "float/float_float_map.hpp"
17
+ #include "float/float_string_map.hpp"
31
18
 
32
19
  #endif