Package ghidra.util

Class UnionAddressSetView

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

public class UnionAddressSetView extends AbstractAddressSetView
A lazily computed AddressSetView defined as the union of many given AddressSetViews.

This is equivalent to using AddressSetView.union(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 if the inputs are themselves computed lazily.

This follows the conventions expected of an AddressSetView in that the returned ranges are disjoint. Thus, it will combine intersecting and abutting ranges from among the inputs. For example, the union of [[1,2]] and [[3,4]] is [[1,4]].

  • Constructor Details

    • UnionAddressSetView

      public UnionAddressSetView(AddressSetView... views)
      Construct the union of the given address set views
      Parameters:
      views - the input sets
    • UnionAddressSetView

      public UnionAddressSetView(Collection<AddressSetView> views)
      Construct the union of the given address set views
      Parameters:
      views - the input sets
  • 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.
    • isEmpty

      public boolean isEmpty()
      Specified by:
      isEmpty in interface AddressSetView
      Overrides:
      isEmpty in class AbstractAddressSetView
      Returns:
      true if this set is empty.
    • getMinAddress

      public Address getMinAddress()
      Description copied from interface: AddressSetView
      Get the minimum address for this address set.

      NOTE: An AddressRange should generally not be formed using this address and AddressSetView.getMaxAddress() since it may span multiple AddressSpaces.

      Specified by:
      getMinAddress in interface AddressSetView
      Overrides:
      getMinAddress in class AbstractAddressSetView
      Returns:
      the minimum address for this set. Returns null if the set is empty.
    • getMaxAddress

      public Address getMaxAddress()
      Description copied from interface: AddressSetView
      Get the maximum address for this address set.

      NOTE: An AddressRange should generally not be formed using this address and AddressSetView.getMaxAddress() since it may span multiple AddressSpaces.

      Specified by:
      getMaxAddress in interface AddressSetView
      Overrides:
      getMaxAddress in class AbstractAddressSetView
      Returns:
      the maximum address for this set. Returns null if the set is empty.
    • 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