p1_utils icon indicating copy to clipboard operation
p1_utils copied to clipboard

Request : Add last() to p1_queue

Open grizzly-monkey opened this issue 7 years ago • 6 comments

Can we please add functionality to get last element from queue()

Thanks Jeet

grizzly-monkey avatar Apr 20 '17 14:04 grizzly-monkey

Only if we can make the operation O(1), which is doubtful without changing file queue format.

zinid avatar Apr 20 '17 14:04 zinid

what is current file queue format why will it not be done in o(1) can we not peek to the last entry ?

grizzly-monkey avatar Apr 21 '17 07:04 grizzly-monkey

The current format is:

<<Size:32, BinaryTerm:Size/binary, ...>>

So, obviously, we can only peek in O(N) to the last element. In order to peek in O(1), we need to have something like:

<<Size:32, BinaryTerm:Size/binary, Size:32, ...>>

zinid avatar Apr 21 '17 07:04 zinid

Thanks for the clarity @zinid for now i am using ram queues so without changing p1_q i am managing last in my module. However if we can get this change in p1_q it would be awesome i am not sure how big this change format is for file queue but if we can get this it will be really great .

grizzly-monkey avatar Apr 21 '17 07:04 grizzly-monkey

OK, I will try to look at it ASAP.

zinid avatar Apr 21 '17 07:04 zinid

Thank you Sir.

grizzly-monkey avatar Apr 21 '17 07:04 grizzly-monkey