C++ vector, what does this code mean?

前端 未结 6 1177
谎友^
谎友^ 2021-01-23 22:27

I have this code:

 const int maxnodes = 5000;
 struct Edge 
 {
   int to, rev;
   int f, cap;
 };

 vector g[maxnodes];

This is qui

6条回答
  •  死守一世寂寞
    2021-01-23 23:00

    I believe others have already explained what each line does well. I'm just pointing out that in the second line,

    Edge &e = g[u][j];
    

    the code places the Edge at g[u][j] in a reference, presumably, to make the following code easier to both read and write (instead of repeating g[u][j] multiple times).

提交回复
热议问题