java.lang.Object
ghidra.app.plugin.assembler.sleigh.util.AsmUtil

public class AsmUtil extends Object
Utilities for the Assembler
  • Constructor Details

    • AsmUtil

      public AsmUtil()
  • Method Details

    • compareInOrder

      public static <T extends Comparable<T>> int compareInOrder(Collection<T> a, Collection<T> b)
      Compare two collections by their corresponding elements in order

      If the collections have differing sizes, the ordering does not matter. The smaller collection precedes the larger. Otherwise, each corresponding pair of elements are compared. Once an unequal pair is found, the collections are ordered by those elements. This is analogous to String comparison.

      Parameters:
      a - the first set
      b - the second set
      Returns:
      a comparison result as in Comparable.compareTo(Object)
    • compareArrays

      public static int compareArrays(byte[] a, byte[] b)
      Compare two byte arrays by their corresponding entries

      If the two arrays have differing lengths, the shorter precedes the longer. Otherwise, they are compared as in C's memcmp, except that Java bytes are signed.

      Parameters:
      a - the first array
      b - the second array
      Returns:
      a comparison result as in Comparable.compareTo(Object)
    • extendList

      public static <T> List<T> extendList(List<T> list, T ext)
      Extend a list with the given item

      Used in functional style when the list is immutable.

      Type Parameters:
      T - the type of elements
      Parameters:
      list - the list
      ext - the additional item
      Returns:
      an immutable copy of the list with the given item appended