Skip to content

Heap#change_key doesn't work properly with delete = true #58

@uvlad7

Description

@uvlad7

test

    it 'changes certain keys' do
      numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 100, 101]

      heap = PfCustomCrawlerNeo::Containers::MinHeap.new(numbers)
      heap.change_key(2, 102, true)
      heap.pop
      heap.pop
      heap.change_key(8, 50, true)
      ordered = []
      ordered << heap.min! until heap.empty?
      expect(ordered).to eql([4, 5, 6, 7, 9, 10, 8, 100, 101, 2])
    end

fails

     Failure/Error: expect(ordered).to eql([4, 5, 6, 7, 9, 10, 8, 100, 101, 2])
     
       expected: [4, 5, 6, 7, 9, 10, 8, 100, 101, 2]
            got: [8, 3, 4, 5, 6, 7, 9, 10, 100, 101]
     
       (compared using eql?)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions