Skip to content

Commit f409fb1

Browse files
committed
docs: migrate Javadoc to Markdown #53
1 parent 90c4cb4 commit f409fb1

File tree

5 files changed

+202
-270
lines changed

5 files changed

+202
-270
lines changed

src/main/java/com/adventofcode/flashk/common/JsonUtil.java

Lines changed: 27 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,18 @@ public final class JsonUtil {
1010

1111
private JsonUtil() {}
1212

13-
/**
14-
* Builds a json tree.
15-
* <p>Input accepts basic json and even simple arrays such as:</p>
16-
* <pre>
17-
* [4]
18-
* [1,1,3,1,1]
19-
* [[[],[],8,3],[10]]
20-
* [[2],[3,[[],[1]],[],[0,[10,7]]],[[]],[7,[6],8,[9,0],[2]]]
21-
* </pre>
22-
* <p>This is useful for AoC puzzles such as 2021 day 18 and 2022 day 13.</p>
23-
* @param input the input string
24-
* @return The parsed <code>JsonNode</code> Jackson based tree.
25-
*/
13+
/// Builds a json tree.
14+
///
15+
/// Input accepts basic json and even simple arrays such as:
16+
/// ```
17+
/// [4]
18+
/// [1,1,3,1,1]
19+
/// [[[],[],8,3],[10]]
20+
/// [[2],[3,[[],[1]],[],[0,[10,7]]],[[]],[7,[6],8,[9,0],[2]]]
21+
/// ```
22+
/// This is useful for AoC puzzles such as 2021 day 18 and 2022 day 13.
23+
/// @param input the input string
24+
/// @return The parsed `JsonNode` Jackson based tree.
2625
public static JsonNode buildTree(String input) {
2726
try {
2827
ObjectMapper objectMapper = new ObjectMapper();
@@ -32,28 +31,25 @@ public static JsonNode buildTree(String input) {
3231
}
3332
}
3433

35-
/**
36-
* Builds a json tree using Gson library.
37-
* <p>Input accepts basic json and even simple arrays such as:</p>
38-
* <pre>
39-
* [4]
40-
* [1,1,3,1,1]
41-
* [[[],[],8,3],[10]]
42-
* [[2],[3,[[],[1]],[],[0,[10,7]]],[[]],[7,[6],8,[9,0],[2]]]
43-
* </pre>
44-
* <p>This is useful for AoC puzzles such as 2021 day 18 and 2022 day 13.</p>
45-
* @param input the input string
46-
* @return The parsed <code>JsonElement</code> Gson based tree.
47-
*/
34+
/// Builds a json tree using Gson library.
35+
///
36+
/// Input accepts basic json and even simple arrays such as:
37+
/// ```
38+
/// [4]
39+
/// [1,1,3,1,1]
40+
/// [[[],[],8,3],[10]]
41+
/// [[2],[3,[[],[1]],[],[0,[10,7]]],[[]],[7,[6],8,[9,0],[2]]]
42+
/// ```
43+
/// This is useful for AoC puzzles such as 2021 day 18 and 2022 day 13.
44+
/// @param input the input string
45+
/// @return The parsed `JsonElement` Gson based tree.
4846
public static JsonElement buildGsonTree(String input) {
4947
return new Gson().fromJson(input, JsonElement.class);
5048
}
5149

52-
/**
53-
* Checks if a Gson <code>JsonElement</code> is an integer.
54-
* @param element the element to check
55-
* @return true if element is a primitive integer. False otherwise
56-
*/
50+
/// Checks if a Gson `JsonElement` is an integer.
51+
/// @param element the element to check
52+
/// @return true if element is a primitive integer. False otherwise
5753
public static boolean isInt(JsonElement element) {
5854
return element.isJsonPrimitive() && element.getAsJsonPrimitive().isNumber();
5955
}

src/main/java/com/adventofcode/flashk/common/MathUtil.java

Lines changed: 60 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,18 @@ public final class MathUtil {
88

99
private MathUtil() {}
1010

11-
/**
12-
* Applies the sums of a function over a range of values.
13-
* Example:
14-
* <pre>
15-
* summation(1, 5, i -> i * i) // returns 55 (1^2 + 2^2 + 3^2 + 4^2 + 5^2)
16-
* summation(1, 5, i -> i) // returns 15 (1 + 2 + 3 + 4 + 5)
17-
* summation(0, 0, i -> i) // returns 0 (0)
18-
* </pre>
19-
* @param min the minimum value to start the summation. Must be smaller or equal to max.
20-
* @param max the maximum value to end the summation. Must be greater or equal to min.
21-
* @param summationFunction the function to apply to each value in the range before summing them up.
22-
* @return the summation of the function applied to each value in the range
23-
* @throws IllegalArgumentException if min is greater than max
24-
*/
11+
/// Applies the sums of a function over a range of values.
12+
/// Example:
13+
/// ```
14+
/// summation(1, 5, i -> i * i) // returns 55 (1^2 + 2^2 + 3^2 + 4^2 + 5^2)
15+
/// summation(1, 5, i -> i) // returns 15 (1 + 2 + 3 + 4 + 5)
16+
/// summation(0, 0, i -> i) // returns 0 (0)
17+
/// ```
18+
/// @param min the minimum value to start the summation. Must be smaller or equal to max.
19+
/// @param max the maximum value to end the summation. Must be greater or equal to min.
20+
/// @param summationFunction the function to apply to each value in the range before summing them up.
21+
/// @return the summation of the function applied to each value in the range
22+
/// @throws IllegalArgumentException if min is greater than max
2523
public static int summation(int min, int max, IntFunction<Integer> summationFunction) {
2624

2725
if(min > max) {
@@ -37,20 +35,18 @@ public static int summation(int min, int max, IntFunction<Integer> summationFunc
3735
return sum;
3836
}
3937

40-
/**
41-
* Applies the sums of a function over a range of values.
42-
* Example:
43-
* <pre>
44-
* summation(1, 5, i -> i * i) // returns 55 (1^2 + 2^2 + 3^2 + 4^2 + 5^2)
45-
* summation(1, 5, i -> i) // returns 15 (1 + 2 + 3 + 4 + 5)
46-
* summation(0, 0, i -> i) // returns 0 (0)
47-
* </pre>
48-
* @param min the minimum value to start the summation. Must be smaller or equal to max.
49-
* @param max the maximum value to end the summation. Must be greater or equal to min.
50-
* @param summationFunction the function to apply to each value in the range before summing them up.
51-
* @return the summation of the function applied to each value in the range
52-
* @throws IllegalArgumentException if min is greater than max
53-
*/
38+
/// Applies the sums of a function over a range of values.
39+
/// Example:
40+
/// ```
41+
/// summation(1, 5, i -> i * i) // returns 55 (1^2 + 2^2 + 3^2 + 4^2 + 5^2)
42+
/// summation(1, 5, i -> i) // returns 15 (1 + 2 + 3 + 4 + 5)
43+
/// summation(0, 0, i -> i) // returns 0 (0)
44+
/// ```
45+
/// @param min the minimum value to start the summation. Must be smaller or equal to max.
46+
/// @param max the maximum value to end the summation. Must be greater or equal to min.
47+
/// @param summationFunction the function to apply to each value in the range before summing them up.
48+
/// @return the summation of the function applied to each value in the range
49+
/// @throws IllegalArgumentException if min is greater than max
5450
public static long summation(long min, long max, LongFunction<Long> summationFunction) {
5551

5652
if(min > max) {
@@ -66,20 +62,18 @@ public static long summation(long min, long max, LongFunction<Long> summationFun
6662
return sum;
6763
}
6864

69-
/**
70-
* Applies the sums of a function over a range of values.
71-
* Example:
72-
* <pre>
73-
* summation(1, 5, i -> i * i) // returns 55 (1^2 + 2^2 + 3^2 + 4^2 + 5^2)
74-
* summation(1, 5, i -> i) // returns 15 (1 + 2 + 3 + 4 + 5)
75-
* summation(0, 0, i -> i) // returns 0 (0)
76-
* </pre>
77-
* @param min the minimum value to start the summation. Must be smaller or equal to max.
78-
* @param max the maximum value to end the summation. Must be greater or equal to min.
79-
* @param summationFunction the function to apply to each value in the range before summing them up.
80-
* @return the summation of the function applied to each value in the range
81-
* @throws IllegalArgumentException if min is greater than max
82-
*/
65+
/// Applies the sums of a function over a range of values.
66+
/// Example:
67+
/// ```
68+
/// summation(1, 5, i -> i * i) // returns 55 (1^2 + 2^2 + 3^2 + 4^2 + 5^2)
69+
/// summation(1, 5, i -> i) // returns 15 (1 + 2 + 3 + 4 + 5)
70+
/// summation(0, 0, i -> i) // returns 0 (0)
71+
/// ```
72+
/// @param min the minimum value to start the summation. Must be smaller or equal to max.
73+
/// @param max the maximum value to end the summation. Must be greater or equal to min.
74+
/// @param summationFunction the function to apply to each value in the range before summing them up.
75+
/// @return the summation of the function applied to each value in the range
76+
/// @throws IllegalArgumentException if min is greater than max
8377
public static double summation(double min, double max, DoubleFunction<Double> summationFunction) {
8478

8579
if(min > max) {
@@ -95,20 +89,18 @@ public static double summation(double min, double max, DoubleFunction<Double> su
9589
return sum;
9690
}
9791

98-
/**
99-
* Applies the product of a function over a range of values.
100-
* Example:
101-
* <pre>
102-
* product(1, 5, i -> i * i) // returns 14400 (1^2 * 2^2 * 3^2 * 4^2 * 5^2)
103-
* product(1, 5, i -> i) // returns 120 (1 * 2 * 3 * 4 * 5)
104-
* product(0, 0, i -> i) // returns 0 (0)
105-
* </pre>
106-
* @param min the minimum value to start the summation. Must be smaller or equal to max.
107-
* @param max the maximum value to end the summation. Must be greater or equal to min.
108-
* @param productFunction the function to apply to each value in the range before summing them up.
109-
* @return the summation of the function applied to each value in the range
110-
* @throws IllegalArgumentException if min is greater than max
111-
*/
92+
/// Applies the product of a function over a range of values.
93+
/// Example:
94+
/// ```
95+
/// product(1, 5, i -> i * i) // returns 14400 (1^2 * 2^2 * 3^2 * 4^2 * 5^2)
96+
/// product(1, 5, i -> i) // returns 120 (1 * 2 * 3 * 4 * 5)
97+
/// product(0, 0, i -> i) // returns 0 (0)
98+
/// ```
99+
/// @param min the minimum value to start the summation. Must be smaller or equal to max.
100+
/// @param max the maximum value to end the summation. Must be greater or equal to min.
101+
/// @param productFunction the function to apply to each value in the range before summing them up.
102+
/// @return the summation of the function applied to each value in the range
103+
/// @throws IllegalArgumentException if min is greater than max
112104
public static int product(int min, int max, IntFunction<Integer> productFunction) {
113105

114106
if(min > max) {
@@ -124,20 +116,18 @@ public static int product(int min, int max, IntFunction<Integer> productFunction
124116
return product;
125117
}
126118

127-
/**
128-
* Applies the product of a function over a range of values.
129-
* Example:
130-
* <pre>
131-
* product(1, 5, i -> i * i) // returns 14400 (1^2 * 2^2 * 3^2 * 4^2 * 5^2)
132-
* product(1, 5, i -> i) // returns 120 (1 * 2 * 3 * 4 * 5)
133-
* product(0, 0, i -> i) // returns 0 (0)
134-
* </pre>
135-
* @param min the minimum value to start the summation. Must be smaller or equal to max.
136-
* @param max the maximum value to end the summation. Must be greater or equal to min.
137-
* @param productFunction the function to apply to each value in the range before summing them up.
138-
* @return the summation of the function applied to each value in the range
139-
* @throws IllegalArgumentException if min is greater than max
140-
*/
119+
/// Applies the product of a function over a range of values.
120+
/// Example:
121+
/// ```
122+
/// product(1, 5, i -> i * i) // returns 14400 (1^2 * 2^2 * 3^2 * 4^2 * 5^2)
123+
/// product(1, 5, i -> i) // returns 120 (1 * 2 * 3 * 4 * 5)
124+
/// product(0, 0, i -> i) // returns 0 (0)
125+
/// ```
126+
/// @param min the minimum value to start the summation. Must be smaller or equal to max.
127+
/// @param max the maximum value to end the summation. Must be greater or equal to min.
128+
/// @param productFunction the function to apply to each value in the range before summing them up.
129+
/// @return the summation of the function applied to each value in the range
130+
/// @throws IllegalArgumentException if min is greater than max
141131
public static long product(long min, long max, LongFunction<Long> productFunction) {
142132

143133
if(min > max) {

0 commit comments

Comments
 (0)