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

Rolling link list

26 views
Skip to first unread message

Rick C. Hodgin

unread,
Oct 4, 2019, 8:08:15 AM10/4/19
to
I'm not sure what to call it, but I'll try this:

Is there a rolling link list class? Or something where a maximum
of N elements will exist in the link list, so that each time you do
a push_back(), it adds a new element such that if N+1 elements exist
in the list, the oldest one added gets deleted?

It would work like how tank treads strike the ground. Only so many
are ever touching the ground at any one time. As one comes down,
one goes up. As the next one comes down, the one that was previously
in the lead is now second. As the third comes down ... and so on.
Once the N count is reached, the oldest ones are pushed off the list
and would simply be deleted.

I'm looking for a way navigate through a sequential data set using
a fixed-size window of visibility, such that items beyond a certain
range are no longer of any interest and can fall off the list. Kind
of like having a console window with content shown on the screen for
a fixed size, but without a scroll-back buffer.

--
Rick C. Hodgin

Mr Flibble

unread,
Oct 4, 2019, 5:26:33 PM10/4/19
to
And Satan invented fossils, yes?

/Flibble

--
"Snakes didn't evolve, instead talking snakes with legs changed into
snakes." - Rick C. Hodgin

“You won’t burn in hell. But be nice anyway.” – Ricky Gervais

“I see Atheists are fighting and killing each other again, over who
doesn’t believe in any God the most. Oh, no..wait.. that never happens.” –
Ricky Gervais

"Suppose it's all true, and you walk up to the pearly gates, and are
confronted by God," Bryne asked on his show The Meaning of Life. "What
will Stephen Fry say to him, her, or it?"
"I'd say, bone cancer in children? What's that about?" Fry replied.
"How dare you? How dare you create a world to which there is such misery
that is not our fault. It's not right, it's utterly, utterly evil."
"Why should I respect a capricious, mean-minded, stupid God who creates a
world that is so full of injustice and pain. That's what I would say."

Jorgen Grahn

unread,
Oct 5, 2019, 2:39:19 AM10/5/19
to
I didn't read carefully, but isn't that a circular buffer?

- Maybe Boost has something.
- You could wrap std::list or std::deque lightly.
- You could wrap std::array if you're after the efficiency aspects
of a circular buffer.

/Jorgen

--
// Jorgen Grahn <grahn@ Oo o. . .
\X/ snipabacken.se> O o .

Rick C. Hodgin

unread,
Oct 5, 2019, 10:35:57 AM10/5/19
to
On 10/5/2019 2:39 AM, Jorgen Grahn wrote:
> I didn't read carefully, but isn't that a circular buffer?
>
> - Maybe Boost has something.
> - You could wrap std::list or std::deque lightly.
> - You could wrap std::array if you're after the efficiency aspects
> of a circular buffer.

Kind of. With a linked list you could insert nodes in the middle,
but if they're all just push_back() then it is.

I was just wondering if something template / stock already existed.

--
Rick C. Hodgin
0 new messages