1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
package com.stevesoft.pat; |
9 |
|
|
10 |
|
import java.util.Hashtable; |
11 |
|
|
12 |
|
|
|
|
| 0% |
Uncovered Elements: 40 (40) |
Complexity: 10 |
Complexity Density: 0.4 |
|
13 |
|
class OrMark extends Or |
14 |
|
{ |
15 |
|
SubMark sm = new SubMark(); |
16 |
|
|
17 |
|
int id; |
18 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
19 |
0 |
OrMark(int i)... |
20 |
|
{ |
21 |
0 |
sm.om = this; |
22 |
0 |
id = i; |
23 |
|
} |
24 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
25 |
0 |
String leftForm()... |
26 |
|
{ |
27 |
0 |
return "("; |
28 |
|
} |
29 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
30 |
0 |
public Pattern getNext()... |
31 |
|
{ |
32 |
0 |
return sm; |
33 |
|
} |
34 |
|
|
|
|
| 0% |
Uncovered Elements: 23 (23) |
Complexity: 5 |
Complexity Density: 0.33 |
|
35 |
0 |
public int matchInternal(int pos, Pthings pt)... |
36 |
|
{ |
37 |
0 |
sm.next = super.getNext(); |
38 |
0 |
if (pt.marks == null) |
39 |
|
{ |
40 |
0 |
int n2 = 2 * pt.nMarks + 2; |
41 |
0 |
pt.marks = new int[n2]; |
42 |
0 |
for (int i = 0; i < n2; i++) |
43 |
|
{ |
44 |
0 |
pt.marks[i] = -1; |
45 |
|
} |
46 |
|
} |
47 |
0 |
pt.marks[id] = pos; |
48 |
0 |
int ret = super.matchInternal(pos, pt); |
49 |
0 |
if (ret < 0) |
50 |
|
{ |
51 |
0 |
pt.marks[id] = -1; |
52 |
|
} |
53 |
0 |
else if (pt.marks[id] > pt.marks[id + pt.nMarks]) |
54 |
|
{ |
55 |
0 |
int swap = pt.marks[id]; |
56 |
0 |
pt.marks[id] = pt.marks[id + pt.nMarks] + 1; |
57 |
0 |
pt.marks[id + pt.nMarks] = swap + 1; |
58 |
|
} |
59 |
0 |
return ret; |
60 |
|
} |
61 |
|
|
|
|
| 0% |
Uncovered Elements: 8 (8) |
Complexity: 2 |
Complexity Density: 0.33 |
|
62 |
0 |
public Pattern clone1(Hashtable h)... |
63 |
|
{ |
64 |
0 |
OrMark om = new OrMark(id); |
65 |
0 |
h.put(om, om); |
66 |
0 |
h.put(this, om); |
67 |
0 |
for (int i = 0; i < v.size(); i++) |
68 |
|
{ |
69 |
0 |
om.v.addElement(((Pattern) v.elementAt(i)).clone(h)); |
70 |
|
} |
71 |
0 |
return om; |
72 |
|
} |
73 |
|
}; |