Skip to content
This repository has been archived by the owner on Mar 15, 2024. It is now read-only.

Commit

Permalink
Running clean up code on entire project, killing trailing whitespace …
Browse files Browse the repository at this point in the history
…etc. Made all settings project specific, so they're saved into vcs
  • Loading branch information
hraberg committed Apr 12, 2010
1 parent f31981f commit 441c347
Show file tree
Hide file tree
Showing 44 changed files with 769 additions and 340 deletions.
270 changes: 269 additions & 1 deletion .settings/org.eclipse.jdt.core.prefs

Large diffs are not rendered by default.

66 changes: 66 additions & 0 deletions .settings/org.eclipse.jdt.ui.prefs
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,66 @@
#Mon Apr 12 13:03:09 SGT 2010
cleanup.add_default_serial_version_id=true
cleanup.add_generated_serial_version_id=false
cleanup.add_missing_annotations=false
cleanup.add_missing_deprecated_annotations=true
cleanup.add_missing_methods=false
cleanup.add_missing_nls_tags=false
cleanup.add_missing_override_annotations=true
cleanup.add_serial_version_id=false
cleanup.always_use_blocks=true
cleanup.always_use_parentheses_in_expressions=false
cleanup.always_use_this_for_non_static_field_access=false
cleanup.always_use_this_for_non_static_method_access=false
cleanup.convert_to_enhanced_for_loop=false
cleanup.correct_indentation=true
cleanup.format_source_code=true
cleanup.format_source_code_changes_only=false
cleanup.make_local_variable_final=true
cleanup.make_parameters_final=false
cleanup.make_private_fields_final=true
cleanup.make_type_abstract_if_missing_method=false
cleanup.make_variable_declarations_final=false
cleanup.never_use_blocks=false
cleanup.never_use_parentheses_in_expressions=true
cleanup.organize_imports=true
cleanup.qualify_static_field_accesses_with_declaring_class=false
cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true
cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true
cleanup.qualify_static_member_accesses_with_declaring_class=true
cleanup.qualify_static_method_accesses_with_declaring_class=false
cleanup.remove_private_constructors=true
cleanup.remove_trailing_whitespaces=true
cleanup.remove_trailing_whitespaces_all=true
cleanup.remove_trailing_whitespaces_ignore_empty=false
cleanup.remove_unnecessary_casts=true
cleanup.remove_unnecessary_nls_tags=true
cleanup.remove_unused_imports=true
cleanup.remove_unused_local_variables=false
cleanup.remove_unused_private_fields=true
cleanup.remove_unused_private_members=false
cleanup.remove_unused_private_methods=true
cleanup.remove_unused_private_types=true
cleanup.sort_members=false
cleanup.sort_members_all=false
cleanup.use_blocks=false
cleanup.use_blocks_only_for_return_and_throw=false
cleanup.use_parentheses_in_expressions=false
cleanup.use_this_for_non_static_field_access=false
cleanup.use_this_for_non_static_field_access_only_if_necessary=true
cleanup.use_this_for_non_static_method_access=false
cleanup.use_this_for_non_static_method_access_only_if_necessary=true
cleanup_profile=_Eclipse [mine]
cleanup_settings_version=2
eclipse.preferences.version=1
formatter_profile=_Eclipse [mine]
formatter_settings_version=11
org.eclipse.jdt.ui.exception.name=e
org.eclipse.jdt.ui.gettersetter.use.is=true
org.eclipse.jdt.ui.ignorelowercasenames=true
org.eclipse.jdt.ui.importorder=java;javax;org;com;
org.eclipse.jdt.ui.javadoc=false
org.eclipse.jdt.ui.keywordthis=false
org.eclipse.jdt.ui.ondemandthreshold=20
org.eclipse.jdt.ui.overrideannotation=false
org.eclipse.jdt.ui.staticondemandthreshold=1
org.eclipse.jdt.ui.text.custom_code_templates=<?xml version\="1.0" encoding\="UTF-8" standalone\="no"?><templates><template autoinsert\="false" context\="gettercomment_context" deleted\="false" description\="Comment for getter method" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.gettercomment" name\="gettercomment"/><template autoinsert\="false" context\="settercomment_context" deleted\="false" description\="Comment for setter method" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.settercomment" name\="settercomment"/><template autoinsert\="false" context\="constructorcomment_context" deleted\="false" description\="Comment for created constructors" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.constructorcomment" name\="constructorcomment"/><template autoinsert\="false" context\="filecomment_context" deleted\="false" description\="Comment for created Java files" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.filecomment" name\="filecomment">&\#13;\r\n</template><template autoinsert\="false" context\="typecomment_context" deleted\="false" description\="Comment for created types" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.typecomment" name\="typecomment"/><template autoinsert\="false" context\="fieldcomment_context" deleted\="false" description\="Comment for fields" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.fieldcomment" name\="fieldcomment"/><template autoinsert\="false" context\="methodcomment_context" deleted\="false" description\="Comment for non-overriding methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.methodcomment" name\="methodcomment"/><template autoinsert\="false" context\="overridecomment_context" deleted\="false" description\="Comment for overriding methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.overridecomment" name\="overridecomment"/><template autoinsert\="false" context\="delegatecomment_context" deleted\="false" description\="Comment for delegate methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.delegatecomment" name\="delegatecomment"/><template autoinsert\="true" context\="newtype_context" deleted\="false" description\="Newly created files" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.newtype" name\="newtype">${filecomment}\r\n${package_declaration}\r\n\r\n${typecomment}\r\n${type_declaration}</template><template autoinsert\="true" context\="classbody_context" deleted\="false" description\="Code in new class type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.classbody" name\="classbody">\r\n</template><template autoinsert\="true" context\="interfacebody_context" deleted\="false" description\="Code in new interface type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.interfacebody" name\="interfacebody">\r\n</template><template autoinsert\="true" context\="enumbody_context" deleted\="false" description\="Code in new enum type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.enumbody" name\="enumbody">\r\n</template><template autoinsert\="true" context\="annotationbody_context" deleted\="false" description\="Code in new annotation type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.annotationbody" name\="annotationbody">\r\n</template><template autoinsert\="false" context\="catchblock_context" deleted\="false" description\="Code in new catch blocks" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.catchblock" name\="catchblock">throw uncheck(${exception_var});</template><template autoinsert\="false" context\="methodbody_context" deleted\="false" description\="Code in created method stubs" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.methodbody" name\="methodbody"/><template autoinsert\="false" context\="constructorbody_context" deleted\="false" description\="Code in created constructor stubs" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.constructorbody" name\="constructorbody"/><template autoinsert\="true" context\="getterbody_context" deleted\="false" description\="Code in created getters" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.getterbody" name\="getterbody">return ${field};</template><template autoinsert\="true" context\="setterbody_context" deleted\="false" description\="Code in created setters" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.setterbody" name\="setterbody">${field} \= ${param};</template></templates>
22 changes: 11 additions & 11 deletions src/example/java/lambda/MicroBench.java
Original file line number Original file line Diff line number Diff line change
@@ -1,5 +1,10 @@
package lambda; package lambda;


import static java.lang.System.*;
import static lambda.Lambda.*;
import static lambda.Parameters.*;
import static lambda.enumerable.Enumerable.*;

import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Random; import java.util.Random;
Expand All @@ -9,11 +14,6 @@
import lambda.primitives.LambdaPrimitives; import lambda.primitives.LambdaPrimitives;
import lambda.weaving.LambdaLoader; import lambda.weaving.LambdaLoader;
import lambda.weaving.Version; import lambda.weaving.Version;
import static java.lang.System.*;
import static lambda.Lambda.*;
import static lambda.Parameters.*;

import static lambda.enumerable.Enumerable.*;


public class MicroBench { public class MicroBench {
public static void main(String[] args) { public static void main(String[] args) {
Expand All @@ -38,18 +38,18 @@ void run(int n, int times) {


out.println(); out.println();


bench("object collect for loop", times, λ(_, methodCollect())); bench("object collect for loop", times, λ(_, methodCollect()));
bench("object collect lambda", times, λ(_, lambdaCollect())); bench("object collect lambda", times, λ(_, lambdaCollect()));


bench("primitive collect for loop", times, λ(_, methodCollectP())); bench("primitive collect for loop", times, λ(_, methodCollectP()));
bench("primitive collect lambda", times, λ(_, lambdaCollectP())); bench("primitive collect lambda", times, λ(_, lambdaCollectP()));


out.println(); out.println();


bench("object inject for loop", times, λ(_, methodInject())); bench("object inject for loop", times, λ(_, methodInject()));
bench("object inject lambda", times, λ(_, lambdaInject())); bench("object inject lambda", times, λ(_, lambdaInject()));


bench("primitive inject for loop", times, λ(_, methodInjectP())); bench("primitive inject for loop", times, λ(_, methodInjectP()));
bench("primitive inject lambda", times, λ(_, lambdaInjectP())); bench("primitive inject lambda", times, λ(_, lambdaInjectP()));
} }


Expand Down Expand Up @@ -82,7 +82,7 @@ Integer methodInject() {
result *= i; result *= i;
return result; return result;
} }

Integer lambdaInject() { Integer lambdaInject() {
return inject(integers, λ(n, m, n * m)); return inject(integers, λ(n, m, n * m));
} }
Expand Down Expand Up @@ -110,7 +110,7 @@ long bench(String name, int times, Fn0<?> block) {
Fn1ItoI fibp; Fn1ItoI fibp;


int length = 100000; int length = 100000;

List<Integer> integers = new ArrayList<Integer>(length); List<Integer> integers = new ArrayList<Integer>(length);
int[] ints = new int[length]; int[] ints = new int[length];


Expand Down
15 changes: 7 additions & 8 deletions src/example/java/lambda/enumerable/EnumerableExample.java
Original file line number Original file line Diff line number Diff line change
@@ -1,5 +1,12 @@
package lambda.enumerable; package lambda.enumerable;


import static java.lang.Math.*;
import static java.util.Arrays.*;
import static lambda.Lambda.*;
import static lambda.Parameters.*;
import static lambda.enumerable.Enumerable.*;
import static lambda.primitives.LambdaPrimitives.*;

import java.io.PrintStream; import java.io.PrintStream;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
Expand All @@ -11,14 +18,6 @@
import lambda.primitives.Fn1ItoI; import lambda.primitives.Fn1ItoI;
import lambda.weaving.LambdaLoader; import lambda.weaving.LambdaLoader;
import lambda.weaving.Version; import lambda.weaving.Version;
import static java.lang.Math.*;
import static java.util.Arrays.*;
import static lambda.Lambda.*;
import static lambda.Parameters.*;

import static lambda.enumerable.Enumerable.*;

import static lambda.primitives.LambdaPrimitives.*;


public class EnumerableExample { public class EnumerableExample {
/** /**
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/lambda/annotation/NewLambda.java
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
* <p> * <p>
* The last argument to the method is the actual block expression. The other * The last argument to the method is the actual block expression. The other
* arguments have to be {@link LambdaParameter} marking the blocks signature. * arguments have to be {@link LambdaParameter} marking the blocks signature.
* The first parameter can be {@link Unused} to create blocks that * The first parameter can be {@link Unused} to create blocks that take no
* take no parameters. * parameters.
* <p> * <p>
* The return type of the block is the type of the block expression parameter. * The return type of the block is the type of the block expression parameter.
* *
Expand Down
32 changes: 25 additions & 7 deletions src/main/java/lambda/enumerable/Enumerable.java
Original file line number Original file line Diff line number Diff line change
@@ -1,16 +1,33 @@
package lambda.enumerable; package lambda.enumerable;


import java.io.*; import static java.lang.Boolean.*;
import java.util.*; import static lambda.exception.UncheckedException.*;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.Reader;
import java.io.StringReader;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.regex.Pattern; import java.util.regex.Pattern;


import lambda.Fn0; import lambda.Fn0;
import lambda.Fn1; import lambda.Fn1;
import lambda.Fn2; import lambda.Fn2;
import lambda.enumerable.collection.*; import lambda.enumerable.collection.EIterable;
import static java.lang.Boolean.*; import lambda.enumerable.collection.EList;
import static lambda.exception.UncheckedException.*; import lambda.enumerable.collection.EMap;
import lambda.enumerable.collection.ESet;


/** /**
* Ruby/Smalltalk style internal iterators for Java 5 using bytecode * Ruby/Smalltalk style internal iterators for Java 5 using bytecode
Expand Down Expand Up @@ -557,11 +574,12 @@ private static final class ReverseComparator<E> implements Comparator<E> {
} }


public int compare(E o1, E o2) { public int compare(E o1, E o2) {
return - comparator.compare(o1, o2); return -comparator.compare(o1, o2);
} }
} }


private static final class NaturalOrderComparator<E extends Object & Comparable<? super E>> implements Comparator<E> { private static final class NaturalOrderComparator<E extends Object & Comparable<? super E>> implements
Comparator<E> {
public int compare(E o1, E o2) { public int compare(E o1, E o2) {
return o1.compareTo(o2); return o1.compareTo(o2);
} }
Expand Down
13 changes: 8 additions & 5 deletions src/main/java/lambda/enumerable/EnumerableArrays.java
Original file line number Original file line Diff line number Diff line change
@@ -1,7 +1,10 @@
package lambda.enumerable; package lambda.enumerable;


import java.lang.reflect.Array; import java.lang.reflect.Array;
import java.util.*; import java.util.Comparator;
import java.util.Iterator;
import java.util.List;
import java.util.NoSuchElementException;
import java.util.regex.Pattern; import java.util.regex.Pattern;


import lambda.Fn1; import lambda.Fn1;
Expand Down Expand Up @@ -270,7 +273,7 @@ public static Integer[] range(int start, int end) {
public static Integer[] range(int start, int end, boolean exclusive) { public static Integer[] range(int start, int end, boolean exclusive) {
return Enumerable.range(start, end, exclusive).toList().toArray(new Integer[0]); return Enumerable.range(start, end, exclusive).toList().toArray(new Integer[0]);
} }

/** /**
* Returns an array containing all elements of array for which block is * Returns an array containing all elements of array for which block is
* false. * false.
Expand Down Expand Up @@ -363,11 +366,11 @@ public static <E> Object[][] zip(E[] array, Object[]... args) {
private static <T> T[] newEmptyArray(T[] array) { private static <T> T[] newEmptyArray(T[] array) {
return (T[]) Array.newInstance(array.getClass().getComponentType(), 0); return (T[]) Array.newInstance(array.getClass().getComponentType(), 0);
} }

private static <T> Iterable<T> asIterable(T[] array) { private static <T> Iterable<T> asIterable(T[] array) {
return new ArrayIterable<T>(array); return new ArrayIterable<T>(array);
} }

static class ArrayIterable<T> implements Iterable<T> { static class ArrayIterable<T> implements Iterable<T> {
T[] array; T[] array;


Expand All @@ -385,7 +388,7 @@ public boolean hasNext() {


public T next() { public T next() {
if (i == array.length) if (i == array.length)
throw new NoSuchElementException(); throw new NoSuchElementException();
return array[i++]; return array[i++];
} }


Expand Down
2 changes: 1 addition & 1 deletion src/main/java/lambda/enumerable/Range.java
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public EList<Integer> toList() {
result.add(integer); result.add(integer);
return result; return result;
} }

public int[] toArray() { public int[] toArray() {
int[] array = new int[(exclusive ? end : end + 1) - start]; int[] array = new int[(exclusive ? end : end + 1) - start];
int i = 0; int i = 0;
Expand Down
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public ECollection() {
public ECollection(Collection<E> collection) { public ECollection(Collection<E> collection) {
super(collection); super(collection);
} }

public Collection<E> delegate() { public Collection<E> delegate() {
return (Collection<E>) iterable; return (Collection<E>) iterable;
} }
Expand Down
11 changes: 7 additions & 4 deletions src/main/java/lambda/enumerable/collection/EIterable.java
Original file line number Original file line Diff line number Diff line change
@@ -1,13 +1,16 @@
package lambda.enumerable.collection; package lambda.enumerable.collection;


import java.util.*; import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import java.util.regex.Pattern; import java.util.regex.Pattern;


import lambda.Fn1; import lambda.Fn1;
import lambda.Fn2; import lambda.Fn2;
import lambda.enumerable.Enumerable; import lambda.enumerable.Enumerable;


public class EIterable<E> implements Iterable<E>, IEnumerable<E> { public class EIterable<E> implements Iterable<E>, IEnumerable<E> {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public static <T, R extends EIterable<T>> R from(Iterable<T> iterable) { public static <T, R extends EIterable<T>> R from(Iterable<T> iterable) {
if (iterable instanceof EIterable<?>) if (iterable instanceof EIterable<?>)
Expand All @@ -20,7 +23,7 @@ public static <T, R extends EIterable<T>> R from(Iterable<T> iterable) {
return (R) new ECollection<T>((Collection<T>) iterable); return (R) new ECollection<T>((Collection<T>) iterable);
return (R) new EIterable<T>(iterable); return (R) new EIterable<T>(iterable);
} }

protected final Iterable<E> iterable; protected final Iterable<E> iterable;


public EIterable(Iterable<E> iterable) { public EIterable(Iterable<E> iterable) {
Expand All @@ -39,7 +42,7 @@ public boolean equals(Object obj) {
if (obj instanceof EIterable<?>) if (obj instanceof EIterable<?>)
return this.iterable.equals(((EIterable<?>) obj).iterable); return this.iterable.equals(((EIterable<?>) obj).iterable);
if (obj instanceof Iterable<?>) if (obj instanceof Iterable<?>)
return this.iterable.equals((Iterable<?>) obj); return this.iterable.equals(obj);
return false; return false;
} }


Expand Down
5 changes: 4 additions & 1 deletion src/main/java/lambda/enumerable/collection/EList.java
Original file line number Original file line Diff line number Diff line change
@@ -1,6 +1,9 @@
package lambda.enumerable.collection; package lambda.enumerable.collection;


import java.util.*; import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.ListIterator;


public class EList<E> extends ECollection<E> implements List<E> { public class EList<E> extends ECollection<E> implements List<E> {
public EList() { public EList() {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/lambda/enumerable/collection/EMap.java
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public EMap() {
public EMap(Map<K, V> map) { public EMap(Map<K, V> map) {
this.map = map; this.map = map;
} }

public Map<K, V> delegate() { public Map<K, V> delegate() {
return map; return map;
} }
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/lambda/enumerable/collection/ESet.java
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public ESet() {
public ESet(Set<E> set) { public ESet(Set<E> set) {
super(set); super(set);
} }

public Set<E> delegate() { public Set<E> delegate() {
return (Set<E>) iterable; return (Set<E>) iterable;
} }
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/lambda/enumerable/collection/IEnumerable.java
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -219,8 +219,7 @@ public interface IEnumerable<E> extends Iterable<E> {
* *
* <p> * <p>
* Due to varargs this version doesn't support taking a block like in Ruby. * Due to varargs this version doesn't support taking a block like in Ruby.
* Feed the result into {@link #collect(Fn1)} to achieve the same * Feed the result into {@link #collect(Fn1)} to achieve the same effect.
* effect.
* </p> * </p>
*/ */
EList<EList<?>> zip(Iterable<?>... args); EList<EList<?>> zip(Iterable<?>... args);
Expand Down
Loading

0 comments on commit 441c347

Please sign in to comment.