Comments (5)
Something like a BST, with an in-order traversal?
from ext-ds.
You could easily create something like this around a PriorityQueue, can't you? You can use an internal Sequence as a buffer.
from ext-ds.
Just coming back to this to clarify what I meant by using a sequence as a buffer. You can pop all the items in the queue into a sequence (tuple would be better in 2.0) as you process (for example emit events), then push them all back into the priority queue.
Would be best to push them back in from highest to lowest priority to reduce the number of swaps that the priority would need to do.
from ext-ds.
@rtheunissen It might make sense to allow constructing the PQ from an array. You can construct a heap in O(n) time, while pushing into a heap element-wise is O(n log n).
from ext-ds.
@nikic What would the structure of the array be? Pairs of value/priority? It also just occurred to me that in order for the intermediary to work we'd have to pop the priority along with the value, as the priority it was inserted with might not be known at the time.
A better strucuture for the suggested use case might just be a sequence then, that you sort in O(n log n) after registering the events, or insert into using a binary search, which I think would be an O(log n) insert but the buffer unshift would make it a worst case O(n log n).
🤔
from ext-ds.
Related Issues (20)
- Segmentation fault when Map is used with IteratorIterator (v1.3.0) HOT 3
- Testing for Equality HOT 4
- . HOT 1
- map method for Set? HOT 3
- PHP 8.1 compatibility HOT 5
- How to make sure extension is used HOT 5
- How to install in PHP8 Docker alpine:version image? HOT 8
- Support php 7.4's `__unserialize` to prepare for PHP 9.0 removing Serializable
- Release supporting PHP 8.1 HOT 11
- Audit and update documentation HOT 1
- ReflectionClass and ReflectionObject not reporting information when using Ds\Map via extension
- Passing array item by reference breaks \DS\Set behaviour HOT 1
- php_ds.dll for PHP 8.2.x on Windows HOT 2
- Pecl install missing php 8.2 HOT 3
- Better Interface Segregation (Future Version?) HOT 3
- Clarify Support for PHP 8.3.x and 9.x? HOT 11
- Segmentation fault merging keys of maps containing maps HOT 7
- DLL missing on PECL for 1.5.0 HOT 3
- Upgrade PECL page to identify homepage HOT 2
- Null coalescing operator on Vector make search failed HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ext-ds.