Rewrite function in java-8 style -


i implement next task in 1 stream, without loop in code:

public list<integer> findsumforeachnode() {     list<integer> result = new arraylist<>();     (int ind = 0; ind < nodenum; ind++) {         result.add(stream                 .concat(getneighbors(ind).stream(), getinneighbors(ind).stream())                 .collect(summingint(integer::intvalue)));     }     return result; } 

what going on: each node take neighbours (list) , inneighbours(list), find sum , add result in result list.

intstream.range(0, nodenum)   .maptoobj(ind ->       stream.concat(            getneighbors(ind).stream(), getinneighbors(ind).stream())       .collect(summingint(integer::intvalue)))   .collect(tolist()); 

Comments

Popular posts from this blog

how to insert data php javascript mysql with multiple array session 2 -

multithreading - Exception in Application constructor -

windows - CertCreateCertificateContext returns CRYPT_E_ASN1_BADTAG / 8009310b -