-4

I'm working on a code in C++ but i'm not sure what a[set][i]++; does. I was assuming that the value located in that array was incremented by 1, but i'm not sure.
Also, what's the function of assert(0); in the code? Thank for your help!

The code block is:

for (i=0; i<1S; i++)
{
   if (a[637][i] < a[637][15]) 
       {
          a[637][i]++;
          if (a[637][i] == 15)
             assert(0);
       }
    }
a[637][15] = 0; 

Edit: Sorry i forgot to mention the background.
The definition of a is uint32_t a[2048][16];so 637 and i are values from a particular loop in order to compare them with another 2D array and then choose which line to evict. This is for a cache replacement policy but i just was curious for those cases. Thanks!

1 Answers1

0

Statement a[637][i]++ increases the value of the cell 637/i of two-dimensional array a.

assert(0) simply aborts program execution at this point (since condition 0 means false, defining that the assertion is never met). Confer this SO answer for a more detailed explanation.

Community
  • 1
  • 1
Stephan Lechner
  • 34,891
  • 4
  • 35
  • 58