Skip to content
Permalink
Browse files

slightly changed the Java code formatting rules

- the Eclipse formatter/cleanup rules are attached in /eclipse/
- use 'git diff -w' to ignore whitespace changes of this commit
  • Loading branch information...
Benedikt Waldvogel
Benedikt Waldvogel committed Jul 10, 2009
1 parent fe3cfc2 commit e859a30212a0a0c9e8d88fa88eae9e64e08f5d73
@@ -0,0 +1,55 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<profiles version="2">
<profile kind="CleanUpProfile" name="Liblinear Clean Up Conventions" version="1">
<setting id="cleanup.remove_unused_private_fields" value="true"/>
<setting id="cleanup.always_use_parentheses_in_expressions" value="false"/>
<setting id="cleanup.never_use_blocks" value="false"/>
<setting id="cleanup.remove_unused_private_methods" value="true"/>
<setting id="cleanup.add_missing_deprecated_annotations" value="true"/>
<setting id="cleanup.convert_to_enhanced_for_loop" value="false"/>
<setting id="cleanup.remove_unnecessary_nls_tags" value="true"/>
<setting id="cleanup.sort_members" value="false"/>
<setting id="cleanup.remove_unused_local_variables" value="false"/>
<setting id="cleanup.never_use_parentheses_in_expressions" value="true"/>
<setting id="cleanup.remove_unused_private_members" value="false"/>
<setting id="cleanup.remove_unnecessary_casts" value="true"/>
<setting id="cleanup.make_parameters_final" value="false"/>
<setting id="cleanup.use_this_for_non_static_field_access" value="false"/>
<setting id="cleanup.remove_private_constructors" value="true"/>
<setting id="cleanup.use_blocks" value="true"/>
<setting id="cleanup.always_use_this_for_non_static_method_access" value="false"/>
<setting id="cleanup.remove_trailing_whitespaces_all" value="false"/>
<setting id="cleanup.always_use_this_for_non_static_field_access" value="false"/>
<setting id="cleanup.use_this_for_non_static_field_access_only_if_necessary" value="true"/>
<setting id="cleanup.add_default_serial_version_id" value="true"/>
<setting id="cleanup.make_type_abstract_if_missing_method" value="false"/>
<setting id="cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class" value="true"/>
<setting id="cleanup.make_variable_declarations_final" value="false"/>
<setting id="cleanup.add_missing_nls_tags" value="false"/>
<setting id="cleanup.format_source_code" value="true"/>
<setting id="cleanup.qualify_static_method_accesses_with_declaring_class" value="false"/>
<setting id="cleanup.add_missing_override_annotations" value="true"/>
<setting id="cleanup.remove_unused_private_types" value="true"/>
<setting id="cleanup.add_missing_methods" value="false"/>
<setting id="cleanup.make_local_variable_final" value="true"/>
<setting id="cleanup.correct_indentation" value="false"/>
<setting id="cleanup.remove_unused_imports" value="true"/>
<setting id="cleanup.remove_trailing_whitespaces_ignore_empty" value="true"/>
<setting id="cleanup.make_private_fields_final" value="true"/>
<setting id="cleanup.add_generated_serial_version_id" value="false"/>
<setting id="cleanup.organize_imports" value="true"/>
<setting id="cleanup.remove_trailing_whitespaces" value="false"/>
<setting id="cleanup.sort_members_all" value="false"/>
<setting id="cleanup.use_blocks_only_for_return_and_throw" value="true"/>
<setting id="cleanup.add_missing_annotations" value="true"/>
<setting id="cleanup.use_parentheses_in_expressions" value="false"/>
<setting id="cleanup.qualify_static_field_accesses_with_declaring_class" value="false"/>
<setting id="cleanup.use_this_for_non_static_method_access_only_if_necessary" value="true"/>
<setting id="cleanup.use_this_for_non_static_method_access" value="false"/>
<setting id="cleanup.qualify_static_member_accesses_through_instances_with_declaring_class" value="true"/>
<setting id="cleanup.add_serial_version_id" value="false"/>
<setting id="cleanup.format_source_code_changes_only" value="false"/>
<setting id="cleanup.qualify_static_member_accesses_with_declaring_class" value="true"/>
<setting id="cleanup.always_use_blocks" value="false"/>
</profile>
</profiles>

Large diffs are not rendered by default.

Oops, something went wrong.
@@ -3,89 +3,89 @@

final class ArraySorter {

/**
* <p>Sorts the specified array of doubles into <b>descending</b> order.</p>
*
* <em>This code is borrowed from Sun's JDK 1.6.0.07</em>
*/
public static void reversedMergesort( double[] a ) {
reversedMergesort(a, 0, a.length);
}
/**
* <p>Sorts the specified array of doubles into <b>descending</b> order.</p>
*
* <em>This code is borrowed from Sun's JDK 1.6.0.07</em>
*/
public static void reversedMergesort(double[] a) {
reversedMergesort(a, 0, a.length);
}

private static void reversedMergesort( double x[], int off, int len ) {
// Insertion sort on smallest arrays
if ( len < 7 ) {
for ( int i = off; i < len + off; i++ )
for ( int j = i; j > off && x[j - 1] < x[j]; j-- )
swap(x, j, j - 1);
return;
}
private static void reversedMergesort(double x[], int off, int len) {
// Insertion sort on smallest arrays
if (len < 7) {
for (int i = off; i < len + off; i++)
for (int j = i; j > off && x[j - 1] < x[j]; j--)
swap(x, j, j - 1);
return;
}

// Choose a partition element, v
int m = off + (len >> 1); // Small arrays, middle element
if ( len > 7 ) {
int l = off;
int n = off + len - 1;
if ( len > 40 ) { // Big arrays, pseudomedian of 9
int s = len / 8;
l = med3(x, l, l + s, l + 2 * s);
m = med3(x, m - s, m, m + s);
n = med3(x, n - 2 * s, n - s, n);
}
m = med3(x, l, m, n); // Mid-size, med of 3
}
double v = x[m];
// Choose a partition element, v
int m = off + (len >> 1); // Small arrays, middle element
if (len > 7) {
int l = off;
int n = off + len - 1;
if (len > 40) { // Big arrays, pseudomedian of 9
int s = len / 8;
l = med3(x, l, l + s, l + 2 * s);
m = med3(x, m - s, m, m + s);
n = med3(x, n - 2 * s, n - s, n);
}
m = med3(x, l, m, n); // Mid-size, med of 3
}
double v = x[m];

// Establish Invariant: v* (<v)* (>v)* v*
int a = off, b = a, c = off + len - 1, d = c;
while ( true ) {
while ( b <= c && x[b] >= v ) {
if ( x[b] == v ) swap(x, a++, b);
b++;
}
while ( c >= b && x[c] <= v ) {
if ( x[c] == v ) swap(x, c, d--);
c--;
}
if ( b > c ) break;
swap(x, b++, c--);
}
// Establish Invariant: v* (<v)* (>v)* v*
int a = off, b = a, c = off + len - 1, d = c;
while (true) {
while (b <= c && x[b] >= v) {
if (x[b] == v) swap(x, a++, b);
b++;
}
while (c >= b && x[c] <= v) {
if (x[c] == v) swap(x, c, d--);
c--;
}
if (b > c) break;
swap(x, b++, c--);
}

// Swap partition elements back to middle
int s, n = off + len;
s = Math.min(a - off, b - a);
vecswap(x, off, b - s, s);
s = Math.min(d - c, n - d - 1);
vecswap(x, b, n - s, s);
// Swap partition elements back to middle
int s, n = off + len;
s = Math.min(a - off, b - a);
vecswap(x, off, b - s, s);
s = Math.min(d - c, n - d - 1);
vecswap(x, b, n - s, s);

// Recursively sort non-partition-elements
if ( (s = b - a) > 1 ) reversedMergesort(x, off, s);
if ( (s = d - c) > 1 ) reversedMergesort(x, n - s, s);
}
// Recursively sort non-partition-elements
if ((s = b - a) > 1) reversedMergesort(x, off, s);
if ((s = d - c) > 1) reversedMergesort(x, n - s, s);
}

/**
* Swaps x[a] with x[b].
*/
private static void swap( double x[], int a, int b ) {
double t = x[a];
x[a] = x[b];
x[b] = t;
}
/**
* Swaps x[a] with x[b].
*/
private static void swap(double x[], int a, int b) {
double t = x[a];
x[a] = x[b];
x[b] = t;
}

/**
* Swaps x[a .. (a+n-1)] with x[b .. (b+n-1)].
*/
private static void vecswap( double x[], int a, int b, int n ) {
for ( int i = 0; i < n; i++, a++, b++ )
swap(x, a, b);
}
/**
* Swaps x[a .. (a+n-1)] with x[b .. (b+n-1)].
*/
private static void vecswap(double x[], int a, int b, int n) {
for (int i = 0; i < n; i++, a++, b++)
swap(x, a, b);
}

/**
* Returns the index of the median of the three indexed doubles.
*/
private static int med3( double x[], int a, int b, int c ) {
return (x[a] < x[b] ? (x[b] < x[c] ? b : x[a] < x[c] ? c : a) : (x[b] > x[c] ? b : x[a] > x[c] ? c : a));
}
/**
* Returns the index of the median of the three indexed doubles.
*/
private static int med3(double x[], int a, int b, int c) {
return (x[a] < x[b] ? (x[b] < x[c] ? b : x[a] < x[c] ? c : a) : (x[b] > x[c] ? b : x[a] > x[c] ? c : a));
}


}
@@ -3,25 +3,25 @@

final class DoubleArrayPointer {

private final double[] _array;
private int _offset;
private final double[] _array;
private int _offset;


public void setOffset( int offset ) {
if ( offset < 0 || offset >= _array.length ) throw new IllegalArgumentException("offset must be between 0 and the length of the array");
_offset = offset;
}
public void setOffset(int offset) {
if (offset < 0 || offset >= _array.length) throw new IllegalArgumentException("offset must be between 0 and the length of the array");
_offset = offset;
}

public DoubleArrayPointer( final double[] array, final int offset ) {
_array = array;
setOffset(offset);
}
public DoubleArrayPointer( final double[] array, final int offset ) {
_array = array;
setOffset(offset);
}

public double get( final int index ) {
return _array[_offset + index];
}
public double get(final int index) {
return _array[_offset + index];
}

public void set( final int index, final double value ) {
_array[_offset + index] = value;
}
public void set(final int index, final double value) {
_array[_offset + index] = value;
}
}
@@ -2,12 +2,12 @@

public class FeatureNode {

public final int index;
public final double value;
public final int index;
public final double value;

public FeatureNode( final int index, final double value ) {
if ( index < 1 ) throw new IllegalArgumentException("index must be >= 1");
this.index = index;
this.value = value;
}
public FeatureNode( final int index, final double value ) {
if (index < 1) throw new IllegalArgumentException("index must be >= 1");
this.index = index;
this.value = value;
}
}
@@ -3,15 +3,15 @@
// origin: tron.h
public interface Function {

// double fun(double *w);
// void grad(double *w, double *g);
// void Hv(double *s, double *Hs);
// double fun(double *w);
// void grad(double *w, double *g);
// void Hv(double *s, double *Hs);

double fun( double[] w );
double fun(double[] w);

void grad( double[] w, double[] g );
void grad(double[] w, double[] g);

void Hv( double[] s, double[] Hs );
void Hv(double[] s, double[] Hs);

int get_nr_variable();
int get_nr_variable();
}
@@ -3,25 +3,25 @@

final class IntArrayPointer {

private final int[] _array;
private int _offset;
private final int[] _array;
private int _offset;


public void setOffset( int offset ) {
if ( offset < 0 || offset >= _array.length ) throw new IllegalArgumentException("offset must be between 0 and the length of the array");
_offset = offset;
}
public void setOffset(int offset) {
if (offset < 0 || offset >= _array.length) throw new IllegalArgumentException("offset must be between 0 and the length of the array");
_offset = offset;
}

public IntArrayPointer( final int[] array, final int offset ) {
_array = array;
setOffset(offset);
}
public IntArrayPointer( final int[] array, final int offset ) {
_array = array;
setOffset(offset);
}

public int get( final int index ) {
return _array[_offset + index];
}
public int get(final int index) {
return _array[_offset + index];
}

public void set( final int index, final int value ) {
_array[_offset + index] = value;
}
public void set(final int index, final int value) {
_array[_offset + index] = value;
}
}
Oops, something went wrong.

0 comments on commit e859a30

Please sign in to comment.
You can’t perform that action at this time.