Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Containers that enforce size limits

42 views
Skip to first unread message

Mut...@dastardlyhq.com

unread,
Mar 31, 2023, 5:26:06 AM3/31/23
to
I'm currently writing software that requires a deque that will reach a
max size and stay there so for example at the limit when I push something
on one end it automatically pops it off the other. Obviously this is simple
to accomplish with some boiler plate size check code, but does anyone know if
this sort of functionality has been mooted for upcoming STL versions?

Sam

unread,
Mar 31, 2023, 7:40:14 AM3/31/23
to
STL hasn't existed for decades. There's nothing of that sort in the current
version of the C++ library, and I haven't heard anything about anything of
that sort. I think it's unlikely.

Öö Tiib

unread,
Mar 31, 2023, 7:44:58 AM3/31/23
to
You mean C++ standard library? No. That seems quite unusual behaviour for
deque. It is unclear why you just do not wrap std::deque to adapter that
checks the size and does what you want?
Or maybe what you really need is circular buffer? There is circular_buffer class
in boost.

Malcolm McLean

unread,
Mar 31, 2023, 8:26:32 AM3/31/23
to
A deque can throw. On most systems with a bug free and reasonable program,
this is so unlikely that the possibility can be ignored.
If a dequeu has a maximum size, then data has to be discarded when the maximum
is reached. Whilst you can think of circumstances in which this is appropriate,
for example if you are injecting a stream of badddies into a video game, it's
too unusual and special purpose to be attractive for standardisation.

Paavo Helde

unread,
Mar 31, 2023, 8:51:06 AM3/31/23
to
Silently discarding data is not a behavior which should be present in a
standard container IMO.

There are also multiple variations about what and how such a thing could
behave, which are in my mind no worse, or less often needed:

- discarding not the first entry, but some other(s), depending on
condition
- throwing an exception
- waiting until another thread makes room in the queue
- yielding to a coroutine for making room in the queue
- ...



Mut...@dastardlyhq.com

unread,
Mar 31, 2023, 11:02:27 AM3/31/23
to
On Fri, 31 Mar 2023 07:39:59 -0400
Sam <s...@email-scan.com> wrote:
>Mut...@dastardlyhq.com writes:
>
>> I'm currently writing software that requires a deque that will reach a
>> max size and stay there so for example at the limit when I push something
>> on one end it automatically pops it off the other. Obviously this is simple
>> to accomplish with some boiler plate size check code, but does anyone know if
>
>> this sort of functionality has been mooted for upcoming STL versions?
>
>STL hasn't existed for decades.

I see pendant mode has been turned to 11 again today.

STL is shorthand for the containers in the standard library amongst a lot of
us.


Mut...@dastardlyhq.com

unread,
Mar 31, 2023, 11:04:41 AM3/31/23
to
On Fri, 31 Mar 2023 04:44:47 -0700 (PDT)
=?UTF-8?B?w5bDtiBUaWli?= <oot...@hot.ee> wrote:
>On Friday, 31 March 2023 at 12:26:06 UTC+3, Mut...@dastardlyhq.com wrote:
>> I'm currently writing software that requires a deque that will reach a
>> max size and stay there so for example at the limit when I push something
>> on one end it automatically pops it off the other. Obviously this is simple
>> to accomplish with some boiler plate size check code, but does anyone know
>if
>> this sort of functionality has been mooted for upcoming STL versions?
>
>You mean C++ standard library? No. That seems quite unusual behaviour for
>deque. It is unclear why you just do not wrap std::deque to adapter that
>checks the size and does what you want?

For the same reason I use C++ and not C and writing my own implementation of
a queue.

>Or maybe what you really need is circular buffer? There is circular_buffer
>class
>in boost.

Boost? Ugh. That abomination should crawl away and die in a corner, its time
has passed.

Mut...@dastardlyhq.com

unread,
Mar 31, 2023, 11:07:56 AM3/31/23
to
On Fri, 31 Mar 2023 15:50:49 +0300
Paavo Helde <ees...@osa.pri.ee> wrote:
>31.03.2023 12:25 Mut...@dastardlyhq.com kirjutas:
>> I'm currently writing software that requires a deque that will reach a
>> max size and stay there so for example at the limit when I push something
>> on one end it automatically pops it off the other. Obviously this is simple
>> to accomplish with some boiler plate size check code, but does anyone know if
>
>> this sort of functionality has been mooted for upcoming STL versions?
>
>Silently discarding data is not a behavior which should be present in a
>standard container IMO.

Depends on the type of container.

>There are also multiple variations about what and how such a thing could
>behave, which are in my mind no worse, or less often needed:
>
> - discarding not the first entry, but some other(s), depending on
>condition
> - throwing an exception
> - waiting until another thread makes room in the queue
> - yielding to a coroutine for making room in the queue
> - ...

Or in my case, a message queue in which messages cease to be valid after X
messages have followed them so if they haven't been read by then they can be
binned.

Christian Gollwitzer

unread,
Mar 31, 2023, 1:20:58 PM3/31/23
to
Am 31.03.23 um 17:04 schrieb Mut...@dastardlyhq.com:
Regardless of Boost, I think what you describe is a circular buffer
(also called ring buffer). It can be implemented efficiently with a
fixed-size array and two pointers. You can certainly find other
implementations besides Boost.

Christian


Bonita Montero

unread,
Mar 31, 2023, 1:58:37 PM3/31/23
to
A size-limited deque<> doens't make sense.

Mut...@dastardlyhq.com

unread,
Apr 1, 2023, 6:29:10 AM4/1/23
to
Yes, you're right, they are functionally equivalent. I should have spotted
that.


Tony Mike

unread,
Oct 3, 2023, 9:58:47 PM10/3/23
to
<a href="https://megatechammunution.com/" rel="dofollow">megatechammunution.com</a>
<a href="https://megatechammunution.com/index.php/product/trail-boss-powder/" rel="dofollow">trail boss powder</a>
<a href="https://megatechammunution.com/index.php/product/vortex-crossfire-reddot/" rel="dofollow">vortex crossfire reddot</a>
<a href="https://megatechammunution.com/index.php/product/leupold-deltapoint-pro/" rel="dofollow">leupold deltapoint pro</a>
<a href="https://megatechammunution.com/index.php/product/eotech-magnifier/" rel="dofollow">eotech magnifier</a>
<a href="https://megatechammunution.com/index.php/product/labradar/" rel="dofollow">labrader</a>
<a href="https://megatechammunution.com/index.php/product/apex-trigger/" rel="dofollow">apex trigger</a>
<a href="https://megatechammunution.com/index.php/product/swagger-bipods/" rel="dofollow">swagger bipods</a>
<a href="https://megatechammunution.com/index.php/product/timney-trigger/" rel="dofollow">timney trigger</a>
<a href="https://megatechammunution.com/index.php/product/para-15-trigger/" rel="dofollow">para-15 trigger</a>
<a href="https://megatechammunution.com/index.php/product/alamo-15-trigger" rel="dofollow">alamo 15 trigger</a>
<a href="https://megatechammunution.com/index.php/product/geissele-trigger/" rel="dofollow">geissele trigger</a>
<a href="https://megatechammunution.com/index.php/product/cmc-triggers/" rel="dofollow">cmc triggers</a>
<a href="https://megatechammunution.com/index.php/product/binary-trigger/" rel="dofollow">binary trigger</a>
<a href="https://megatechammunution.com/index.php/product/wot-trigger/" rel="dofollow">wot trigger</a>
<a href="https://megatechammunution.com/index.php/product/holosun-507k/" rel="dofollow">holosun 507k</a>

https://alphaspirituality.com
https://alphaspirituality.com/product/purple-mdma/
https://alphaspirituality.com/product/rybelsus-weight-loss/
https://alphaspirituality.com/product/buy-ozempic-online/
https://alphaspirituality.com/product/buy-wegovy-online/
https://alphaspirituality.com/product/percocet-30s/
https://alphaspirituality.com/product/adderall-uk
https://alphaspirituality.com/product/ketamine-for-anxiety/
https://alphaspirituality.com/product/pregabalin-bnf/
https://alphaspirituality.com/product/mifegest-buy-online/
https://alphaspirituality.com/product/lions-mane-mushrooms-near/
https://alphaspirituality.com/product/lions-mane-uk/
https://alphaspirituality.com/product/buy-mifepristone/
https://alphaspirituality.com/product/dihydrocodeine-30mg/
https://alphaspirituality.com/product/cytotec-uk
https://alphaspirituality.com/product/mdma-buy/
https://alphaspirituality.com/product/blue-tesla-pills/
https://alphaspirituality.com/product/mdma-buying/
https://alphaspirituality.com/product/mdma-for-depression-treatment/
https://alphaspirituality.com/product/enoki-mushrooms/
https://alphaspirituality.com/product/dmt-vape-pen/
https://alphaspirituality.com/product/dmt-cart/
https://alphaspirituality.com/product/buying-mdma-online/
https://alphaspirituality.com/product/mdma-dose/
https://alphaspirituality.com/product/molly-drug/
https://alphaspirituality.com/product/pure-mdma/
https://alphaspirituality.com/product/psilocybe-cubensis-dried/
https://alphaspirituality.com/product/malabar-coast-mushrooms/
https://alphaspirituality.com/product/blue-meanies-mushroom/
https://alphaspirituality.com/product/amazonian-mushrooms/
https://alphaspirituality.com/product/magic-mushrooms-for-sale/
https://alphaspirituality.com/product/golden-teacher-mushrooms/
https://alphaspirituality.com/product/dried-shiitake-mushrooms/
https://alphaspirituality.com/product/magic-mushroom-spores/
https://alphaspirituality.com/product/psilocybin-mushroom-spores/
https://alphaspirituality.com/product/morel-mushroom-spores/
https://alphaspirituality.com/product/mushroom-spores/
https://alphaspirituality.com/product/b-mushrooms/
https://alphaspirituality.com/product/1p-lsd/
https://alphaspirituality.com/product/buy-lsd/
https://alphaspirituality.com/product/where-to-buy-lsd/
https://alphaspirituality.com/product/lsd-25/
https://alphaspirituality.com/product/lsd-for-sale/
https://alphaspirituality.com/product/lsd-tabs/
https://alphaspirituality.com/product/ecstacy-pills/
https://alphaspirituality.com/product/buy-dmt/
https://alphaspirituality.com/product/4-aco-dmt/
https://alphaspirituality.com/product/kratom-near-me/
<a href="https://megatechammunution.com/index.php/product/mantis-blackbeard/" rel="dofollow">mantis blackbeard</a>
<a href="https://megatechammunution.com/index.php/product/surefire-warden/" rel="dofollow">surefire warden</a>
<a href="https://megatechammunution.com/index.php/product/atlas-bipod/" rel="dofollow">atlas bipod</a>
<a href="https://megatechammunution.com/index.php/product/glock-43-slide/" rel="dofollow">glock 43 slide</a>
<a href="https://megatechammunution.com/index.php/product/glock-19-barrel/" rel="dofollow">glock 19 barrel</a>
<a href="https://megatechammunution.com/index.php/product/holosun-508t/" rel="dofollow">holosun 508t</a>
<a href="https://megatechammunution.com/index.php/product/eotech-vudu/" rel="dofollow">eotech vudu</a>
<a href="https://megatechammunution.com/index.php/product/federal-speed-shok/" rel="dofollow">federal speed shok</a>
<a href="https://megatechammunution.com/index.php/product/sig-romeo-zero/" rel="dofollow">sig romeo zero</a>
<a href="https://megatechammunution.com/index.php/product/50-ae-ammo/" rel="dofollow">50 ae ammo</a>
<a href="https://megatechammunution.com/index.php/product/american-eagle-ammo/" rel="dofollow">american eagle ammo</a>
<a href="https://megatechammunution.com/index.php/product/remington-870-barrel/" rel="dofollow">remington 870 barrel</a>
<a href="https://megatechammunution.com/index.php/product/270-wsm-ammo/" rel="dofollow">270 wsm ammo</a>
<a href="https://megatechammunution.com/index.php/product/blackhawk-compstock/" rel="dofollow">blackhawk compstock</a>
<a href="https://megatechammunution.com/index.php/product/modlite/" rel="dofollow">modlite</a>
0 new messages