mirror of
https://github.com/TheAlgorithms/Java.git
synced 2025-07-24 04:54:21 +08:00
style: enable MethodName
in CheckStyle (#5182)
enabled: MethodName in CheckStyle
This commit is contained in:

committed by
GitHub

parent
ea4dc15a24
commit
295e7436b1
@ -11,7 +11,7 @@ public final class CountChar {
|
||||
* @return number of character in the specified string
|
||||
*/
|
||||
|
||||
public static int CountCharacters(String str) {
|
||||
public static int countCharacters(String str) {
|
||||
return str.replaceAll("\\s", "").length();
|
||||
}
|
||||
}
|
||||
|
@ -13,11 +13,11 @@ public final class KMP {
|
||||
public static void main(String[] args) {
|
||||
final String haystack = "AAAAABAAABA"; // This is the full string
|
||||
final String needle = "AAAA"; // This is the substring that we want to find
|
||||
KMPmatcher(haystack, needle);
|
||||
kmpMatcher(haystack, needle);
|
||||
}
|
||||
|
||||
// find the starting index in string haystack[] that matches the search word P[]
|
||||
public static void KMPmatcher(final String haystack, final String needle) {
|
||||
public static void kmpMatcher(final String haystack, final String needle) {
|
||||
final int m = haystack.length();
|
||||
final int n = needle.length();
|
||||
final int[] pi = computePrefixFunction(needle);
|
||||
|
@ -33,7 +33,7 @@ public final class KochSnowflake {
|
||||
ArrayList<Vector2> vectors = new ArrayList<Vector2>();
|
||||
vectors.add(new Vector2(0, 0));
|
||||
vectors.add(new Vector2(1, 0));
|
||||
ArrayList<Vector2> result = Iterate(vectors, 1);
|
||||
ArrayList<Vector2> result = iterate(vectors, 1);
|
||||
|
||||
assert result.get(0).x == 0;
|
||||
assert result.get(0).y == 0;
|
||||
@ -54,7 +54,7 @@ public final class KochSnowflake {
|
||||
int imageWidth = 600;
|
||||
double offsetX = imageWidth / 10.;
|
||||
double offsetY = imageWidth / 3.7;
|
||||
BufferedImage image = GetKochSnowflake(imageWidth, 5);
|
||||
BufferedImage image = getKochSnowflake(imageWidth, 5);
|
||||
|
||||
// The background should be white
|
||||
assert image.getRGB(0, 0) == new Color(255, 255, 255).getRGB();
|
||||
@ -80,10 +80,10 @@ public final class KochSnowflake {
|
||||
* @param steps The number of iterations.
|
||||
* @return The transformed vectors after the iteration-steps.
|
||||
*/
|
||||
public static ArrayList<Vector2> Iterate(ArrayList<Vector2> initialVectors, int steps) {
|
||||
public static ArrayList<Vector2> iterate(ArrayList<Vector2> initialVectors, int steps) {
|
||||
ArrayList<Vector2> vectors = initialVectors;
|
||||
for (int i = 0; i < steps; i++) {
|
||||
vectors = IterationStep(vectors);
|
||||
vectors = iterationStep(vectors);
|
||||
}
|
||||
|
||||
return vectors;
|
||||
@ -96,7 +96,7 @@ public final class KochSnowflake {
|
||||
* @param steps The number of iterations.
|
||||
* @return The image of the rendered Koch snowflake.
|
||||
*/
|
||||
public static BufferedImage GetKochSnowflake(int imageWidth, int steps) {
|
||||
public static BufferedImage getKochSnowflake(int imageWidth, int steps) {
|
||||
if (imageWidth <= 0) {
|
||||
throw new IllegalArgumentException("imageWidth should be greater than zero");
|
||||
}
|
||||
@ -111,8 +111,8 @@ public final class KochSnowflake {
|
||||
initialVectors.add(vector2);
|
||||
initialVectors.add(vector3);
|
||||
initialVectors.add(vector1);
|
||||
ArrayList<Vector2> vectors = Iterate(initialVectors, steps);
|
||||
return GetImage(vectors, imageWidth, imageWidth);
|
||||
ArrayList<Vector2> vectors = iterate(initialVectors, steps);
|
||||
return getImage(vectors, imageWidth, imageWidth);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -125,7 +125,7 @@ public final class KochSnowflake {
|
||||
* applied.
|
||||
* @return The transformed vectors after the iteration-step.
|
||||
*/
|
||||
private static ArrayList<Vector2> IterationStep(ArrayList<Vector2> vectors) {
|
||||
private static ArrayList<Vector2> iterationStep(ArrayList<Vector2> vectors) {
|
||||
ArrayList<Vector2> newVectors = new ArrayList<Vector2>();
|
||||
for (int i = 0; i < vectors.size() - 1; i++) {
|
||||
Vector2 startVector = vectors.get(i);
|
||||
@ -149,7 +149,7 @@ public final class KochSnowflake {
|
||||
* @param imageHeight The height of the rendered image.
|
||||
* @return The image of the rendered edges.
|
||||
*/
|
||||
private static BufferedImage GetImage(ArrayList<Vector2> vectors, int imageWidth, int imageHeight) {
|
||||
private static BufferedImage getImage(ArrayList<Vector2> vectors, int imageWidth, int imageHeight) {
|
||||
BufferedImage image = new BufferedImage(imageWidth, imageHeight, BufferedImage.TYPE_INT_RGB);
|
||||
Graphics2D g2d = image.createGraphics();
|
||||
|
||||
|
@ -20,7 +20,7 @@ public final class LineSweep {
|
||||
* param = ranges : Array of range[start,end]
|
||||
* return Maximum Endpoint
|
||||
*/
|
||||
public static int FindMaximumEndPoint(int[][] ranges) {
|
||||
public static int findMaximumEndPoint(int[][] ranges) {
|
||||
Arrays.sort(ranges, Comparator.comparingInt(a -> a[1]));
|
||||
return ranges[ranges.length - 1][1];
|
||||
}
|
||||
@ -32,7 +32,7 @@ public final class LineSweep {
|
||||
*/
|
||||
public static boolean isOverlap(int[][] ranges) {
|
||||
|
||||
int maximumEndPoint = FindMaximumEndPoint(ranges);
|
||||
int maximumEndPoint = findMaximumEndPoint(ranges);
|
||||
Arrays.sort(ranges, Comparator.comparingInt(a -> a[0]));
|
||||
int[] numberLine = new int[maximumEndPoint + 2];
|
||||
for (int[] range : ranges) {
|
||||
|
Reference in New Issue
Block a user