Skip to content

Commit

Permalink
docs: migrate Array2DUtil and BaseUtil javadoc to markdown
Browse files Browse the repository at this point in the history
  • Loading branch information
Flashky committed Dec 10, 2024
1 parent 94f916d commit 14afd70
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 49 deletions.
14 changes: 5 additions & 9 deletions src/main/java/com/adventofcode/flashk/common/Array2DUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@ public class Array2DUtil {

private Array2DUtil() {}

/**
* Transposes the given 2D array.
* @param array the array to transpose.
* @return a new 2D array that is the transpose of the given array.
*/
/// Transposes the given 2D array.
/// @param array the array to transpose.
/// @return a new 2D char array that is the transpose of the given array.
public static char[][] transpose(char[][] array) {
int rows = array.length;
int cols = array[0].length;
Expand All @@ -21,10 +19,8 @@ public static char[][] transpose(char[][] array) {
return transposedArray;
}

/**
* Paints the given array.
* @param map the array to paint
*/
/// Paints the given 2D array.
/// @param map the array to paint.
public static void paint(char[][] map) {

System.out.println();
Expand Down
72 changes: 32 additions & 40 deletions src/main/java/com/adventofcode/flashk/common/BaseUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,49 +13,41 @@ public static Integer binaryToDecInteger(String bin) {
public static Long binaryToDec(String bin) {
return Long.parseLong(bin, 2);
}

/**
* Converts from hexadecimal to binary.
* <p>
* Any hexadecimal number can be represented with 4 binary digits (<code>6 hex = 0110 bin</code>).
* </p>
* <p>
* Leading zero digits won't be included in the converted number.
* Use {@link #hexToBinaryPadLeft(String)} if they need to be included.
* </p>
* <p>
* <b>Examples:</b>
* </p>
* <pre>
* BaseUtil.hexToBinary("6") = "110"
* </pre>
* @param hex the hexadecimal code
* @return the translated binary code
* @see #hexToBinaryPadLeft(String)
*/

/// Converts from hexadecimal to binary.
///
/// Any hexadecimal number can be represented with 4 binary digits (`6 hex = 0110 bin`).
///
/// Leading zero digits won't be included in the converted number.
/// Use [hexToBinaryPadLeft][#hexToBinaryPadLeft(String)] if they need to be included.
///
/// **Examples:**
///
/// ```java
/// BaseUtil.hexToBinary("6") // returns "110"
/// ```
/// @param hex the hexadecimal code
/// @return the translated binary code
/// @see #hexToBinaryPadLeft(String)
public static String hexToBinary(String hex) {
return new BigInteger(hex, 16).toString(2);
}

/**
* Converts from hexadecimal to binary and adds zero padding at the leading.
* <p>
* Any hexadecimal number can be represented with 4 binary digits (<code>6 hex = 0110 bin</code>).
* </p>
* </p>
* Leading zero digits will be included in the converted number.
* Use {@link #hexToBinary(String)} if they need to be removed from the result.
* </p>
* <p>
* <b>Examples:</b>
* </p>
* <pre>
* BaseUtil.hexToBinaryPadLeft("6") = "0110"
* </pre>
* @param hex the hexadecimal code
* @return the translated binary code, it will always have a multiple of 4 digits.
* @see #hexToBinary(String)
*/

/// Converts from hexadecimal to binary and adds zero padding at the leading.
///
/// Any hexadecimal number can be represented with 4 binary digits (`6 hex = 0110 bin`).
///
/// Leading zero digits will be included in the converted number.
/// Use [hexToBinary][#hexToBinary(String)] if they need to be removed from the result.
///
/// **Examples:**
///
/// ```java
/// BaseUtil.hexToBinaryPadLeft("6"); // returns "0110"
/// ```
/// @param hex the hexadecimal code
/// @return the translated binary code, it will always have a multiple of 4 digits.
/// @see #hexToBinary(String)
public static String hexToBinaryPadLeft(String hex) {
String unpaddedBinary = BaseUtil.hexToBinary(hex);
int size = hex.length() * 4;
Expand Down

0 comments on commit 14afd70

Please sign in to comment.