Is there any approach to setInvalid the whole header stack?

Hello, I wonder if I can setInvalid a header stack without explicitly applying setInvalid() one every element in that header stack?
For example, if I want to set invalid my_header_stack, for now I can only try hdr.my_header_stack[0].setInvalid();
hdr.my_header_stack[1].setInvalid();
...
and I wonder if there is an easier and prettier approach to setInavlid the whole stack?

Hi, welcome to the group

Since stacks are of fixed size (size_num), you could use pop_front(int count):

hdr.my_stack.pop_front(size_num);

From the test I made you should see no stack headers deparsed. Strictly speaking, I am not sure if this method sets the whole stack as invalid or it just does not deparse any header because it is empty (which could mean the same thing, now that I think about it :thinking:). According to the spec I believe it might, but not sure:

hs.pop_front(int count): shifts hs “left” by count (i.e., element with index count is copied in stack at index 0). The last count elements become invalid. The hs.nextIndex counter is decremented by count. The count argument must be a positive integer that is a compile-time known value. The return type is void.

In any case, I believe this method should achieve what you expect, and it should work for you.

Cheers,

It works well for me too! Thanks a lot!