View Javadoc
1   package civitas.result;
2   
3   import org.springframework.stereotype.Controller;
4   
5   @Controller
6   public class InitialMatrix {
7   
8   	CandidatePair[][] apply(final Integer[][] m, final Integer n) {
9   		@SuppressWarnings("unchecked")
10  		CandidatePair[][] r = new CandidatePair[n][n];
11  		for (int i = 0; i < n; i++) {
12  			for (int j = 0; j < n; j++) {
13  				Integer x = m[i][j];
14  				Integer y = m[j][i];
15  				if (x == y) {
16  					r[i][j] = new CandidatePair(0, 0);
17  				} else if (x > y) {
18  					r[i][j] = new CandidatePair(x, y);
19  					r[j][i] = new CandidatePair(0, 0);
20  				} else {
21  					r[i][j] = new CandidatePair(0, 0);
22  					r[j][i] = new CandidatePair(y, x);
23  				}
24  			}
25  		}
26  		return r;
27  	}
28  }