From 8002137b764de30918bfc1375fd816034edc3f16 Mon Sep 17 00:00:00 2001 From: Ayoub Chegraoui Date: Sun, 15 Oct 2023 15:02:24 +0100 Subject: [PATCH] Fixed some typos and links for javadoc, and some refactoring (#4755) --- .../com/thealgorithms/ciphers/AESEncryption.java | 2 +- .../thealgorithms/conversions/AnyBaseToDecimal.java | 2 +- .../thealgorithms/conversions/DecimalToAnyBase.java | 2 +- .../thealgorithms/conversions/RgbHsvConversion.java | 4 ++-- .../java/com/thealgorithms/geometry/GrahamScan.java | 12 +++++------- 5 files changed, 10 insertions(+), 12 deletions(-) diff --git a/src/main/java/com/thealgorithms/ciphers/AESEncryption.java b/src/main/java/com/thealgorithms/ciphers/AESEncryption.java index 2b12aeaa..169fc10e 100644 --- a/src/main/java/com/thealgorithms/ciphers/AESEncryption.java +++ b/src/main/java/com/thealgorithms/ciphers/AESEncryption.java @@ -19,7 +19,7 @@ public class AESEncryption { /** * 1. Generate a plain text for encryption 2. Get a secret key (printed in - * hexadecimal form). In actual use this must by encrypted and kept safe. + * hexadecimal form). In actual use this must be encrypted and kept safe. * The same key is required for decryption. */ public static void main(String[] args) throws Exception { diff --git a/src/main/java/com/thealgorithms/conversions/AnyBaseToDecimal.java b/src/main/java/com/thealgorithms/conversions/AnyBaseToDecimal.java index 837b3530..20f15bc2 100644 --- a/src/main/java/com/thealgorithms/conversions/AnyBaseToDecimal.java +++ b/src/main/java/com/thealgorithms/conversions/AnyBaseToDecimal.java @@ -1,7 +1,7 @@ package com.thealgorithms.conversions; /** - * @author Varun Upadhyay (https://github.com/varunu28) + * @author Varun Upadhyay (...) */ // Driver program public class AnyBaseToDecimal { diff --git a/src/main/java/com/thealgorithms/conversions/DecimalToAnyBase.java b/src/main/java/com/thealgorithms/conversions/DecimalToAnyBase.java index 31ef2bff..2d0223a4 100644 --- a/src/main/java/com/thealgorithms/conversions/DecimalToAnyBase.java +++ b/src/main/java/com/thealgorithms/conversions/DecimalToAnyBase.java @@ -5,7 +5,7 @@ import java.io.InputStreamReader; import java.util.ArrayList; /** - * @author Varun Upadhyay (https://github.com/varunu28) + * @author Varun Upadhyay (...) */ // Driver Program public class DecimalToAnyBase { diff --git a/src/main/java/com/thealgorithms/conversions/RgbHsvConversion.java b/src/main/java/com/thealgorithms/conversions/RgbHsvConversion.java index ca64c3ff..65cb00fc 100644 --- a/src/main/java/com/thealgorithms/conversions/RgbHsvConversion.java +++ b/src/main/java/com/thealgorithms/conversions/RgbHsvConversion.java @@ -10,8 +10,8 @@ import java.util.Arrays; * models how colors appear under light. In it, colors are represented using * three components: hue, saturation and (brightness-)value. This class provides * methods for converting colors from one representation to the other. - * (description adapted from https://en.wikipedia.org/wiki/RGB_color_model and - * https://en.wikipedia.org/wiki/HSL_and_HSV). + * (description adapted from [1] and + * [2]). */ public class RgbHsvConversion { diff --git a/src/main/java/com/thealgorithms/geometry/GrahamScan.java b/src/main/java/com/thealgorithms/geometry/GrahamScan.java index 3325a658..9122c6f6 100644 --- a/src/main/java/com/thealgorithms/geometry/GrahamScan.java +++ b/src/main/java/com/thealgorithms/geometry/GrahamScan.java @@ -6,7 +6,7 @@ import java.util.Stack; /* * A Java program that computes the convex hull using the Graham Scan algorithm - * In the best case, time complexity is O(n), while in the worst case, it is log(n). + * In the best case, time complexity is O(n), while in the worst case, it is O(nlog(n)). * O(n) space complexity * * This algorithm is only applicable to integral coordinates. @@ -106,16 +106,14 @@ public class GrahamScan { /** * @param p2 Co-ordinate of point to compare to. - * This function will compare the points and will return a positive integer it the + * This function will compare the points and will return a positive integer if the * point is greater than the argument point and a negative integer if the point is * less than the argument point. */ public int compareTo(Point p2) { - if (this.y < p2.y) return -1; - if (this.y > p2.y) return +1; - if (this.x < p2.x) return -1; - if (this.x > p2.x) return +1; - return 0; + int res = Integer.compare(this.y, p2.y); + if (res == 0) res = Integer.compare(this.x, p2.x); + return res; } /**