Questions tagged [stack]
A LIFO (Last In, First Out) data structure.
79 questions
- Bountied 0
- Unanswered
- Frequent
- Score
- Trending
- Week
- Month
- Unanswered (my tags)
3
votes
4
answers
2k
views
Iterating through stacks and queues?
Are stacks and queues allowed to be iterated over, conceptually?
It "feels wrong" for some reason but I can't come up with a reason why it would be bad to see through the whole thing that's stacked/...
2
votes
4
answers
871
views
Could a language allow for persistent allocations without heap?
Is it possible in theory to have a programming language that allows for object lifetimes that exist beyond the current scope but without using heap?
As a little background, in embedded development it ...
5
votes
4
answers
384
views
Use of globals in stack-based virtual machine implementation
I'm implementing a stack-based virtual machine in C.
The following variables are used by pretty much every function:
memory array
various pointers to memory offsets
program counter
stack
stack ...
0
votes
1
answer
173
views
Which scope should markers for a Stack Allocator fall under?
For reference, I am reading from "Game Engine Architecture 2nd Edition" by Jason Gregory.
Although I understand the theory behind Stack Allocators, I am having trouble implementing it fully. ...
-3
votes
4
answers
2k
views
C# Why should i limit myself to List or Stack ? ( instead of having both)
List is implemented in C# exactly as Stack, see:
https://docs.microsoft.com/en-us/dotnet/api/system.collections.generic.stack-1.push?view=netframework-4.8#remarks
https://docs.microsoft.com/en-us/...
24
votes
3
answers
4k
views
Are the Stack and Heap hardware, OS, or language-specific concepts?
In languages such as C or Java we have the concepts of the Stack and the Heap.
Are these abstractions the particular language runtime/compiler creates over the plain-old RAM? Or are these concepts ...
0
votes
3
answers
273
views
Resolving function calls as function arguments using a stack
After doing a bit of reading, I have a vague understanding of the use of a stack in calling functions when one function calls another, where the arguments are placed on the stack for the called ...
0
votes
4
answers
9k
views
Is it a good idea to use strings in a struct as values to static properties?
I'm in a discussion with a co-worker concerning the use of structs. I have a couple of structs that contain several static properties that are used throughout our website. The value of those ...
1
vote
2
answers
2k
views
Should I always allocate QObject and derived classes to the heap?
I was in #Qt irc channel, and I showed a small snippet of my code in a style that I heavily rely upon. It looks like this:
/* Get Reply from Server */
QPointer<QNetworkReply> reply;
{
...
0
votes
1
answer
3k
views
Registers and Stacks in NASM
So, I am more or less voluntarily learning NASM, and I have problems finding sources that really explain it. Unlike with Java or C# I can't just use google as well, since Assembly just isn't used by ...
0
votes
2
answers
225
views
How to Implement a `function` with `return` Without Using the `function` keyword
Along the lines of How to Simulate Control-Flow without using Control-Flow Primitives, I am wondering how to simulate return from a function.
Given an example setup like this:
console.log(a(10))
...
-3
votes
2
answers
11k
views
Why we use top== -1 for implementation of stack using simple array?
I am a newbie at data structures.
I have read an implementation of a stack using a simple array. The algorithm for this implementation is presented below.
Stack implementation in terms of an array
...
4
votes
1
answer
945
views
C++ Are members of a class pointer automatically on heap?
Let's say we have a struct Vector2i { int x = 0, int y = 0 };
And create a Pointer to it via Vector2i* pointer = new Vector2i;
Where would int x and int y be stored? Heap or stack?
Are all members ...
2
votes
3
answers
2k
views
How do Stack Machine store global vars?
How exactly do stack machines (both real and virtual stack machines) store global variables?
I know that C(++) just compile it to the .data segment of a program's memory segmentation.
Then there's ...
2
votes
2
answers
4k
views
Does Java copy method parameters to the stack frame of the called method?
This is part of the answer about stack and heap in Java:
So, why have the stack or the heap at all? For things that leave
scope, the stack can be expensive. Consider the code:
void foo(String arg)...