University stuff.
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

1234567891011121314151617181920212223
  1. * Compile: `javac *.java`
  2. * Run test case: `./test <test dir>`
  3. * test 1: no matches (empty haystack)
  4. * test 2: no matches (empty needle)
  5. * test 3: "cog" (0-2), "cag"(8-10)
  6. * test 4: "horse" (0-4), "house"(5-9)
  7. * test 5: "this\nis\ntext" (0-11), "this is text" (13-24)
  8. * Main.java contains the main method.
  9. * I have assumed '_' should match a single character (like . in regex),
  10. not any number of characters (like * in bash).
  11. * My code is heavily influenced by the explanation of Boyer Moore Horspool
  12. in lecture 10.
  13. http://www.uio.no/studier/emner/matnat/ifi/INF2220/h16/undervisningsmaterialet/lecture10.pdf
  14. # Explanation of why it works
  15. The only change I made from standard Boyer Moore Horspool is that
  16. instead of checking whether a position in the needle matches the corresponding
  17. position in the haystack, I check if a positiion in the needle matches
  18. either '_' or the corresponding position in the heystack.
  19. I also modified it such that instead of returning on the first match,
  20. it just adds the match to an array, breaks out of the inner for loop, and
  21. goes on to find the next match.