Clover icon

jalviewX

  1. Project Clover database Wed Oct 31 2018 15:13:58 GMT
  2. Package mc_view

File Zsort.java

 

Coverage histogram

../img/srcFileCovDistChart0.png
56% of files have more coverage

Code metrics

8
20
3
1
80
47
9
0.45
6.67
3
3

Classes

Class Line # Actions
Zsort 25 20 9 31
0.00%
 

Contributing tests

No tests hitting this source file were found.

Source view

1    /*
2    * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3    * Copyright (C) $$Year-Rel$$ The Jalview Authors
4    *
5    * This file is part of Jalview.
6    *
7    * Jalview is free software: you can redistribute it and/or
8    * modify it under the terms of the GNU General Public License
9    * as published by the Free Software Foundation, either version 3
10    * of the License, or (at your option) any later version.
11    *
12    * Jalview is distributed in the hope that it will be useful, but
13    * WITHOUT ANY WARRANTY; without even the implied warranty
14    * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15    * PURPOSE. See the GNU General Public License for more details.
16    *
17    * You should have received a copy of the GNU General Public License
18    * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
19    * The Jalview Authors are detailed in the 'AUTHORS' file.
20    */
21    package mc_view;
22   
23    import java.util.Vector;
24   
 
25    public class Zsort
26    {
27    /**
28    * Sorts the Bond list in ascending order of the z-value of the bond start
29    * atom
30    *
31    * @param bonds
32    */
 
33  0 toggle public void sort(Vector<Bond> bonds)
34    {
35  0 sort(bonds, 0, bonds.size() - 1);
36    }
37   
 
38  0 toggle public void sort(Vector<Bond> bonds, int p, int r)
39    {
40  0 int q;
41   
42  0 if (p < r)
43    {
44  0 q = partition(bonds, p, r);
45  0 sort(bonds, p, q);
46  0 sort(bonds, q + 1, r);
47    }
48    }
49   
 
50  0 toggle private int partition(Vector<Bond> bonds, int p, int r)
51    {
52  0 float x = bonds.elementAt(p).start[2];
53  0 int i = p - 1;
54  0 int j = r + 1;
55  0 Bond tmp;
56  0 while (true)
57    {
58  0 do
59    {
60  0 j--;
61  0 } while ((j >= 0) && (bonds.elementAt(j).start[2] > x));
62   
63  0 do
64    {
65  0 i++;
66  0 } while ((i < bonds.size()) && (bonds.elementAt(i).start[2] < x));
67   
68  0 if (i < j)
69    {
70  0 tmp = bonds.elementAt(i);
71  0 bonds.setElementAt(bonds.elementAt(j), i);
72  0 bonds.setElementAt(tmp, j);
73    }
74    else
75    {
76  0 return j;
77    }
78    }
79    }
80    }