d_heap 0.3.0 → 0.7.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/.clang-format +21 -0
- data/.github/workflows/main.yml +18 -3
- data/.gitignore +1 -0
- data/.rubocop.yml +32 -2
- data/.yardopts +10 -0
- data/CHANGELOG.md +93 -0
- data/D +7 -0
- data/README.md +416 -154
- data/d_heap.gemspec +20 -8
- data/docs/benchmarks-2.txt +93 -0
- data/docs/benchmarks-mem.txt +39 -0
- data/docs/benchmarks.txt +686 -0
- data/docs/profile.txt +358 -0
- data/ext/d_heap/.rubocop.yml +7 -0
- data/ext/d_heap/d_heap.c +917 -295
- data/ext/d_heap/extconf.rb +45 -3
- data/images/push_n.png +0 -0
- data/images/push_n_pop_n.png +0 -0
- data/images/push_pop.png +0 -0
- data/images/wikipedia-min-heap.png +0 -0
- data/lib/d_heap.rb +116 -3
- data/lib/d_heap/version.rb +1 -1
- metadata +33 -17
- data/.rspec +0 -3
- data/.travis.yml +0 -6
- data/Gemfile +0 -11
- data/Gemfile.lock +0 -67
- data/Rakefile +0 -20
- data/bin/console +0 -15
- data/bin/rake +0 -29
- data/bin/rspec +0 -29
- data/bin/rubocop +0 -29
- data/bin/setup +0 -8
- data/ext/d_heap/d_heap.h +0 -41
data/bin/rspec
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# frozen_string_literal: true
|
3
|
-
|
4
|
-
#
|
5
|
-
# This file was generated by Bundler.
|
6
|
-
#
|
7
|
-
# The application 'rspec' is installed as part of a gem, and
|
8
|
-
# this file is here to facilitate running it.
|
9
|
-
#
|
10
|
-
|
11
|
-
require "pathname"
|
12
|
-
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
|
13
|
-
Pathname.new(__FILE__).realpath)
|
14
|
-
|
15
|
-
bundle_binstub = File.expand_path("../bundle", __FILE__)
|
16
|
-
|
17
|
-
if File.file?(bundle_binstub)
|
18
|
-
if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
|
19
|
-
load(bundle_binstub)
|
20
|
-
else
|
21
|
-
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
22
|
-
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
require "rubygems"
|
27
|
-
require "bundler/setup"
|
28
|
-
|
29
|
-
load Gem.bin_path("rspec-core", "rspec")
|
data/bin/rubocop
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# frozen_string_literal: true
|
3
|
-
|
4
|
-
#
|
5
|
-
# This file was generated by Bundler.
|
6
|
-
#
|
7
|
-
# The application 'rubocop' is installed as part of a gem, and
|
8
|
-
# this file is here to facilitate running it.
|
9
|
-
#
|
10
|
-
|
11
|
-
require "pathname"
|
12
|
-
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
|
13
|
-
Pathname.new(__FILE__).realpath)
|
14
|
-
|
15
|
-
bundle_binstub = File.expand_path("../bundle", __FILE__)
|
16
|
-
|
17
|
-
if File.file?(bundle_binstub)
|
18
|
-
if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
|
19
|
-
load(bundle_binstub)
|
20
|
-
else
|
21
|
-
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
22
|
-
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
require "rubygems"
|
27
|
-
require "bundler/setup"
|
28
|
-
|
29
|
-
load Gem.bin_path("rubocop", "rubocop")
|
data/bin/setup
DELETED
data/ext/d_heap/d_heap.h
DELETED
@@ -1,41 +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
|
-
// copied from pg gem
|
17
|
-
|
18
|
-
#define UNUSED(x) ((void)(x))
|
19
|
-
|
20
|
-
#ifdef HAVE_RB_GC_MARK_MOVABLE
|
21
|
-
#define dheap_compact_callback(x) ((void (*)(void*))(x))
|
22
|
-
#define dheap_gc_location(x) x = rb_gc_location(x)
|
23
|
-
#else
|
24
|
-
#define rb_gc_mark_movable(x) rb_gc_mark(x)
|
25
|
-
#define dheap_compact_callback(x) {(x)}
|
26
|
-
#define dheap_gc_location(x) UNUSED(x)
|
27
|
-
#endif
|
28
|
-
|
29
|
-
// from internal/compar.h
|
30
|
-
#define STRING_P(s) (RB_TYPE_P((s), T_STRING) && CLASS_OF(s) == rb_cString)
|
31
|
-
|
32
|
-
#ifdef __D_HEAP_DEBUG
|
33
|
-
#define debug(v) { \
|
34
|
-
ID sym_puts = rb_intern("puts"); \
|
35
|
-
rb_funcall(rb_mKernel, sym_puts, 1, v); \
|
36
|
-
}
|
37
|
-
#else
|
38
|
-
#define debug(v)
|
39
|
-
#endif
|
40
|
-
|
41
|
-
#endif /* D_HEAP_H */
|