Package ghidra.util

Class DifferenceAddressSetView

java.lang.Object
ghidra.util.AbstractAddressSetView
ghidra.util.DifferenceAddressSetView
All Implemented Interfaces:
AddressSetView, Iterable<AddressRange>

public class DifferenceAddressSetView extends AbstractAddressSetView
A lazily computed AddressSetView defined as the difference between two given AddressSetViews.

This is equivalent to using AddressSetView.subtract(AddressSetView), but does not materialize the difference. The choice of one over the other depends on the number of ranges in the inputs and the frequency of use of the result. With few ranges, or in cases where you need to access the entire result, anyway, just use the normal AddressRange. In cases with many, many ranges and where only a small part of the result needs to be computed, use this view. It may also be advantageous to use this view if the inputs are themselves computed lazily.

  • Constructor Details

    • DifferenceAddressSetView

      public DifferenceAddressSetView(AddressSetView a, AddressSetView b)
      Construct the difference between two address sets
      Parameters:
      a - the minuend
      b - the subtrahend
  • Method Details

    • contains

      public boolean contains(Address addr)
      Description copied from interface: AddressSetView
      Test if the address is contained within this set.
      Parameters:
      addr - address to test.
      Returns:
      true if addr exists in the set, false otherwise.
    • contains

      public boolean contains(Address start, Address end)
      Description copied from interface: AddressSetView
      Test if the given address range is contained in this set.

      The specified start and end addresses must form a valid range within a single AddressSpace.

      Specified by:
      contains in interface AddressSetView
      Overrides:
      contains in class AbstractAddressSetView
      Parameters:
      start - the first address in the range.
      end - the last address in the range.
      Returns:
      true if entire range is contained within the set, false otherwise.
    • contains

      public boolean contains(AddressSetView rangeSet)
      Description copied from interface: AddressSetView
      Test if the given address set is a subset of this set.
      Specified by:
      contains in interface AddressSetView
      Overrides:
      contains in class AbstractAddressSetView
      Parameters:
      rangeSet - the set to test.
      Returns:
      true if the entire set is contained within this set, false otherwise.
    • getAddressRanges

      public AddressRangeIterator getAddressRanges()
      Returns:
      an iterator over the address ranges in this address set.
    • getAddressRanges

      public AddressRangeIterator getAddressRanges(boolean forward)
      Description copied from interface: AddressSetView
      Returns an iterator over the ranges in the specified order
      Parameters:
      forward - the ranges are returned from lowest to highest, otherwise from highest to lowest
      Returns:
      an iterator over all the addresse ranges in the set.
    • getAddressRanges

      public AddressRangeIterator getAddressRanges(Address start, boolean forward)
      Description copied from interface: AddressSetView
      Returns an iterator of address ranges starting with the range that contains the given address.

      If there is no range containing the start address, then the first range will be the next range greater than the start address if going forward, otherwise the range less than the start address

      Parameters:
      start - the address the first range should contain.
      forward - true iterators forward, false backwards
      Returns:
      the AddressRange iterator
    • getRangeContaining

      public AddressRange getRangeContaining(Address address)
      Description copied from interface: AddressSetView
      Returns the range that contains the given address
      Specified by:
      getRangeContaining in interface AddressSetView
      Overrides:
      getRangeContaining in class AbstractAddressSetView
      Parameters:
      address - the address for which to find a range.
      Returns:
      the range that contains the given address.