pairing_heap 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bfbfbd0337f23ec71179ae039bd54331178fbe5317c7fdd53730f8e9b2152656
4
- data.tar.gz: a8fa80b6831cf3bbf2b13bafd72d7f899748c1698ac1c1d6300a3378b49a9dcc
3
+ metadata.gz: 5c613ce9a9caad4430ef201edb734809f647c31c4d55201be5a5a7db7d5fa45d
4
+ data.tar.gz: 8699200563407c193754f5bd76a345c6a6359dff22c8de4b7dda69fdb8438f4e
5
5
  SHA512:
6
- metadata.gz: 87d4f15844b9772ae6a13c2f1ec4a259f16a5a3091eaf4148730d487cc77d602939e3409de4314de8e1457800b718d6cb5d9624c81a7977eceef1f46d29ee02b
7
- data.tar.gz: a78e724d551ec09e7058ad3f7a50580cff5769d5b5269973dacd36e85486df9dfdfb21da0606c6738bd134f6d151cbfbc50a3ace2f246433badd2cb02fbe91a2
6
+ metadata.gz: 744cb71f43c43a9f767a7d4ca7e3ce644eadb17af658d8877eba5e688cdeb2ccf53371218f2ce21022b3c32621db45c213485604354e20a8d14dfae9a3e7ee23
7
+ data.tar.gz: e358f76ea6b2fc5932118d0ae053c01c53fddf4b6dc1f269a4645c6676ca5a7ff1e3cb4ee976bd2490577dae62388beaac668c9a45706b94e961aba983cf56d6
data/README.md CHANGED
@@ -835,11 +835,11 @@ Heaps that support change_priority operation use it. Heaps that do not support i
835
835
  </tr>
836
836
  <tr>
837
837
  <td>pairing_heap (PairingHeap)</td>
838
- <td>1.209</td>
838
+ <td>1.209x slower</td>
839
839
  </tr>
840
840
  <tr>
841
841
  <td>rb_heap</td>
842
- <td>1.954</td>
842
+ <td>1.954x slower</td>
843
843
  </tr>
844
844
  <tr>
845
845
  <td>lazy_priority_queue</td>
@@ -889,7 +889,7 @@ Heaps that support change_priority operation use it. Heaps that do not support i
889
889
  </tr>
890
890
  <tr>
891
891
  <td>pairing_heap (PairingHeap)</td>
892
- <td>1.296</td>
892
+ <td>1.296x slower</td>
893
893
  </tr>
894
894
  <tr>
895
895
  <td>lazy_priority_queue</td>
@@ -897,7 +897,7 @@ Heaps that support change_priority operation use it. Heaps that do not support i
897
897
  </tr>
898
898
  <tr>
899
899
  <td>rb_heap</td>
900
- <td>1.710</td>
900
+ <td>1.710x slower</td>
901
901
  </tr>
902
902
  <tr>
903
903
  <td>Fibonacci</td>
@@ -931,6 +931,7 @@ Heaps that support change_priority operation use it. Heaps that do not support i
931
931
  <td>2.044x slower</td>
932
932
  </tr>
933
933
  </table>
934
+
934
935
  ## Development
935
936
 
936
937
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PairingHeap
4
- VERSION = "0.2.0"
4
+ VERSION = "0.3.0"
5
5
  end
data/lib/pairing_heap.rb CHANGED
@@ -218,12 +218,11 @@ module PairingHeap
218
218
 
219
219
  class SimplePairingHeap
220
220
  class Node
221
- attr_accessor :elem, :priority, :subheaps, :parent, :next_sibling
222
- def initialize(elem, priority, subheaps, parent, next_sibling)
221
+ attr_accessor :elem, :priority, :subheaps, :next_sibling
222
+ def initialize(elem, priority, subheaps, next_sibling)
223
223
  @elem = elem
224
224
  @priority = priority
225
225
  @subheaps = subheaps
226
- @parent = parent
227
226
  @next_sibling = next_sibling
228
227
  end
229
228
  end
@@ -243,7 +242,7 @@ module PairingHeap
243
242
  # @raise [ArgumentError] if the element is already in the heap
244
243
  # @return [PairingHeap]
245
244
  def push(elem, priority)
246
- node = Node.new(elem, priority, nil, nil, nil)
245
+ node = Node.new(elem, priority, nil, nil)
247
246
  @root = meld(@root, node)
248
247
  @size += 1
249
248
  self
@@ -291,7 +290,6 @@ module PairingHeap
291
290
  elem = @root.elem
292
291
  @root = merge_pairs(@root.subheaps)
293
292
  if @root
294
- @root.parent = nil
295
293
  @root.next_sibling = nil
296
294
  end
297
295
  elem
@@ -320,7 +318,6 @@ module PairingHeap
320
318
  end
321
319
  child.next_sibling = parent.subheaps
322
320
  parent.subheaps = child
323
- child.parent = parent
324
321
  parent
325
322
  end
326
323
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pairing_heap
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marcin Henryk Bartkowiak
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-02-05 00:00:00.000000000 Z
11
+ date: 2022-02-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest