Skip to content

Add an ArrayList native for searching for byte sequences #1539

Open
@asherkin

Description

@asherkin

Split out of #966 for tracking, see that PR for more background detail.

Add a new FindArrayInArray native that takes an array of bytes to search for along with an offset to start matching from.

FindValueInArray(arr, 42, 1, 2); would become FindArrayInArray(arr, { 42, 42 }, 2, 1);

But this design also allows more flexible combinations such as FindArrayInArray(arr, { 11, 42 }, 2, 1);

And if we specify an additional limit param and wrap access to the input array, the first example can be simplified to: FindArrayInArray(arr, { 42 }, 1, 1, 2);

native int FindArrayInArray(Handle array, any[] needle, int needleLength, int start = 0, int limit = 0); 

Where:

  • needle = the bytes to search.
  • start = the byte offset in each block to start searching.
  • limit = the number of bytes of the block to match, looping needle as needed, with the following special values:
    • -1 = the block size - start
    • 0 = needleLength
  • needleLength > limit would be an error.
  • limit > (block size - start) would be an error.
  • 0 < start <= block size would be an error.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions