New format

This commit is contained in:
Bruce Eckel 2015-09-07 11:44:36 -06:00
parent 7140659efb
commit 06855b96c5
943 changed files with 3193 additions and 2549 deletions

View File

@ -1,5 +1,5 @@
//: Copyright.txt
This computer source code is Copyright 2015 MindView LLC
// Copyright.txt
This computer source code is Copyright ©2015 MindView LLC
All Rights Reserved.
Permission to use, copy, modify, and distribute this
@ -70,4 +70,3 @@ where it is freely available under the terms stated above.
If you think you've found an error in the Source Code,
please submit a correction at:
https://github.com/BruceEckel/OnJava-Examples/issues
///:~

View File

@ -1,4 +1,4 @@
//: annotations/AtUnitComposition.java
// annotations/AtUnitComposition.java
// ©2015 MindView LLC: see Copyright.txt
// Creating non-embedded tests.
package annotations;
@ -18,9 +18,10 @@ public class AtUnitComposition {
OSExecute.command(
"java com.mindviewinc.atunit.AtUnit AtUnitComposition");
}
} /* Output:
}
/* Output:
annotations.AtUnitComposition
. _methodOne
. _methodTwo This is methodTwo
OK (2 tests)
*///:~
*/

View File

@ -1,4 +1,4 @@
//: annotations/AtUnitExample1.java
// annotations/AtUnitExample1.java
// ©2015 MindView LLC: see Copyright.txt
package annotations;
import com.mindviewinc.atunit.*;
@ -24,7 +24,8 @@ public class AtUnitExample1 {
OSExecute.command(
"java com.mindviewinc.atunit.AtUnit AtUnitExample1");
}
} /* Output:
}
/* Output:
annotations.AtUnitExample1
. anotherDisappointment (failed)
. failureTest (failed)
@ -35,4 +36,4 @@ annotations.AtUnitExample1
>>> 2 FAILURES <<<
annotations.AtUnitExample1: anotherDisappointment
annotations.AtUnitExample1: failureTest
*///:~
*/

View File

@ -1,4 +1,4 @@
//: annotations/AtUnitExample2.java
// annotations/AtUnitExample2.java
// ©2015 MindView LLC: see Copyright.txt
// Assertions and exceptions can be used in @Tests.
package annotations;
@ -32,7 +32,8 @@ public class AtUnitExample2 {
OSExecute.command(
"java com.mindviewinc.atunit.AtUnit AtUnitExample2");
}
} /* Output:
}
/* Output:
annotations.AtUnitExample2
. assertFailureExample java.lang.AssertionError: What a
surprise!
@ -46,4 +47,4 @@ nofile.txt (The system cannot find the file specified)
>>> 2 FAILURES <<<
annotations.AtUnitExample2: assertFailureExample
annotations.AtUnitExample2: exceptionExample
*///:~
*/

View File

@ -1,4 +1,4 @@
//: annotations/AtUnitExample3.java
// annotations/AtUnitExample3.java
// ©2015 MindView LLC: see Copyright.txt
package annotations;
import com.mindviewinc.atunit.*;
@ -27,10 +27,11 @@ public class AtUnitExample3 {
OSExecute.command(
"java com.mindviewinc.atunit.AtUnit AtUnitExample3");
}
} /* Output:
}
/* Output:
annotations.AtUnitExample3
. methodOneTest
. initialization
. m2 This is methodTwo
OK (3 tests)
*///:~
*/

View File

@ -1,4 +1,4 @@
//: annotations/AtUnitExample4.java
// annotations/AtUnitExample4.java
// ©2015 MindView LLC: see Copyright.txt
package annotations;
import java.util.*;
@ -58,7 +58,8 @@ public class AtUnitExample4 {
OSExecute.command(
"java com.mindviewinc.atunit.AtUnit AtUnitExample4");
}
} /* Output:
}
/* Output:
starting
annotations.AtUnitExample4
. scramble1 'All'
@ -67,4 +68,4 @@ lAl
tsaeborornussu
. words 'are'
OK (3 tests)
*///:~
*/

View File

@ -1,4 +1,4 @@
//: annotations/AtUnitExample5.java
// annotations/AtUnitExample5.java
// ©2015 MindView LLC: see Copyright.txt
package annotations;
import java.io.*;
@ -42,7 +42,8 @@ public class AtUnitExample5 {
OSExecute.command(
"java com.mindviewinc.atunit.AtUnit AtUnitExample5");
}
} /* Output:
}
/* Output:
annotations.AtUnitExample5
. test3
Running cleanup
@ -51,4 +52,4 @@ Running cleanup
. test2
Running cleanup
OK (3 tests)
*///:~
*/

View File

@ -1,4 +1,4 @@
//: annotations/AtUnitExternalTest.java
// annotations/AtUnitExternalTest.java
// ©2015 MindView LLC: see Copyright.txt
// Creating non-embedded tests.
package annotations;
@ -14,9 +14,10 @@ public class AtUnitExternalTest extends AtUnitExample1 {
OSExecute.command(
"java com.mindviewinc.atunit.AtUnit AtUnitExternalTest");
}
} /* Output:
}
/* Output:
annotations.AtUnitExternalTest
. _methodTwo This is methodTwo
. _methodOne
OK (2 tests)
*///:~
*/

View File

@ -1,4 +1,4 @@
//: annotations/HashSetTest.java
// annotations/HashSetTest.java
// ©2015 MindView LLC: see Copyright.txt
package annotations;
import java.util.*;
@ -23,10 +23,11 @@ public class HashSetTest {
OSExecute.command(
"java com.mindviewinc.atunit.AtUnit HashSetTest");
}
} /* Output:
}
/* Output:
annotations.HashSetTest
. initialization
. _remove
. _contains
OK (3 tests)
*///:~
*/

View File

@ -1,4 +1,4 @@
//: annotations/PasswordUtils.java
// annotations/PasswordUtils.java
// ©2015 MindView LLC: see Copyright.txt
import java.util.*;
@ -18,4 +18,4 @@ public class PasswordUtils {
List<String> prevPasswords, String password) {
return !prevPasswords.contains(password);
}
} ///:~
}

View File

@ -1,4 +1,4 @@
//: annotations/SimulatingNull.java
// annotations/SimulatingNull.java
// ©2015 MindView LLC: see Copyright.txt
import java.lang.annotation.*;
@ -7,4 +7,4 @@ import java.lang.annotation.*;
public @interface SimulatingNull {
public int id() default -1;
public String description() default "";
} ///:~
}

View File

@ -1,4 +1,4 @@
//: annotations/StackL.java
// annotations/StackL.java
// ©2015 MindView LLC: see Copyright.txt
// A stack built on a linkedList.
package annotations;
@ -9,4 +9,4 @@ public class StackL<T> {
public void push(T v) { list.addFirst(v); }
public T top() { return list.getFirst(); }
public T pop() { return list.removeFirst(); }
} ///:~
}

View File

@ -1,4 +1,4 @@
//: annotations/StackLStringTest.java
// annotations/StackLStringTest.java
// ©2015 MindView LLC: see Copyright.txt
// Applying @Unit to generics.
package annotations;
@ -28,10 +28,11 @@ public class StackLStringTest extends StackL<String> {
OSExecute.command(
"java com.mindviewinc.atunit.AtUnit StackLStringTest");
}
} /* Output:
}
/* Output:
annotations.StackLStringTest
. _push
. _top
. _pop
OK (3 tests)
*///:~
*/

View File

@ -1,4 +1,4 @@
//: annotations/Testable.java
// annotations/Testable.java
// ©2015 MindView LLC: see Copyright.txt
package annotations;
import com.mindviewinc.atunit.*;
@ -8,4 +8,4 @@ public class Testable {
System.out.println("Executing..");
}
@Test void testExecute() { execute(); }
} ///:~
}

View File

@ -1,4 +1,4 @@
//: annotations/UseCase.java
// annotations/UseCase.java
// ©2015 MindView LLC: see Copyright.txt
import java.lang.annotation.*;
@ -7,4 +7,4 @@ import java.lang.annotation.*;
public @interface UseCase {
public int id();
public String description() default "no description";
} ///:~
}

View File

@ -1,4 +1,4 @@
//: annotations/UseCaseTracker.java
// annotations/UseCaseTracker.java
// ©2015 MindView LLC: see Copyright.txt
import java.lang.reflect.*;
import java.util.*;
@ -23,11 +23,12 @@ public class UseCaseTracker {
Collections.addAll(useCases, 47, 48, 49, 50);
trackUseCases(useCases, PasswordUtils.class);
}
} /* Output:
}
/* Output:
Found Use Case:49 New passwords can't equal previously used
ones
Found Use Case:47 Passwords must contain at least one
numeric
Found Use Case:48 no description
Warning: Missing use case-50
*///:~
*/

View File

@ -1,4 +1,4 @@
//: annotations/database/Constraints.java
// annotations/database/Constraints.java
// ©2015 MindView LLC: see Copyright.txt
package annotations.database;
import java.lang.annotation.*;
@ -9,4 +9,4 @@ public @interface Constraints {
boolean primaryKey() default false;
boolean allowNull() default true;
boolean unique() default false;
} ///:~
}

View File

@ -1,4 +1,4 @@
//: annotations/database/DBTable.java
// annotations/database/DBTable.java
// ©2015 MindView LLC: see Copyright.txt
package annotations.database;
import java.lang.annotation.*;
@ -7,4 +7,4 @@ import java.lang.annotation.*;
@Retention(RetentionPolicy.RUNTIME)
public @interface DBTable {
public String name() default "";
} ///:~
}

View File

@ -1,4 +1,4 @@
//: annotations/database/Member.java
// annotations/database/Member.java
// ©2015 MindView LLC: see Copyright.txt
package annotations.database;
@ -17,4 +17,4 @@ public class Member {
@Override
public String toString() { return handle; }
public Integer getAge() { return age; }
} ///:~
}

View File

@ -1,4 +1,4 @@
//: annotations/database/SQLInteger.java
// annotations/database/SQLInteger.java
// ©2015 MindView LLC: see Copyright.txt
package annotations.database;
import java.lang.annotation.*;
@ -8,4 +8,4 @@ import java.lang.annotation.*;
public @interface SQLInteger {
String name() default "";
Constraints constraints() default @Constraints;
} ///:~
}

View File

@ -1,4 +1,4 @@
//: annotations/database/SQLString.java
// annotations/database/SQLString.java
// ©2015 MindView LLC: see Copyright.txt
package annotations.database;
import java.lang.annotation.*;
@ -9,4 +9,4 @@ public @interface SQLString {
int value() default 0;
String name() default "";
Constraints constraints() default @Constraints;
} ///:~
}

View File

@ -1,4 +1,4 @@
//: annotations/database/TableCreator.java
// annotations/database/TableCreator.java
// ©2015 MindView LLC: see Copyright.txt
// Reflection-based annotation processor.
// {Args: annotations.database.Member}
@ -74,7 +74,8 @@ public class TableCreator {
constraints += " UNIQUE";
return constraints;
}
} /* Output:
}
/* Output:
Table Creation SQL for annotations.database.Member is :
CREATE TABLE MEMBER(
FIRSTNAME VARCHAR(30));
@ -93,4 +94,4 @@ CREATE TABLE MEMBER(
LASTNAME VARCHAR(50),
AGE INT,
HANDLE VARCHAR(30) PRIMARY KEY);
*///:~
*/

View File

@ -1,4 +1,4 @@
//: annotations/database/Uniqueness.java
// annotations/database/Uniqueness.java
// ©2015 MindView LLC: see Copyright.txt
// Sample of nested annotations
package annotations.database;
@ -6,4 +6,4 @@ package annotations.database;
public @interface Uniqueness {
Constraints constraints()
default @Constraints(unique=true);
} ///:~
}

View File

@ -1,4 +1,4 @@
//: annotations/ifx/ExtractInterface.java
// annotations/ifx/ExtractInterface.java
// ©2015 MindView LLC: see Copyright.txt
// javac-based annotation processing.
package annotations.ifx;
@ -8,4 +8,4 @@ import java.lang.annotation.*;
@Retention(RetentionPolicy.SOURCE)
public @interface ExtractInterface {
public String interfaceName() default "-!!-";
} ///:~
}

View File

@ -1,4 +1,4 @@
//: annotations/ifx/IfaceExtractorProcessor.java
// annotations/ifx/IfaceExtractorProcessor.java
// ©2015 MindView LLC: see Copyright.txt
// javac-based annotation processing.
package annotations.ifx;
@ -89,4 +89,4 @@ extends AbstractProcessor {
args += ")";
return args;
}
} ///:~
}

View File

@ -1,4 +1,4 @@
//: annotations/ifx/Multiplier.java
// annotations/ifx/Multiplier.java
// ©2015 MindView LLC: see Copyright.txt
// javac-based annotation processing.
package annotations.ifx;
@ -25,6 +25,7 @@ public class Multiplier {
System.out.println(
"11 * 16 = " + m.multiply(11, 16));
}
} /* Output:
}
/* Output:
11 * 16 = 176
*///:~
*/

View File

@ -1,4 +1,4 @@
//: annotations/simplest/Simple.java
// annotations/simplest/Simple.java
// ©2015 MindView LLC: see Copyright.txt
// A bare-bones annotation.
package annotations.simplest;
@ -15,4 +15,4 @@ import java.lang.annotation.ElementType;
ElementType.LOCAL_VARIABLE})
public @interface Simple {
String value() default "-default-";
} ///:~
}

View File

@ -1,4 +1,4 @@
//: annotations/simplest/SimpleProcessor.java
// annotations/simplest/SimpleProcessor.java
// ©2015 MindView LLC: see Copyright.txt
// A bare-bones annotation processor.
package annotations.simplest;
@ -41,4 +41,4 @@ extends AbstractProcessor {
System.out.println(ex.getParameters() + ")");
}
}
} ///:~
}

View File

@ -1,4 +1,4 @@
//: annotations/simplest/SimpleTest.java
// annotations/simplest/SimpleTest.java
// ©2015 MindView LLC: see Copyright.txt
// Test the "Simple" annotation
package annotations.simplest;
@ -23,6 +23,7 @@ public class SimpleTest {
SimpleTest st = new SimpleTest();
st.foo();
}
} /* Output:
}
/* Output:
SimpleTest.foo()
*///:~
*/

View File

@ -1,4 +1,4 @@
//: arrays/AlphabeticSearch.java
// arrays/AlphabeticSearch.java
// ©2015 MindView LLC: see Copyright.txt
// Searching with a Comparator.
import java.util.*;
@ -14,11 +14,12 @@ public class AlphabeticSearch {
String.CASE_INSENSITIVE_ORDER);
System.out.println("Index: "+ index + "\n"+ sa[index]);
}
} /* Output:
}
/* Output:
[bkIna, cQrGs, cXZJo, dLsmw, eGZMm, EqUCB, gwsqP, hKcxr,
HLGEa, HqXum, HxxHv, JMRoE, JmzMs, Mesbt, MNvqe, nyGcF,
ogoYW, OneOE, OWZnT, RFJQA, rUkZP, sgqia, slJrL, suEcU,
uTpnX, vpfFv, WHkjU, xxEAJ, YNzbr, zDyCy]
Index: 10
HxxHv
*///:~
*/

View File

@ -1,4 +1,4 @@
//: arrays/ArrayOfGenericType.java
// arrays/ArrayOfGenericType.java
// ©2015 MindView LLC: see Copyright.txt
// Arrays of generic types won't compile.
@ -11,4 +11,4 @@ public class ArrayOfGenericType<T> {
}
// Illegal:
//! public <U> U[] makeArray() { return new U[10]; }
} ///:~
}

View File

@ -1,4 +1,4 @@
//: arrays/ArrayOfGenerics.java
// arrays/ArrayOfGenerics.java
// ©2015 MindView LLC: see Copyright.txt
// It is possible to create arrays of generics.
import java.util.*;
@ -26,4 +26,5 @@ public class ArrayOfGenerics {
for(int i = 0; i < spheres.length; i++)
spheres[i] = new ArrayList<>();
}
} /* Output: (None) *///:~
}
/* Output: (None) */

View File

@ -1,4 +1,4 @@
//: arrays/ArrayOptions.java
// arrays/ArrayOptions.java
// ©2015 MindView LLC: see Copyright.txt
// Initialization & re-assignment of arrays.
import java.util.*;
@ -52,7 +52,8 @@ public class ArrayOptions {
e = new int[]{ 1, 2 };
print("e.length = " + e.length);
}
} /* Output:
}
/* Output:
b: [null, null, null, null, null]
a.length = 2
b.length = 5
@ -65,4 +66,4 @@ g.length = 4
h.length = 3
e.length = 3
e.length = 2
*///:~
*/

View File

@ -1,4 +1,4 @@
//: arrays/ArraySearching.java
// arrays/ArraySearching.java
// ©2015 MindView LLC: see Copyright.txt
// Using Arrays.binarySearch().
import java.util.*;
@ -23,9 +23,10 @@ public class ArraySearching {
}
}
}
} /* Output:
}
/* Output:
Sorted array: [128, 140, 200, 207, 258, 258, 278, 288, 322,
429, 511, 520, 522, 551, 555, 589, 693, 704, 809, 861, 861,
868, 916, 961, 998]
Location of 322 is 8, a[8] = 322
*///:~
*/

View File

@ -1,4 +1,4 @@
//: arrays/AssemblingMultidimensionalArrays.java
// arrays/AssemblingMultidimensionalArrays.java
// ©2015 MindView LLC: see Copyright.txt
// Creating multidimensional arrays.
import java.util.*;
@ -14,6 +14,7 @@ public class AssemblingMultidimensionalArrays {
}
System.out.println(Arrays.deepToString(a));
}
} /* Output:
}
/* Output:
[[0, 0, 0], [0, 1, 2], [0, 2, 4]]
*///:~
*/

View File

@ -1,4 +1,4 @@
//: arrays/AutoboxingArrays.java
// arrays/AutoboxingArrays.java
// ©2015 MindView LLC: see Copyright.txt
import java.util.*;
@ -12,8 +12,9 @@ public class AutoboxingArrays {
};
System.out.println(Arrays.deepToString(a));
}
} /* Output:
}
/* Output:
[[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [21, 22, 23, 24, 25, 26,
27, 28, 29, 30], [51, 52, 53, 54, 55, 56, 57, 58, 59, 60],
[71, 72, 73, 74, 75, 76, 77, 78, 79, 80]]
*///:~
*/

View File

@ -1,4 +1,4 @@
//: arrays/CompType.java
// arrays/CompType.java
// ©2015 MindView LLC: see Copyright.txt
// Implementing Comparable in a class.
import java.util.*;
@ -38,7 +38,8 @@ public class CompType implements Comparable<CompType> {
print("after sorting:");
print(Arrays.toString(a));
}
} /* Output:
}
/* Output:
before sorting:
[[i = 58, j = 55], [i = 93, j = 61], [i = 61, j = 29]
, [i = 68, j = 0], [i = 22, j = 7], [i = 88, j = 28]
@ -51,4 +52,4 @@ after sorting:
, [i = 58, j = 55], [i = 61, j = 29], [i = 68, j = 0]
, [i = 88, j = 28], [i = 93, j = 61], [i = 98, j = 61]
]
*///:~
*/

View File

@ -1,4 +1,4 @@
//: arrays/ComparatorTest.java
// arrays/ComparatorTest.java
// ©2015 MindView LLC: see Copyright.txt
// Implementing a Comparator for a class.
import java.util.*;
@ -21,7 +21,8 @@ public class ComparatorTest {
print("after sorting:");
print(Arrays.toString(a));
}
} /* Output:
}
/* Output:
before sorting:
[[i = 58, j = 55], [i = 93, j = 61], [i = 61, j = 29]
, [i = 68, j = 0], [i = 22, j = 7], [i = 88, j = 28]
@ -34,4 +35,4 @@ after sorting:
, [i = 58, j = 55], [i = 20, j = 58], [i = 93, j = 61]
, [i = 98, j = 61], [i = 9, j = 78], [i = 51, j = 89]
]
*///:~
*/

View File

@ -1,4 +1,4 @@
//: arrays/ComparingArrays.java
// arrays/ComparingArrays.java
// ©2015 MindView LLC: see Copyright.txt
// Using Arrays.equals()
import java.util.*;
@ -19,8 +19,9 @@ public class ComparingArrays {
new String("Hi"), new String("Hi") };
print(Arrays.equals(s1, s2));
}
} /* Output:
}
/* Output:
true
false
true
*///:~
*/

View File

@ -1,4 +1,4 @@
//: arrays/ContainerComparison.java
// arrays/ContainerComparison.java
// ©2015 MindView LLC: see Copyright.txt
import java.util.*;
import static com.mindviewinc.util.Print.*;
@ -34,7 +34,8 @@ public class ContainerComparison {
print(intList);
print(intList.get(4));
}
} /* Output:
}
/* Output:
[Sphere 0, Sphere 1, Sphere 2, Sphere 3, Sphere 4, null,
null, null, null, null]
Sphere 4
@ -44,4 +45,4 @@ Sphere 9
4
[0, 1, 2, 3, 4, 5, 97]
4
*///:~
*/

View File

@ -1,4 +1,4 @@
//: arrays/CopyingArrays.java
// arrays/CopyingArrays.java
// ©2015 MindView LLC: see Copyright.txt
// Using System.arraycopy()
import java.util.*;
@ -31,7 +31,8 @@ public class CopyingArrays {
System.arraycopy(v, 0, u, u.length/2, v.length);
print("u = " + Arrays.toString(u));
}
} /* Output:
}
/* Output:
i = [47, 47, 47, 47, 47, 47, 47]
j = [99, 99, 99, 99, 99, 99, 99, 99, 99, 99]
j = [47, 47, 47, 47, 47, 47, 47, 99, 99, 99]
@ -40,4 +41,4 @@ i = [103, 103, 103, 103, 103, 47, 47]
u = [47, 47, 47, 47, 47, 47, 47, 47, 47, 47]
v = [99, 99, 99, 99, 99]
u = [47, 47, 47, 47, 47, 99, 99, 99, 99, 99]
*///:~
*/

View File

@ -1,4 +1,4 @@
//: arrays/FillingArrays.java
// arrays/FillingArrays.java
// ©2015 MindView LLC: see Copyright.txt
// Using Arrays.fill()
import java.util.*;
@ -38,7 +38,8 @@ public class FillingArrays {
Arrays.fill(a9, 3, 5, "World");
print("a9 = " + Arrays.toString(a9));
}
} /* Output:
}
/* Output:
a1 = [true, true, true, true, true, true]
a2 = [11, 11, 11, 11, 11, 11]
a3 = [x, x, x, x, x, x]
@ -49,4 +50,4 @@ a7 = [29.0, 29.0, 29.0, 29.0, 29.0, 29.0]
a8 = [47.0, 47.0, 47.0, 47.0, 47.0, 47.0]
a9 = [Hello, Hello, Hello, Hello, Hello, Hello]
a9 = [Hello, Hello, Hello, World, World, Hello]
*///:~
*/

View File

@ -1,4 +1,4 @@
//: arrays/GeneratorsTest.java
// arrays/GeneratorsTest.java
// ©2015 MindView LLC: see Copyright.txt
import com.mindviewinc.util.*;
@ -21,7 +21,8 @@ public class GeneratorsTest {
public static void main(String[] args) {
test(CountingGenerator.class);
}
} /* Output:
}
/* Output:
Double: 0.0 1.0 2.0 3.0 4.0 5.0 6.0 7.0 8.0 9.0
Float: 0.0 1.0 2.0 3.0 4.0 5.0 6.0 7.0 8.0 9.0
Long: 0 1 2 3 4 5 6 7 8 9
@ -33,4 +34,4 @@ Character: a b c d e f g h i j
Byte: 0 1 2 3 4 5 6 7 8 9
Boolean: true false true false true false true false true
false
*///:~
*/

View File

@ -1,4 +1,4 @@
//: arrays/IceCream.java
// arrays/IceCream.java
// ©2015 MindView LLC: see Copyright.txt
// Returning arrays from methods.
import java.util.*;
@ -29,7 +29,8 @@ public class IceCream {
for(int i = 0; i < 7; i++)
System.out.println(Arrays.toString(flavorSet(3)));
}
} /* Output:
}
/* Output:
[Rum Raisin, Mint Chip, Mocha Almond Fudge]
[Chocolate, Strawberry, Mocha Almond Fudge]
[Strawberry, Mint Chip, Mocha Almond Fudge]
@ -37,4 +38,4 @@ public class IceCream {
[Vanilla Fudge Swirl, Chocolate, Mocha Almond Fudge]
[Praline Cream, Strawberry, Mocha Almond Fudge]
[Mocha Almond Fudge, Strawberry, Mint Chip]
*///:~
*/

View File

@ -1,4 +1,4 @@
//: arrays/MultiDimWrapperArray.java
// arrays/MultiDimWrapperArray.java
// ©2015 MindView LLC: see Copyright.txt
// Multidimensional arrays of "wrapper" objects.
import java.util.*;
@ -23,10 +23,11 @@ public class MultiDimWrapperArray {
System.out.println("a2: " + Arrays.deepToString(a2));
System.out.println("a3: " + Arrays.deepToString(a3));
}
} /* Output:
}
/* Output:
a1: [[1, 2, 3], [4, 5, 6]]
a2: [[[1.1, 2.2], [3.3, 4.4]], [[5.5, 6.6], [7.7, 8.8]],
[[9.9, 1.2], [2.3, 3.4]]]
a3: [[The, Quick, Sly, Fox], [Jumped, Over], [The, Lazy,
Brown, Dog, and, friend]]
*///:~
*/

View File

@ -1,4 +1,4 @@
//: arrays/MultidimensionalObjectArrays.java
// arrays/MultidimensionalObjectArrays.java
// ©2015 MindView LLC: see Copyright.txt
import java.util.*;
@ -15,8 +15,9 @@ public class MultidimensionalObjectArrays {
};
System.out.println(Arrays.deepToString(spheres));
}
} /* Output:
}
/* Output:
[[Sphere 0, Sphere 1], [Sphere 2, Sphere 3, Sphere 4,
Sphere 5], [Sphere 6, Sphere 7, Sphere 8, Sphere 9, Sphere
10, Sphere 11, Sphere 12, Sphere 13]]
*///:~
*/

View File

@ -1,4 +1,4 @@
//: arrays/MultidimensionalPrimitiveArray.java
// arrays/MultidimensionalPrimitiveArray.java
// ©2015 MindView LLC: see Copyright.txt
// Creating multidimensional arrays.
import java.util.*;
@ -11,6 +11,7 @@ public class MultidimensionalPrimitiveArray {
};
System.out.println(Arrays.deepToString(a));
}
} /* Output:
}
/* Output:
[[1, 2, 3], [4, 5, 6]]
*///:~
*/

View File

@ -1,4 +1,4 @@
//: arrays/ParameterizedArrayType.java
// arrays/ParameterizedArrayType.java
// ©2015 MindView LLC: see Copyright.txt
class ClassParameter<T> {
@ -20,4 +20,5 @@ public class ParameterizedArrayType {
ints2 = MethodParameter.f(ints);
doubles2 = MethodParameter.f(doubles);
}
} /* Output: (None) *///:~
}
/* Output: (None) */

View File

@ -1,4 +1,4 @@
//: arrays/PrimitiveConversionDemonstration.java
// arrays/PrimitiveConversionDemonstration.java
// ©2015 MindView LLC: see Copyright.txt
import java.util.*;
import com.mindviewinc.util.*;
@ -14,7 +14,8 @@ public class PrimitiveConversionDemonstration {
new CountingGenerator.Boolean(), 7));
System.out.println(Arrays.toString(c));
}
} /* Output:
}
/* Output:
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]
[true, false, true, false, true, false, true]
*///:~
*/

View File

@ -1,4 +1,4 @@
#: arrays/PythonLists.py
# arrays/PythonLists.py
# ©2015 MindView LLC: see Copyright.txt
aList = [1, 2, 3, 4, 5]
@ -22,4 +22,4 @@ class MyList(list): # Inherit from list
list2 = MyList(aList)
print(type(list2)) # <class '__main__.MyList'>
print(list2.getReversed()) # [8, 7, 6, 5, 4, 3, 2, 1]
#:~
#>

View File

@ -1,4 +1,4 @@
//: arrays/RaggedArray.java
// arrays/RaggedArray.java
// ©2015 MindView LLC: see Copyright.txt
import java.util.*;
@ -14,8 +14,9 @@ public class RaggedArray {
}
System.out.println(Arrays.deepToString(a));
}
} /* Output:
}
/* Output:
[[], [[0], [0], [0, 0, 0, 0]], [[], [0, 0], [0, 0]], [[0,
0, 0], [0], [0, 0, 0, 0]], [[0, 0, 0], [0, 0, 0], [0], []],
[[0], [], [0]]]
*///:~
*/

View File

@ -1,4 +1,4 @@
//: arrays/RandomGeneratorsTest.java
// arrays/RandomGeneratorsTest.java
// ©2015 MindView LLC: see Copyright.txt
import com.mindviewinc.util.*;
@ -6,7 +6,8 @@ public class RandomGeneratorsTest {
public static void main(String[] args) {
GeneratorsTest.test(RandomGenerator.class);
}
} /* Output:
}
/* Output:
Double: 0.73 0.53 0.16 0.19 0.52 0.27 0.26 0.05 0.8 0.76
Float: 0.53 0.16 0.53 0.4 0.49 0.25 0.8 0.11 0.02 0.8
Long: 7674 8804 8950 7826 4322 896 8033 2984 2344 5810
@ -19,4 +20,4 @@ Character: x x E A J J m z M s
Byte: -60 -17 55 -14 -5 115 39 -37 79 115
Boolean: false true false false true true true true true
true
*///:~
*/

View File

@ -1,4 +1,4 @@
//: arrays/Reverse.java
// arrays/Reverse.java
// ©2015 MindView LLC: see Copyright.txt
// The Collections.reverseOrder() Comparator
import java.util.*;
@ -15,7 +15,8 @@ public class Reverse {
print("after sorting:");
print(Arrays.toString(a));
}
} /* Output:
}
/* Output:
before sorting:
[[i = 58, j = 55], [i = 93, j = 61], [i = 61, j = 29]
, [i = 68, j = 0], [i = 22, j = 7], [i = 88, j = 28]
@ -28,4 +29,4 @@ after sorting:
, [i = 51, j = 89], [i = 22, j = 7], [i = 20, j = 58]
, [i = 16, j = 40], [i = 11, j = 22], [i = 9, j = 78]
]
*///:~
*/

View File

@ -1,4 +1,4 @@
//: arrays/StringSorting.java
// arrays/StringSorting.java
// ©2015 MindView LLC: see Copyright.txt
// Sorting an array of Strings.
import java.util.*;
@ -17,7 +17,8 @@ public class StringSorting {
Arrays.sort(sa, String.CASE_INSENSITIVE_ORDER);
print("Case-insensitive sort: " + Arrays.toString(sa));
}
} /* Output:
}
/* Output:
Before sort: [YNzbr, nyGcF, OWZnT, cQrGs, eGZMm, JMRoE,
suEcU, OneOE, dLsmw, HLGEa, hKcxr, EqUCB, bkIna, Mesbt,
WHkjU, rUkZP, gwsqP, zDyCy, RFJQA, HxxHv]
@ -30,4 +31,4 @@ OWZnT, Mesbt, JMRoE, HxxHv, HLGEa, EqUCB]
Case-insensitive sort: [bkIna, cQrGs, dLsmw, eGZMm, EqUCB,
gwsqP, hKcxr, HLGEa, HxxHv, JMRoE, Mesbt, nyGcF, OneOE,
OWZnT, RFJQA, rUkZP, suEcU, WHkjU, YNzbr, zDyCy]
*///:~
*/

View File

@ -1,4 +1,4 @@
//: arrays/TestArrayGeneration.java
// arrays/TestArrayGeneration.java
// ©2015 MindView LLC: see Copyright.txt
// Test the tools that use generators to fill arrays.
import java.util.*;
@ -34,7 +34,8 @@ public class TestArrayGeneration {
Double.class, new RandomGenerator.Double(), size));
print("a8 = " + Arrays.toString(a8));
}
} /* Output:
}
/* Output:
a1 = [true, false, true, false, false, true]
a2 = [104, -79, -76, 126, 33, -64]
a3 = [Z, n, T, c, Q, r]
@ -43,4 +44,4 @@ a5 = [7704, 7383, 7706, 575, 8410, 6342]
a6 = [7674, 8804, 8950, 7826, 4322, 896]
a7 = [0.01, 0.2, 0.4, 0.79, 0.27, 0.45]
a8 = [0.16, 0.87, 0.7, 0.66, 0.87, 0.59]
*///:~
*/

View File

@ -1,4 +1,4 @@
//: arrays/TestGenerated.java
// arrays/TestGenerated.java
// ©2015 MindView LLC: see Copyright.txt
import java.util.*;
import com.mindviewinc.util.*;
@ -13,8 +13,9 @@ public class TestGenerated {
new CountingGenerator.Integer(), 15);
System.out.println(Arrays.toString(b));
}
} /* Output:
}
/* Output:
[9, 8, 7, 6]
[0, 1, 2, 3]
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]
*///:~
*/

View File

@ -1,4 +1,4 @@
//: arrays/ThreeDWithNew.java
// arrays/ThreeDWithNew.java
// Š2015 MindView LLC: see Copyright.txt
import java.util.*;
@ -8,7 +8,8 @@ public class ThreeDWithNew {
int[][][] a = new int[2][2][4];
System.out.println(Arrays.deepToString(a));
}
} /* Output:
}
/* Output:
[[[0, 0, 0, 0], [0, 0, 0, 0]], [[0, 0, 0, 0], [0, 0, 0,
0]]]
*///:~
*/

View File

@ -1,4 +1,4 @@
//: assertions/Assert1.java
// assertions/Assert1.java
// ©2015 MindView LLC: see Copyright.txt
// Non-informative style of assert
// {JVMArgs: -ea} // Must run with -ea
@ -8,9 +8,10 @@ public class Assert1 {
public static void main(String[] args) {
assert false;
}
} /* Output:
}
/* Output:
___[ Error Output ]___
Exception in thread "main" java.lang.AssertionError
at Assert1.main(Assert1.java:8)
___[ Exception is Expected ]___
*///:~
*/

View File

@ -1,4 +1,4 @@
//: assertions/Assert2.java
// assertions/Assert2.java
// ©2015 MindView LLC: see Copyright.txt
// Assert with an informative message
// {JVMArgs: -ea}
@ -8,10 +8,11 @@ public class Assert2 {
public static void main(String[] args) {
assert false: "Here's a message saying what happened";
}
} /* Output:
}
/* Output:
___[ Error Output ]___
Exception in thread "main" java.lang.AssertionError: Here's
a message saying what happened
at Assert2.main(Assert2.java:8)
___[ Exception is Expected ]___
*///:~
*/

View File

@ -1,4 +1,4 @@
//: assertions/LoaderAssertions.java
// assertions/LoaderAssertions.java
// ©2015 MindView LLC: see Copyright.txt
// Using the class loader to enable assertions
// {ThrowsException}
@ -15,11 +15,12 @@ class Loaded {
public void go() {
assert false: "Loaded.go()";
}
} /* Output:
}
/* Output:
___[ Error Output ]___
Exception in thread "main" java.lang.AssertionError:
Loaded.go()
at Loaded.go(LoaderAssertions.java:15)
at LoaderAssertions.main(LoaderAssertions.java:9)
___[ Exception is Expected ]___
*///:~
*/

View File

@ -1,4 +1,4 @@
//: assertions/Queue.java
// assertions/Queue.java
// ©2015 MindView LLC: see Copyright.txt
// Demonstration of Design by Contract (DbC) combined
// with white-box unit testing.
@ -177,7 +177,8 @@ public class Queue {
org.junit.runner.JUnitCore.runClasses(
Queue.WhiteBoxTest.class);
}
} /* Output:
}
/* Output:
testNullPut
put() null item
testCircularity
@ -229,4 +230,4 @@ get() from empty Queue
in = 5, out = 5, full() = false, empty() = true, queue =
[null, null, null, null, null, null, null, null, null,
null]
*///:~
*/

View File

@ -1,4 +1,4 @@
//: com/mindviewinc/atunit/AtUnit.java
// com/mindviewinc/atunit/AtUnit.java
// ©2015 MindView LLC: see Copyright.txt
// An annotation-based unit-test framework.
package com.mindviewinc.atunit;
@ -156,6 +156,7 @@ public class AtUnit implements ProcessFiles.Strategy {
}
}
}
} /* Output:
}
/* Output:
OK (0 tests)
*///:~
*/

View File

@ -1,4 +1,4 @@
//: com/mindviewinc/atunit/ClassNameFinder.java
// com/mindviewinc/atunit/ClassNameFinder.java
// ©2015 MindView LLC: see Copyright.txt
package com.mindviewinc.atunit;
import java.io.*;
@ -73,7 +73,8 @@ public class ClassNameFinder {
for(File klass : Directory.walk(".", ".*\\.class"))
print(thisClass(BinaryFile.read(klass)));
}
} /* Output:
}
/* Output:
com.mindviewinc.atunit.AtUnit$TestMethods
com.mindviewinc.atunit.AtUnit
com.mindviewinc.atunit.ClassNameFinder
@ -81,4 +82,4 @@ com.mindviewinc.atunit.Test
com.mindviewinc.atunit.TestObjectCleanup
com.mindviewinc.atunit.TestObjectCreate
com.mindviewinc.atunit.TestProperty
*///:~
*/

View File

@ -1,4 +1,4 @@
//: com/mindviewinc/atunit/Test.java
// com/mindviewinc/atunit/Test.java
// ©2015 MindView LLC: see Copyright.txt
// The @Test tag.
package com.mindviewinc.atunit;
@ -6,4 +6,4 @@ import java.lang.annotation.*;
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
public @interface Test {} ///:~
public @interface Test {}

View File

@ -1,4 +1,4 @@
//: com/mindviewinc/atunit/TestObjectCleanup.java
// com/mindviewinc/atunit/TestObjectCleanup.java
// ©2015 MindView LLC: see Copyright.txt
// The @Unit @TestObjectCleanup tag.
package com.mindviewinc.atunit;
@ -6,4 +6,4 @@ import java.lang.annotation.*;
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
public @interface TestObjectCleanup {} ///:~
public @interface TestObjectCleanup {}

View File

@ -1,4 +1,4 @@
//: com/mindviewinc/atunit/TestObjectCreate.java
// com/mindviewinc/atunit/TestObjectCreate.java
// ©2015 MindView LLC: see Copyright.txt
// The @Unit @TestObjectCreate tag.
package com.mindviewinc.atunit;
@ -6,4 +6,4 @@ import java.lang.annotation.*;
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
public @interface TestObjectCreate {} ///:~
public @interface TestObjectCreate {}

View File

@ -1,4 +1,4 @@
//: com/mindviewinc/atunit/TestProperty.java
// com/mindviewinc/atunit/TestProperty.java
// ©2015 MindView LLC: see Copyright.txt
// The @Unit @TestProperty tag.
package com.mindviewinc.atunit;
@ -7,4 +7,4 @@ import java.lang.annotation.*;
// Both fields and methods can be tagged as properties:
@Target({ElementType.FIELD, ElementType.METHOD})
@Retention(RetentionPolicy.RUNTIME)
public @interface TestProperty {} ///:~
public @interface TestProperty {}

View File

@ -1,4 +1,4 @@
//: com/mindviewinc/simple/List.java
// com/mindviewinc/simple/List.java
// ©2015 MindView LLC: see Copyright.txt
// Creating a package.
package com.mindviewinc.simple;
@ -7,4 +7,4 @@ public class List {
public List() {
System.out.println("com.mindviewinc.simple.List");
}
} ///:~
}

View File

@ -1,4 +1,4 @@
//: com/mindviewinc/simple/Vector.java
// com/mindviewinc/simple/Vector.java
// Š2015 MindView LLC: see Copyright.txt
// Creating a package.
package com.mindviewinc.simple;
@ -7,4 +7,4 @@ public class Vector {
public Vector() {
System.out.println("com.mindviewinc.simple.Vector");
}
} ///:~
}

View File

@ -1,4 +1,4 @@
//: com/mindviewinc/util/BasicGenerator.java
// com/mindviewinc/util/BasicGenerator.java
// Š2015 MindView LLC: see Copyright.txt
// Automatically create a Generator, given a class
// with a default (no-arg) constructor.
@ -21,4 +21,4 @@ public class BasicGenerator<T> implements Generator<T> {
public static <T> Generator<T> create(Class<T> type) {
return new BasicGenerator<>(type);
}
} ///:~
}

View File

@ -1,4 +1,4 @@
//: com/mindviewinc/util/BinaryFile.java
// com/mindviewinc/util/BinaryFile.java
// ©2015 MindView LLC: see Copyright.txt
// Utility for reading files in binary form.
package com.mindviewinc.util;
@ -17,4 +17,4 @@ public class BinaryFile {
read(String bFile) throws IOException {
return read(new File(bFile).getAbsoluteFile());
}
} ///:~
}

View File

@ -1,4 +1,4 @@
//: com/mindviewinc/util/CollectionData.java
// com/mindviewinc/util/CollectionData.java
// ©2015 MindView LLC: see Copyright.txt
// A Collection filled with data using a generator object.
package com.mindviewinc.util;
@ -14,4 +14,4 @@ public class CollectionData<T> extends ArrayList<T> {
list(Generator<T> gen, int quantity) {
return new CollectionData<>(gen, quantity);
}
} ///:~
}

View File

@ -1,4 +1,4 @@
//: com/mindviewinc/util/ContainerMethodDifferences.java
// com/mindviewinc/util/ContainerMethodDifferences.java
// ©2015 MindView LLC: see Copyright.txt
package com.mindviewinc.util;
import java.lang.reflect.*;
@ -50,7 +50,8 @@ public class ContainerMethodDifferences {
difference(SortedMap.class, Map.class);
difference(TreeMap.class, Map.class);
}
} /* Output:
}
/* Output:
Collection: [add, addAll, clear, contains, containsAll,
equals, forEach, hashCode, isEmpty, iterator,
parallelStream, remove, removeAll, removeIf, retainAll,
@ -105,4 +106,4 @@ pollFirstEntry, lastKey, firstEntry, floorEntry,
comparator, lastEntry]
Interfaces in TreeMap: [NavigableMap, Cloneable,
Serializable]
*///:~
*/

View File

@ -1,4 +1,4 @@
//: com/mindviewinc/util/ConvertTo.java
// com/mindviewinc/util/ConvertTo.java
// ©2015 MindView LLC: see Copyright.txt
package com.mindviewinc.util;
@ -51,4 +51,4 @@ public class ConvertTo {
result[i] = in[i];
return result;
}
} ///:~
}

View File

@ -1,4 +1,4 @@
//: com/mindviewinc/util/CountingGenerator.java
// com/mindviewinc/util/CountingGenerator.java
// ©2015 MindView LLC: see Copyright.txt
// Simple generator implementations.
package com.mindviewinc.util;
@ -82,4 +82,4 @@ public class CountingGenerator {
return result;
}
}
} ///:~
}

View File

@ -1,4 +1,4 @@
//: com/mindviewinc/util/CountingIntegerList.java
// com/mindviewinc/util/CountingIntegerList.java
// ©2015 MindView LLC: see Copyright.txt
// List of any length, containing sample data.
package com.mindviewinc.util;
@ -19,7 +19,8 @@ extends AbstractList<Integer> {
public static void main(String[] args) {
System.out.println(new CountingIntegerList(30));
}
} /* Output:
}
/* Output:
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29]
*///:~
*/

View File

@ -1,4 +1,4 @@
//: com/mindviewinc/util/CountingMapData.java
// com/mindviewinc/util/CountingMapData.java
// ©2015 MindView LLC: see Copyright.txt
// Unlimited-length Map containing sample data.
package com.mindviewinc.util;
@ -51,7 +51,8 @@ extends AbstractMap<Integer,String> {
public static void main(String[] args) {
System.out.println(new CountingMapData(60));
}
} /* Output:
}
/* Output:
{0=A0, 1=B0, 2=C0, 3=D0, 4=E0, 5=F0, 6=G0, 7=H0, 8=I0,
9=J0, 10=K0, 11=L0, 12=M0, 13=N0, 14=O0, 15=P0, 16=Q0,
17=R0, 18=S0, 19=T0, 20=U0, 21=V0, 22=W0, 23=X0, 24=Y0,
@ -60,4 +61,4 @@ extends AbstractMap<Integer,String> {
41=P1, 42=Q1, 43=R1, 44=S1, 45=T1, 46=U1, 47=V1, 48=W1,
49=X1, 50=Y1, 51=Z1, 52=A2, 53=B2, 54=C2, 55=D2, 56=E2,
57=F2, 58=G2, 59=H2}
*///:~
*/

View File

@ -1,4 +1,4 @@
//: com/mindviewinc/util/Countries.java
// com/mindviewinc/util/Countries.java
// ©2015 MindView LLC: see Copyright.txt
// "Flyweight" Maps and Lists of sample data.
package com.mindviewinc.util;
@ -239,7 +239,8 @@ public class Countries {
print(new LinkedList<>(names(6)));
print(capitals().get("BRAZIL"));
}
} /* Output:
}
/* Output:
{ALGERIA=Algiers, ANGOLA=Luanda, BENIN=Porto-Novo,
BOTSWANA=Gaberone, BURKINA FASO=Ouagadougou,
BURUNDI=Bujumbura, CAMEROON=Yaounde, CAPE VERDE=Praia,
@ -256,4 +257,4 @@ CAMEROON, CAPE VERDE, CENTRAL AFRICAN REPUBLIC, CHAD]
[ALGERIA, ANGOLA, BENIN, BOTSWANA, BURKINA FASO, BURUNDI]
[ALGERIA, ANGOLA, BENIN, BOTSWANA, BURKINA FASO, BURUNDI]
Brasilia
*///:~
*/

View File

@ -1,4 +1,4 @@
//: com/mindviewinc/util/DaemonThreadFactory.java
// com/mindviewinc/util/DaemonThreadFactory.java
// ©2015 MindView LLC: see Copyright.txt
package com.mindviewinc.util;
import java.util.concurrent.*;
@ -10,4 +10,4 @@ public class DaemonThreadFactory implements ThreadFactory {
t.setDaemon(true);
return t;
}
} ///:~
}

View File

@ -1,4 +1,4 @@
//: com/mindviewinc/util/DaemonThreadPoolExecutor.java
// com/mindviewinc/util/DaemonThreadPoolExecutor.java
// ©2015 MindView LLC: see Copyright.txt
package com.mindviewinc.util;
import java.util.concurrent.*;
@ -10,4 +10,4 @@ extends ThreadPoolExecutor {
new SynchronousQueue<>(),
new DaemonThreadFactory());
}
} ///:~
}

View File

@ -1,4 +1,4 @@
//: com/mindviewinc/util/Deque.java
// com/mindviewinc/util/Deque.java
// ©2015 MindView LLC: see Copyright.txt
// Creating a Deque from a LinkedList.
package com.mindviewinc.util;
@ -16,4 +16,4 @@ public class Deque<T> {
@Override
public String toString() { return deque.toString(); }
// And other methods as necessary...
} ///:~
}

View File

@ -1,4 +1,4 @@
//: com/mindviewinc/util/Directory.java
// com/mindviewinc/util/Directory.java
// ©2015 MindView LLC: see Copyright.txt
// Produce a sequence of File objects that match a
// regular expression in either a local directory,
@ -77,7 +77,8 @@ public final class Directory {
for(String arg : args)
System.out.println(walk(arg));
}
} /* Output: (First 20 Lines)
}
/* Output: (First 20 Lines)
dirs: []
files: [
.\BasicGenerator.class
@ -98,4 +99,4 @@ files: [
.\CountingGenerator$Double.class
.\CountingGenerator$Float.class
...
*///:~
*/

View File

@ -1,4 +1,4 @@
//: com/mindviewinc/util/Enums.java
// com/mindviewinc/util/Enums.java
// ©2015 MindView LLC: see Copyright.txt
package com.mindviewinc.util;
import java.util.*;
@ -11,4 +11,4 @@ public class Enums {
public static <T> T random(T[] values) {
return values[rand.nextInt(values.length)];
}
} ///:~
}

View File

@ -1,4 +1,4 @@
//: com/mindviewinc/util/FiveTuple.java
// com/mindviewinc/util/FiveTuple.java
// ©2015 MindView LLC: see Copyright.txt
package com.mindviewinc.util;
@ -14,4 +14,4 @@ extends FourTuple<A,B,C,D> {
return "(" + first + ", " + second + ", " +
third + ", " + fourth + ", " + fifth + ")";
}
} ///:~
}

View File

@ -1,8 +1,9 @@
//: com/mindviewinc/util/FourTuple.java
// com/mindviewinc/util/FourTuple.java
// ©2015 MindView LLC: see Copyright.txt
package com.mindviewinc.util;
public class FourTuple<A,B,C,D> extends ThreeTuple<A,B,C> {
public class FourTuple<A, B, C, D>
extends ThreeTuple<A, B, C> {
public final D fourth;
public FourTuple(A a, B b, C c, D d) {
super(a, b, c);
@ -13,4 +14,4 @@ public class FourTuple<A,B,C,D> extends ThreeTuple<A,B,C> {
return "(" + first + ", " + second + ", " +
third + ", " + fourth + ")";
}
} ///:~
}

View File

@ -1,4 +1,4 @@
//: com/mindviewinc/util/Generated.java
// com/mindviewinc/util/Generated.java
// ©2015 MindView LLC: see Copyright.txt
package com.mindviewinc.util;
@ -15,4 +15,4 @@ public class Generated {
(T[])java.lang.reflect.Array.newInstance(type, size);
return new CollectionData<>(gen, size).toArray(a);
}
} ///:~
}

View File

@ -1,5 +1,5 @@
//: com/mindviewinc/util/Generator.java
// com/mindviewinc/util/Generator.java
// ©2015 MindView LLC: see Copyright.txt
// A generic interface.
package com.mindviewinc.util;
public interface Generator<T> { T next(); } ///:~
public interface Generator<T> { T next(); }

View File

@ -1,4 +1,4 @@
//: com/mindviewinc/util/Hex.java
// com/mindviewinc/util/Hex.java
// ©2015 MindView LLC: see Copyright.txt
package com.mindviewinc.util;
import java.io.*;
@ -26,7 +26,8 @@ public class Hex {
System.out.println(
format(BinaryFile.read(new File(args[0]))));
}
} /* Output: (First 6 Lines)
}
/* Output: (First 6 Lines)
00000: CA FE BA BE 00 00 00 34 00 53 0A 00 05 00 22 07
00010: 00 23 0A 00 02 00 22 08 00 24 07 00 25 0A 00 26
00020: 00 27 0A 00 28 00 29 0A 00 02 00 2A 08 00 2B 0A
@ -34,4 +35,4 @@ public class Hex {
00040: 31 08 00 32 0A 00 33 00 34 0A 00 15 00 35 0A 00
00050: 36 00 37 07 00 38 0A 00 12 00 39 0A 00 33 00 3A
...
*///:~
*/

View File

@ -1,4 +1,4 @@
//: com/mindviewinc/util/MapData.java
// com/mindviewinc/util/MapData.java
// ©2015 MindView LLC: see Copyright.txt
// A Map filled with data using a generator object.
package com.mindviewinc.util;
@ -58,4 +58,4 @@ public class MapData<K,V> extends LinkedHashMap<K,V> {
map(Iterable<K> genK, V value) {
return new MapData<>(genK, value);
}
} ///:~
}

View File

@ -1,4 +1,4 @@
//: com/mindviewinc/util/New.java
// com/mindviewinc/util/New.java
// ©2015 MindView LLC: see Copyright.txt
// Utilities to simplify generic container creation
// by using type argument inference.
@ -29,4 +29,5 @@ public class New {
Set<String> ss = New.set();
Queue<String> qs = New.queue();
}
} /* Output: (None) *///:~
}
/* Output: (None) */

View File

@ -1,4 +1,4 @@
//: com/mindviewinc/util/Null.java
// com/mindviewinc/util/Null.java
// ©2015 MindView LLC: see Copyright.txt
package com.mindviewinc.util;
public interface Null {} ///:~
public interface Null {}

View File

@ -1,4 +1,4 @@
//: com/mindviewinc/util/OSExecute.java
// com/mindviewinc/util/OSExecute.java
// ©2015 MindView LLC: see Copyright.txt
// Run an operating system command
// and send the output to the console.
@ -36,4 +36,4 @@ public class OSExecute {
throw new OSExecuteException("Errors executing " +
command);
}
} ///:~
}

View File

@ -1,7 +1,7 @@
//: com/mindviewinc/util/OSExecuteException.java
// com/mindviewinc/util/OSExecuteException.java
// ©2015 MindView LLC: see Copyright.txt
package com.mindviewinc.util;
public class OSExecuteException extends RuntimeException {
public OSExecuteException(String why) { super(why); }
} ///:~
}

View File

@ -1,4 +1,4 @@
//: com/mindviewinc/util/PPrint.java
// com/mindviewinc/util/PPrint.java
// ©2015 MindView LLC: see Copyright.txt
// Pretty-printer for collections
package com.mindviewinc.util;
@ -24,4 +24,4 @@ public class PPrint {
public static void pprint(Object[] c) {
System.out.println(pformat(Arrays.asList(c)));
}
} ///:~
}

View File

@ -1,4 +1,4 @@
//: com/mindviewinc/util/Pair.java
// com/mindviewinc/util/Pair.java
// ©2015 MindView LLC: see Copyright.txt
package com.mindviewinc.util;
@ -9,4 +9,4 @@ public class Pair<K,V> {
key = k;
value = v;
}
} ///:~
}

View File

@ -1,4 +1,4 @@
//: com/mindviewinc/util/Print.java
// com/mindviewinc/util/Print.java
// ©2015 MindView LLC: see Copyright.txt
// Print methods that can be used without
// qualifiers, using static imports:
@ -23,4 +23,4 @@ public class Print {
printf(String format, Object... args) {
return System.out.printf(format, args);
}
} ///:~
}

View File

@ -1,4 +1,4 @@
//: com/mindviewinc/util/PrintArray.java
// com/mindviewinc/util/PrintArray.java
// ©2015 MindView LLC: see Copyright.txt
// Display an array of double
package com.mindviewinc.util;
@ -12,4 +12,4 @@ public class PrintArray {
}
System.out.println();
}
} ///:~
}

View File

@ -1,4 +1,4 @@
//: com/mindviewinc/util/ProcessFiles.java
// com/mindviewinc/util/ProcessFiles.java
// ©2015 MindView LLC: see Copyright.txt
// {ValidateByHand}
package com.mindviewinc.util;
@ -46,4 +46,5 @@ public class ProcessFiles {
new ProcessFiles(file -> System.out.println(file),
"java").start(args);
}
} /* Output: (Execute to see) *///:~
}
/* Output: (Execute to see) */

View File

@ -1,4 +1,4 @@
//: com/mindviewinc/util/RandomGenerator.java
// com/mindviewinc/util/RandomGenerator.java
// ©2015 MindView LLC: see Copyright.txt
// Generators that produce random values.
package com.mindviewinc.util;
@ -79,4 +79,4 @@ public class RandomGenerator {
return ((double)trimmed) / 100;
}
}
} ///:~
}

View File

@ -1,4 +1,4 @@
//: com/mindviewinc/util/Range.java
// com/mindviewinc/util/Range.java
// ©2015 MindView LLC: see Copyright.txt
// Array creation methods that can be used without
// qualifiers, using static imports:
@ -28,4 +28,4 @@ public class Range {
result[i] = start + (i * step);
return result;
}
} ///:~
}

Some files were not shown because too many files have changed in this diff Show More