d_heap 0.2.2 → 0.6.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class DHeap
4
- VERSION = "0.2.2"
4
+ VERSION = "0.6.1"
5
5
 
6
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.2
4
+ version: 0.6.1
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-27 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.
@@ -25,22 +53,48 @@ files:
25
53
  - ".rspec"
26
54
  - ".rubocop.yml"
27
55
  - ".travis.yml"
56
+ - ".yardopts"
57
+ - CHANGELOG.md
28
58
  - CODE_OF_CONDUCT.md
29
59
  - Gemfile
30
60
  - Gemfile.lock
31
61
  - LICENSE.txt
62
+ - N
32
63
  - README.md
33
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
34
74
  - bin/console
75
+ - bin/profile
35
76
  - bin/rake
36
77
  - bin/rspec
37
78
  - bin/rubocop
38
79
  - bin/setup
39
80
  - d_heap.gemspec
81
+ - docs/benchmarks-2.txt
82
+ - docs/benchmarks-mem.txt
83
+ - docs/benchmarks.txt
84
+ - docs/profile.txt
40
85
  - ext/d_heap/d_heap.c
41
- - ext/d_heap/d_heap.h
42
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
43
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
44
98
  - lib/d_heap/version.rb
45
99
  homepage: https://github.com/nevans/d_heap
46
100
  licenses:
@@ -48,7 +102,7 @@ licenses:
48
102
  metadata:
49
103
  homepage_uri: https://github.com/nevans/d_heap
50
104
  source_code_uri: https://github.com/nevans/d_heap
51
- changelog_uri: https://github.com/nevans/d_heap/blob/master/Changelog.md
105
+ changelog_uri: https://github.com/nevans/d_heap/blob/master/CHANGELOG.md
52
106
  post_install_message:
53
107
  rdoc_options: []
54
108
  require_paths:
@@ -57,7 +111,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
57
111
  requirements:
58
112
  - - ">="
59
113
  - !ruby/object:Gem::Version
60
- version: 2.5.0
114
+ version: 2.4.0
61
115
  required_rubygems_version: !ruby/object:Gem::Requirement
62
116
  requirements:
63
117
  - - ">="
@@ -1,65 +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
- VALUE rb_cDHeap;
15
-
16
- #define CMP_LT(a, b) (optimized_cmp(a, b) < 0)
17
- #define CMP_LTE(a, b) (optimized_cmp(a, b) <= 0)
18
- #define CMP_GT(a, b) (optimized_cmp(a, b) > 0)
19
- #define CMP_GTE(a, b) (optimized_cmp(a, b) >= 0)
20
-
21
- // <=>
22
- ID id_cmp;
23
-
24
- // from internal/compar.h
25
- #define STRING_P(s) (RB_TYPE_P((s), T_STRING) && CLASS_OF(s) == rb_cString)
26
-
27
- /*
28
- * short-circuit evaluation for a few basic types.
29
- *
30
- * Only Integer, Float, and String are optimized,
31
- * and only when both arguments are the same type.
32
- */
33
- static inline int
34
- optimized_cmp(VALUE a, VALUE b) {
35
- if (a == b) // Fixnum equality and object equality
36
- return 0;
37
- if (FIXNUM_P(a) && FIXNUM_P(b))
38
- return (FIX2LONG(a) < FIX2LONG(b)) ? -1 : 1;
39
- if (RB_FLOAT_TYPE_P(a) && RB_FLOAT_TYPE_P(b))
40
- {
41
- double x, y;
42
- x = RFLOAT_VALUE(a);
43
- y = RFLOAT_VALUE(b);
44
- if (isnan(x) || isnan(y)) rb_cmperr(a, b); // raise ArgumentError
45
- return (x < y) ? -1 : ((x == y) ? 0 : 1);
46
- }
47
- if (RB_TYPE_P(a, T_BIGNUM) && RB_TYPE_P(b, T_BIGNUM))
48
- return FIX2INT(rb_big_cmp(a, b));
49
- if (STRING_P(a) && STRING_P(b))
50
- return rb_str_cmp(a, b);
51
-
52
- // give up on an optimized version and just call (a <=> b)
53
- return rb_cmpint(rb_funcallv(a, id_cmp, 1, &b), a, b);
54
- }
55
-
56
- #ifdef __D_HEAP_DEBUG
57
- #define debug(v) { \
58
- ID sym_puts = rb_intern("puts"); \
59
- rb_funcall(rb_mKernel, sym_puts, 1, v); \
60
- }
61
- #else
62
- #define debug(v)
63
- #endif
64
-
65
- #endif /* D_HEAP_H */