rx-queue icon indicating copy to clipboard operation
rx-queue copied to clipboard

Windowed FiFo Queue

Open carlosdelfino opened this issue 6 years ago • 3 comments

I started to write a FIFO queue that works with a window concept, ie it has all the features of the common FIFO, however I can delimit a content perception window.

Entering data they will enter the QUEUE and exit according to the limit of the size allowed for it, but whenever you query an item in index 0 for example will return the first item that the window allows. if item 5 is requested, the fifth intem of the window will be returned.

The other option I am analyzing is that I can have a DataView, or WindowView, object that would view this FIFO as if it were an independent FIFO but actions on it only occur in the perception window.

Below is an image that speaks more than all this explanation. image Credit: https://www.cse.iitk.ac.in/users/dheeraj/cs425/lec09.html

thanks.

carlosdelfino avatar Mar 11 '18 03:03 carlosdelfino

Are you supposing a new Queue like WindowedQueue for your use case?

I have just read the link you provided but it seems that's a scenario of a Server/Client network protocol.

Could you please provide your scenario that needs this kind of Queue, to make it clear for me?

I would like to add it if you could prove it's a useful common feature.

Thanks again for your feature request!

huan avatar Mar 11 '18 09:03 huan

Thanks @zixia

A scenario would be for example the reading of a sensor that constantly sends update of graph of lines that is maintained comparing periods of time, thus I can move the graph so as to only display the desired window of time, this hisencia of data would be in an array , the WindownedQueue or WindownedView would display only the desired window of the array.

Today I do this with two arrays one keeps all the history and another is getting and I'm replacing the old data with the new ones using the Array.splice function, but it's very slow, because if I'm not mistaken it recreates an array every time which is called.

And each array in my case has between 1000 and 2000 items.

https://gist.github.com/carlosdelfino/25f41a053eed2859fd1a8fba7ce84f63

See in the gist the callback function, there is a small part of the code that updates a NativeScript ObservableArray.

Another example could be a line chart that displays real-time stock market counts every hour and can be compared to other time windows for decision making, and both would be updated in a synchronized fashion.

Yet another use would be for example a Google Analytics chart.

carlosdelfino avatar Mar 11 '18 23:03 carlosdelfino

I did not fully understand your scenario but it seems not like a RxQueue problem?

huan avatar Mar 12 '18 13:03 huan