File tree Expand file tree Collapse file tree 1 file changed +5
-5
lines changed
src/main/java/com/thealgorithms/searches Expand file tree Collapse file tree 1 file changed +5
-5
lines changed Original file line number Diff line number Diff line change
1
+ package com .thealgorithms .searches ;
2
+
1
3
/**
2
4
* Boyer-Moore string search algorithm
3
5
* Efficient algorithm for substring search.
@@ -11,15 +13,13 @@ public class BoyerMoore {
11
13
12
14
public BoyerMoore (String pat ) {
13
15
this .pattern = pat ;
14
- this .R = 256 ; // extended ASCII
16
+ this .R = 256 ;
15
17
this .right = new int [R ];
16
18
17
- // Initialize all occurrences as -1
18
19
for (int c = 0 ; c < R ; c ++) {
19
20
right [c ] = -1 ;
20
21
}
21
22
22
- // Fill the actual value of last occurrence of a character
23
23
for (int j = 0 ; j < pat .length (); j ++) {
24
24
right [pat .charAt (j )] = j ;
25
25
}
@@ -42,9 +42,9 @@ public int search(String text) {
42
42
break ;
43
43
}
44
44
}
45
- if (skip == 0 ) return i ; // found
45
+ if (skip == 0 ) return i ;
46
46
}
47
- return -1 ; // not found
47
+ return -1 ;
48
48
}
49
49
50
50
public static int search (String text , String pattern ) {
You can’t perform that action at this time.
0 commit comments