Skip to content

Conversation

@kareltucek
Copy link
Collaborator

@kareltucek kareltucek commented Jan 29, 2026

Summary

  • Replace linear scan for finding next event with a binary min-heap data structure
  • Improves complexity from O(n) to O(log n) for schedule/reschedule/unschedule operations
  • O(1) for finding the minimum (peeking at the next event)
  • Uses an index array to track each event type's heap position for efficient updates

Test plan

  • Verify scheduled events fire at correct times
  • Verify rescheduling works correctly
  • Verify unscheduling works correctly

🤖 Generated with Claude Code

Replace the linear scan for finding the next event with a binary
min-heap data structure. This improves the complexity from O(n) to
O(log n) for schedule/reschedule/unschedule operations, and O(1) for
finding the minimum.

The heap uses an index array to track each event type's position,
enabling efficient updates and removals by event type.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@kareltucek kareltucek force-pushed the feature/event-scheduler-heap branch from 337b46a to 63989b5 Compare January 30, 2026 11:42
@kareltucek kareltucek merged commit 55a96f0 into master Jan 30, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants