d_heap 0.2.1 → 0.6.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.
@@ -1,3 +1,6 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class DHeap
2
- VERSION = "0.2.1"
4
+ VERSION = "0.6.0"
5
+
3
6
  end
metadata CHANGED
@@ -1,15 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: d_heap
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - nicholas a. evans
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-12-26 00:00:00.000000000 Z
12
- dependencies: []
11
+ date: 2021-01-24 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: benchmark_driver
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: ruby-prof
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
13
41
  description: |
14
42
  A C extension implementation of a d-ary heap data structure, suitable for
15
43
  use in e.g. priority queues or Djikstra's algorithm.
@@ -20,24 +48,53 @@ extensions:
20
48
  - ext/d_heap/extconf.rb
21
49
  extra_rdoc_files: []
22
50
  files:
51
+ - ".github/workflows/main.yml"
23
52
  - ".gitignore"
24
53
  - ".rspec"
54
+ - ".rubocop.yml"
25
55
  - ".travis.yml"
56
+ - ".yardopts"
57
+ - CHANGELOG.md
26
58
  - CODE_OF_CONDUCT.md
27
59
  - Gemfile
28
60
  - Gemfile.lock
29
61
  - LICENSE.txt
62
+ - N
30
63
  - README.md
31
64
  - Rakefile
65
+ - benchmarks/perf.rb
66
+ - benchmarks/push_n.yml
67
+ - benchmarks/push_n_pop_n.yml
68
+ - benchmarks/push_pop.yml
69
+ - benchmarks/stackprof.rb
70
+ - bin/bench_charts
71
+ - bin/bench_n
72
+ - bin/benchmark-driver
73
+ - bin/benchmarks
32
74
  - bin/console
75
+ - bin/profile
33
76
  - bin/rake
34
77
  - bin/rspec
78
+ - bin/rubocop
35
79
  - bin/setup
36
80
  - d_heap.gemspec
81
+ - docs/benchmarks-2.txt
82
+ - docs/benchmarks-mem.txt
83
+ - docs/benchmarks.txt
84
+ - docs/profile.txt
37
85
  - ext/d_heap/d_heap.c
38
- - ext/d_heap/d_heap.h
39
86
  - ext/d_heap/extconf.rb
87
+ - images/push_n.png
88
+ - images/push_n_pop_n.png
89
+ - images/push_pop.png
90
+ - images/wikipedia-min-heap.png
91
+ - lib/benchmark_driver/runner/ips_zero_fail.rb
40
92
  - lib/d_heap.rb
93
+ - lib/d_heap/benchmarks.rb
94
+ - lib/d_heap/benchmarks/benchmarker.rb
95
+ - lib/d_heap/benchmarks/implementations.rb
96
+ - lib/d_heap/benchmarks/profiler.rb
97
+ - lib/d_heap/benchmarks/rspec_matchers.rb
41
98
  - lib/d_heap/version.rb
42
99
  homepage: https://github.com/nevans/d_heap
43
100
  licenses:
@@ -54,14 +111,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
54
111
  requirements:
55
112
  - - ">="
56
113
  - !ruby/object:Gem::Version
57
- version: 2.5.0
114
+ version: 2.4.0
58
115
  required_rubygems_version: !ruby/object:Gem::Requirement
59
116
  requirements:
60
117
  - - ">="
61
118
  - !ruby/object:Gem::Version
62
119
  version: '0'
63
120
  requirements: []
64
- rubygems_version: 3.2.3
121
+ rubygems_version: 3.1.4
65
122
  signing_key:
66
123
  specification_version: 4
67
124
  summary: A d-ary heap implementation, for priority queues
@@ -1,74 +0,0 @@
1
- #ifndef D_HEAP_H
2
- #define D_HEAP_H 1
3
-
4
- #include "ruby.h"
5
-
6
- // d=4 uses the fewest comparisons for insert + delete-min (in the worst case).
7
- #define DHEAP_DEFAULT_D 4
8
-
9
- // This is a somewhat arbitary maximum. But benefits from more leaf nodes
10
- // are very unlikely to outweigh the increasinly higher number of worst-case
11
- // comparisons as d gets further from 4.
12
- #define DHEAP_MAX_D 32
13
-
14
-
15
- #define CMP_LT(a, b, cmp_opt) \
16
- (OPTIMIZED_CMP(a, b, cmp_opt) < 0)
17
- #define CMP_LTE(a, b, cmp_opt) \
18
- (OPTIMIZED_CMP(a, b, cmp_opt) <= 0)
19
- #define CMP_GT(a, b, cmp_opt) \
20
- (OPTIMIZED_CMP(a, b, cmp_opt) > 0)
21
- #define CMP_GTE(a, b, cmp_opt) \
22
- (OPTIMIZED_CMP(a, b, cmp_opt) >= 0)
23
-
24
- VALUE rb_cDHeap;
25
- ID id_cmp;
26
-
27
- // from internal/numeric.h
28
- #ifndef INTERNAL_NUMERIC_H
29
- int rb_float_cmp(VALUE x, VALUE y);
30
- #endif /* INTERNAL_NUMERIC_H */
31
-
32
- // from internal/compar.h
33
- #ifndef INTERNAL_COMPAR_H
34
- #define STRING_P(s) (RB_TYPE_P((s), T_STRING) && CLASS_OF(s) == rb_cString)
35
-
36
- enum {
37
- cmp_opt_Integer,
38
- cmp_opt_String,
39
- cmp_opt_Float,
40
- cmp_optimizable_count
41
- };
42
-
43
- struct cmp_opt_data {
44
- unsigned int opt_methods;
45
- unsigned int opt_inited;
46
- };
47
-
48
- #define NEW_CMP_OPT_MEMO(type, value) \
49
- NEW_PARTIAL_MEMO_FOR(type, value, cmp_opt)
50
- #define CMP_OPTIMIZABLE_BIT(type) (1U << TOKEN_PASTE(cmp_opt_,type))
51
- #define CMP_OPTIMIZABLE(data, type) \
52
- (((data).opt_inited & CMP_OPTIMIZABLE_BIT(type)) ? \
53
- ((data).opt_methods & CMP_OPTIMIZABLE_BIT(type)) : \
54
- (((data).opt_inited |= CMP_OPTIMIZABLE_BIT(type)), \
55
- rb_method_basic_definition_p(TOKEN_PASTE(rb_c,type), id_cmp) && \
56
- ((data).opt_methods |= CMP_OPTIMIZABLE_BIT(type))))
57
-
58
- #define OPTIMIZED_CMP(a, b, data) \
59
- ((FIXNUM_P(a) && FIXNUM_P(b) && CMP_OPTIMIZABLE(data, Integer)) ? \
60
- (((long)a > (long)b) ? 1 : ((long)a < (long)b) ? -1 : 0) : \
61
- (STRING_P(a) && STRING_P(b) && CMP_OPTIMIZABLE(data, String)) ? \
62
- rb_str_cmp(a, b) : \
63
- (RB_FLOAT_TYPE_P(a) && RB_FLOAT_TYPE_P(b) && CMP_OPTIMIZABLE(data, Float)) ? \
64
- rb_float_cmp(a, b) : \
65
- rb_cmpint(rb_funcallv(a, id_cmp, 1, &b), a, b))
66
-
67
- #define puts(v) { \
68
- ID sym_puts = rb_intern("puts"); \
69
- rb_funcall(rb_mKernel, sym_puts, 1, v); \
70
- }
71
-
72
- #endif /* INTERNAL_COMPAR_H */
73
-
74
- #endif /* D_HEAP_H */