Package ghidra.util.search.trie

# Interface ByteTrieIfc<T>

All Known Implementing Classes:
  `ByteTrie`, `CaseInsensitiveByteTrie`

public interface ByteTrieIfc<T>

- ## Method Summary

  Modifier and Type
  Method
  Description
  `boolean`
  `add(byte[] value, T item)`
  Adds a byte sequence to the trie, with corresponding user item.
  `ByteTrieNodeIfc<T>`
  `find(byte[] value)`
  Finds a byte sequence in the trie and returns a node interface object for it, or null if not present.
  `void`
  `inorder(TaskMonitor monitor, Op<T> op)`
  Visits all the nodes in the trie such that the visitation order is properly byte value ordered.
  `boolean`
  `isEmpty()`
  Returns if the trie is empty.
  `int`
  `numberOfNodes()`
  Returns the number of nodes in the trie; this is essentially equal to the sum of the number of characters in all byte sequences present in the trie, minus their shared prefixes.
  `List<SearchResult<Integer,T>>`
  `search(byte[] text, TaskMonitor monitor)`
  Search an array of bytes using the Aho-Corasick multiple string trie search algorithm.
  `List<SearchResult<Address,T>>`
  `search(Memory memory, AddressSetView view, TaskMonitor monitor)`
  Search an array of bytes using the Aho-Corasick multiple string trie search algorithm.
  `int`
  `size()`
  Returns the number of byte sequences in the trie.

- ## Method Details

  - ### isEmpty

    boolean isEmpty()
    Returns if the trie is empty.
    Returns:
      if the trie is empty

  - ### size

    int size()
    Returns the number of byte sequences in the trie.
    Returns:
      the number of byte sequences in the trie

  - ### numberOfNodes

    int numberOfNodes()
    Returns the number of nodes in the trie; this is essentially equal to the sum of the number of characters in all byte sequences present in the trie, minus their shared prefixes.
    Returns:
      the number of nodes in the trie

  - ### add

    boolean add(byte[] value, T item)
    Adds a byte sequence to the trie, with corresponding user item. Returns if the add took place, or if this add was essentially a replacement of a previously present value (previous user item is lost forever).
    Parameters:
      `value` - the byte sequence to insert into the trie
      `item` - a user item to store in that location
    Returns:
      whether the add took place

  - ### find

    ByteTrieNodeIfc<T> find(byte[] value)
    Finds a byte sequence in the trie and returns a node interface object for it, or null if not present.
    Parameters:
      `value` - the byte sequence sought
    Returns:
      the node interface if present, or null

  - ### inorder

    void inorder(TaskMonitor monitor, Op<T> op) throws CancelledException
    Visits all the nodes in the trie such that the visitation order is properly byte value ordered. The client is responsible for not performing actions on non-terminal nodes as necessary.
    Parameters:
      `monitor` - a task monitor
      `op` - the operation to perform
    Throws:
      `CancelledException` - if the user cancels

  - ### search

    List<SearchResult<Integer,T>> search(byte[] text, TaskMonitor monitor) throws CancelledException
    Search an array of bytes using the Aho-Corasick multiple string trie search algorithm.
    Parameters:
      `text` - the bytes to search
    Returns:
      a list of results (tuple of offset position, text found)
    Throws:
      `CancelledException` - if the search is cancelled

  - ### search

    List<SearchResult<Address,T>> search(Memory memory, AddressSetView view, TaskMonitor monitor) throws MemoryAccessException, CancelledException
    Search an array of bytes using the Aho-Corasick multiple string trie search algorithm.
    Parameters:
      `memory` - the memory to search in
      `view` - the AddressSetView to restrict the memory search to.
      `monitor` - the task monitor
    Returns:
      a list of results (tuple of offset position, text found)
    Throws:
      `MemoryAccessException` - if an error occurs reading the memory
      `CancelledException` - if the search is cancelled