Subversion Repositories programming

Rev

Rev 56 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 56 Rev 57
Line 43... Line 43...
43
    public int getSwapCount() { return swapCount; }
43
    public int getSwapCount() { return swapCount; }
44
    
44
    
45
    //reset compares and swaps
45
    //reset compares and swaps
46
    public void resetCompCount() { compCount = 0; }
46
    public void resetCompCount() { compCount = 0; }
47
    public void resetSwapCount() { swapCount = 0; }
47
    public void resetSwapCount() { swapCount = 0; }
-
 
48
    
-
 
49
    //increment the swapcount variable
-
 
50
    public static void incSwapCount() { swapCount++; }
-
 
51
    public static void incSwapCount( int increaseBy ) { swapCount += increaseBy; }
48
 
52
 
49
    //this is the only way a swap method can be made in java.
53
    //this is the only way a swap method can be made in java.
50
    //the usual C++ (and others) way of using pointers is not
54
    //the usual C++ (and others) way of using pointers is not
51
    //possible in java. (I've come up with a very solid
55
    //possible in java. (I've come up with a very solid
52
    //explanation of this. See me if you want to know.)
56
    //explanation of this. See me if you want to know.)
Line 106... Line 110...
106
        output.append("Number Compares");
110
        output.append("Number Compares");
107
        
111
        
108
        spaces = new StringBuffer();
112
        spaces = new StringBuffer();
109
        for( int i=output.length(); i<48; i++ ) { spaces.append(" "); }
113
        for( int i=output.length(); i<48; i++ ) { spaces.append(" "); }
110
        output.append(spaces);
114
        output.append(spaces);
111
        output.append("Number Swaps");
115
        output.append("Data Movements");
112
 
116
 
113
        return output.toString();
117
        return output.toString();
114
    }
118
    }
115
    
119
    
116
    //method to generate a properly spaced output line, which is used
120
    //method to generate a properly spaced output line, which is used