So I have a loop that goes something like
for (r = 0; r < k; r++) {
pair p = {r, D[r]};
queue.push(p);
}
where pair is defined as
struct pair {
int u;
float d;
}
Is this a legal way to create k pairs and push them onto a priority queue? Do the pairs still exist on the queue in their original form even though p gets overwritten each time? Or does each pair that's already on the queue get automatically updated to the new value of p, resulting in a queue full of identical copies of the same pair?
Thanks!