Last change
on this file since 1570 was
1568,
checked in by rkrimmel, 10 years ago
|
Building distance matrix between sequences
|
File size:
1.2 KB
|
Rev | Line | |
---|
[1553] | 1 | package de.ugoe.cs.autoquest.tasktrees.alignment.algorithms; |
---|
[1450] | 2 | |
---|
[1542] | 3 | import java.io.Serializable; |
---|
[1450] | 4 | import java.util.ArrayList; |
---|
[1568] | 5 | import java.util.Random; |
---|
[1450] | 6 | |
---|
[1542] | 7 | public class NumberSequence implements Serializable { |
---|
[1450] | 8 | private int[] sequence; |
---|
| 9 | private int signature; |
---|
| 10 | |
---|
| 11 | public NumberSequence(int size) { |
---|
| 12 | |
---|
| 13 | sequence = new int[size]; |
---|
| 14 | } |
---|
| 15 | |
---|
| 16 | public int[] getSequence() { |
---|
| 17 | return sequence; |
---|
| 18 | } |
---|
| 19 | public void setSequence(int[] sequence) { |
---|
| 20 | this.sequence = sequence; |
---|
| 21 | } |
---|
| 22 | public int getSignature() { |
---|
| 23 | return signature; |
---|
| 24 | } |
---|
| 25 | public void setSignature(int signature) { |
---|
| 26 | this.signature = signature; |
---|
| 27 | } |
---|
[1558] | 28 | |
---|
| 29 | public void printSequence() |
---|
| 30 | { |
---|
| 31 | for (int i = 0; i < sequence.length; i++) { |
---|
[1559] | 32 | System.out.format("%5d", sequence[i]); |
---|
[1558] | 33 | } |
---|
| 34 | System.out.println(); |
---|
| 35 | } |
---|
[1568] | 36 | |
---|
| 37 | public NumberSequence shuffle(){ |
---|
| 38 | NumberSequence result = new NumberSequence(sequence.length); |
---|
| 39 | result.setSequence(this.sequence); |
---|
| 40 | Random rgen = new Random(); |
---|
| 41 | |
---|
| 42 | for (int i=0; i<result.sequence.length; i++) { |
---|
| 43 | int randomPosition = rgen.nextInt(result.sequence.length); |
---|
| 44 | int temp = result.sequence[i]; |
---|
| 45 | result.sequence[i] = result.sequence[randomPosition]; |
---|
| 46 | result.sequence[randomPosition] = temp; |
---|
| 47 | } |
---|
| 48 | return result; |
---|
| 49 | |
---|
| 50 | } |
---|
[1450] | 51 | |
---|
| 52 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.