File: Pointer.java

package info (click to toggle)
bbmap 38.90%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 21,520 kB
  • sloc: java: 265,882; sh: 14,954; python: 5,247; ansic: 2,074; perl: 96; xml: 38; makefile: 37
file content (38 lines) | stat: -rwxr-xr-x 818 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package align2;

public class Pointer implements Comparable<Pointer>{
	
	public static Pointer[] loadMatrix(int[][] matrix){
		Pointer[] out=new Pointer[matrix.length];
		for(int i=0; i<out.length; i++){
			int len=(matrix[i]==null ? 0 : matrix[i].length);
			out[i]=new Pointer(i, len);
		}
		return out;
	}
	
	public static Pointer[] loadMatrix(int[][] matrix, Pointer[] out){
		assert(out!=null);
		assert(out.length==matrix.length);
		for(int i=0; i<out.length; i++){
			Pointer p=out[i];
			int len=(matrix[i]==null ? 0 : matrix[i].length);
			p.key=i;
			p.value=len;
		}
		return out;
	}
	
	public Pointer(int key_, int value_){
		key=key_;
		value=value_;
	}
	
	@Override
	public int compareTo(Pointer o) {
		return value-o.value;
	}
	
	public int key;
	public int value;
}