Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
uvlad7 opened this issue Oct 2, 2024 · 0 comments
Open

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

uvlad7 opened this issue Oct 2, 2024 · 0 comments

Comments

@uvlad7
Copy link

uvlad7 commented Oct 2, 2024

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?)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant