de.caff.generics.algorithm

## Class FastDoubleSequenceSearch

- java.lang.Object
- - de.caff.generics.algorithm.FastDoubleSequenceSearch

-     public class FastDoubleSequenceSearch
      extends java.lang.Object

  Fast search algorithm in sequences of random-accessible double values.

  Currently only forward search is implemented, but basically both the search indexable and the searched indexable can be `reversed` before searching.

  Although based on integers this may also be used for searches in byte or character sequences.

  Since:
    July 07, 2020
  Author:
    Rammi

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `FastDoubleSequenceSearch(double... searchTerm)` Constructor.
    `FastDoubleSequenceSearch(DoubleIndexable searchTerm)` Constructor.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `IntIndexable` | `findAllMatches(DoubleIndexable data, boolean allowOverlaps)` Find all matches.
    `int` | `findFirst(DoubleIndexable data)` Find the first appearance of the search term in the given data.
    `int` | `findNext(DoubleIndexable data, int pos)` Find the next appearance of the search term after the given position in the given data.
    `int` | `findNext(DoubleIndexable data, int pos, int end)` Find the next appearance of the search term after the given start position and before the given end position in the given data.
    `DoubleIndexable` | `getSearchTerm()` Get the search term.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### FastDoubleSequenceSearch

          public FastDoubleSequenceSearch(@NotNull
                                          DoubleIndexable searchTerm)

      Constructor.
      Parameters:
        `searchTerm` - term to search for

    - #### FastDoubleSequenceSearch

          public FastDoubleSequenceSearch(double... searchTerm)

      Constructor.
      Parameters:
        `searchTerm` - double sequence to search for

  - ### Method Detail

    - #### getSearchTerm

          @NotNull
          public DoubleIndexable getSearchTerm()

      Get the search term.
      Returns:
        search term

    - #### findFirst

          public int findFirst(@NotNull
                               DoubleIndexable data)

      Find the first appearance of the search term in the given data.
      Parameters:
        `data` - data to search through
      Returns:
        index of first appearance of the search term in the given data, or `-1` if there was nothing found

    - #### findNext

          public int findNext(@NotNull
                              DoubleIndexable data,
                              int pos)

      Find the next appearance of the search term after the given position in the given data.
      Parameters:
        `data` - data to search through
        `pos` - position to start the search
      Returns:
        position of next appearance of the search term in the given data after the given position, or `-1` if there was nothing found between the position and the end of data

    - #### findNext

          public int findNext(@NotNull
                              DoubleIndexable data,
                              int pos,
                              int end)

      Find the next appearance of the search term after the given start position and before the given end position in the given data.
      Parameters:
        `data` - data to search through
        `pos` - position to start the search
        `end` - position to end the search, the whole search term has to fit before this position to be found
      Returns:
        position of next appearance of the search term in the given data after the given start position and before the given end position, or `-1` if there was nothing found between the position and the end of data

    - #### findAllMatches

          @NotNull
          public IntIndexable findAllMatches(@NotNull
                                                      DoubleIndexable data,
                                                      boolean allowOverlaps)

      Find all matches.
      Parameters:
        `data` - data to search
        `allowOverlaps` - allow overlapping sequences in the matches?
      Returns:
        start position of all matches