Skip to content

Conversation

@JaoodxD
Copy link

@JaoodxD JaoodxD commented Mar 14, 2023

Implement and introduce queue mentioned in #50

  • tests and linter show no problems (npm t)
  • tests are added/updated for bug fixes and new features
  • code is properly formatted (npm run fmt)
  • description of changes is added in CHANGELOG.md
  • update .d.ts typings

return this;
}

shift() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It may be better to use enqueue/dequeue methods and under the hood add elements with array.unshift, and remove elements with offset/slice. Need to check performance and compare

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This approach was to match current array methods (push/shift) to minimize refactoring, but I agree that enqueue/dequeue could be more convinient.

Copy link
Author

@JaoodxD JaoodxD Mar 30, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also here is test/queue-performance.js performance comparison test to compare queues of 100k elements. It shows ~25x execution time difference. This factor is growing with queue size e.g. ~800x at 500k elements.

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

Successfully merging this pull request may close these issues.

2 participants