Git Product home page Git Product logo

Comments (6)

garro95 avatar garro95 commented on June 18, 2024

Are you able to reproduce the issue with a minimal example?

from priority-queue.

testforvln avatar testforvln commented on June 18, 2024

use priority_queue::{DoublePriorityQueue, PriorityQueue};

fn main() {
let mut double_queue = DoublePriorityQueue::new();
let mut simple_queue = PriorityQueue::new();
let data = vec![23403.4, 23375.2, 23395.9, 23400.1, 23401.6, 23375.2, 23391.1, 23410.3, 23391.6, 23402.2, 23407.6, 23414.5, 23421.0, 23430.5, 23430.5, 23441.6, 23441.6, 23440.2, 23424.2, 23465.5, 23273.3, 23232.3, 23183.1, 23315.6, 23328.5, 23328.5, 23346.9, 23350.0, 23363.6, 23388.1, 23403.6, 23385.3, 23385.8, 23385.8, 23363.6, 23363.6, 23398.9, 23400.7, 23401.7, 23370.0, 23370.0, 23396.7, 23370.0, 23370.0, 23396.8, 23385.0, 23369.1, 23381.8, 23372.3, 23382.6, 23382.3, 23401.5, 23405.0, 23392.0, 23392.0, 23398.4, 23393.8, 23382.3, 23382.8, 23376.2, 23379.3, 23380.6, 23380.6, 23384.4, 23379.5, 23381.7, 23391.7, 23396.3, 23402.0, 23414.8, 23410.9, 23423.6, 23419.3, 23419.3, 23420.9, 23397.1, 23425.9, 23397.1, 23397.1, 23417.4, 23413.6, 23422.7, 23422.7, 23413.6, 23407.4, 23413.9, 23407.4, 23397.1, 23391.1, 23390.0, 23388.5, 23383.0, 23375.9, 23355.1, 23354.3, 23370.4, 23381.8, 23381.8, 23383.6, 23391.4, 23393.8, 23393.8, 23379.1, 23380.8, 23384.9, 23384.9, 23390.2, 23382.0, 23380.8, 23379.9, 23370.5, 23377.3, 23378.0, 23391.7, 23386.7, 23374.2, 23392.2, 23394.5, 23403.2, 23413.5, 23420.4, 23443.8, 23441.6, 23441.6, 23485.3, 23488.5, 23488.5, 23505.3, 23471.4, 23471.4, 23477.9, 23488.7, 23488.7, 23483.2, 23463.2, 23463.2, 23463.6, 23463.6, 23468.8, 23485.7, 23487.8, 23508.6, 23512.9, 23507.7, 23507.7, 23539.2, 23541.7, 23539.2, 23507.7, 23487.8, 23487.8, 23553.5, 23553.5, 23553.5, 23553.5, 23553.5, 23553.5, 23565.5, 23566.7, 23566.7, 23566.7, 23565.5, 23566.7, 23565.5, 23566.7, 23566.7, 23549.9, 23541.3, 23560.8, 23566.8, 23563.5, 23563.5, 23541.3, 23538.3, 23535.3, 23543.7, 23549.1, 23549.6, 23520.0, 23500.0, 23545.6, 23554.3, 23558.6, 23526.7, 23452.1, 23526.7, 23520.0, 23520.0, 23526.7, 23524.3, 23524.3, 23526.7, 23524.3, 23450.0, 23450.0, 23354.3, 23350.0, 23521.1, 23542.7, 23553.7];
let window = 32;
for idx in 0..window {
let val = (data[idx] * 1000.0 as f64).round() as i32;
simple_queue.push(idx, -val);
double_queue.push(idx, val);
}
for idx in window..data.len() {
let val = (data[idx] * 1000.0 as f64).round() as i32;
simple_queue.change_priority(&(idx % window), -val);
double_queue.change_priority(&(idx % window), val);
let simple_min_result = -simple_queue.peek().unwrap().1.clone();
let double_min_result = double_queue.peek_min().unwrap().1.clone();
if simple_min_result != double_min_result {
println!("{} {} {} ", idx, simple_min_result, double_min_result);
}
}
}

You can try this code.

from priority-queue.

garro95 avatar garro95 commented on June 18, 2024

@testforvln Can I add your code, modified, to the test suite of DoublePriorityQueue?

from priority-queue.

testforvln avatar testforvln commented on June 18, 2024

@testforvln Can I add your code, modified, to the test suite of DoublePriorityQueue?

Of course, use the code as you wish.

from priority-queue.

garro95 avatar garro95 commented on June 18, 2024

Thanks for your contribution. Version 1.3.1 has been released, that includes the fix for this bug

from priority-queue.

testforvln avatar testforvln commented on June 18, 2024

Thanks for your contribution. Version 1.3.1 has been released, that includes the fix for this bug

Great! It's my pleasure to make subtle contribution to your project and the rust ecosystem.

from priority-queue.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.