Package ghidra.util

# Class SymmetricDifferenceAddressSetView

java.lang.Object
ghidra.util.AbstractAddressSetView
ghidra.util.SymmetricDifferenceAddressSetView

All Implemented Interfaces:
  `AddressSetView`, `Iterable<AddressRange>`

public class SymmetricDifferenceAddressSetView extends AbstractAddressSetView
A lazily computed `AddressSetView` defined as the symmetric difference between two given `AddressSetView`s.

There is no equivalent method in `AddressSetView`, but it could be computed using a combination of `AddressSetView.subtract(AddressSetView)` and `AddressSetView.union(AddressSetView)`. However, this class does not materialize the result. 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.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `SymmetricDifferenceAddressSetView(AddressSetView a, AddressSetView b)`
  Construct the symmetric difference between two address sets

- ## Method Summary

  Modifier and Type
  Method
  Description
  `boolean`
  `contains(Address addr)`
  Test if the address is contained within this set.
  `protected static Address`
  `fixStart(AddressRangeIterator rev, boolean forward)`
  `AddressRangeIterator`
  `getAddressRanges()`
  `AddressRangeIterator`
  `getAddressRanges(boolean forward)`
  Returns an iterator over the ranges in the specified order
  `AddressRangeIterator`
  `getAddressRanges(Address start, boolean forward)`
  Returns an iterator of address ranges starting with the range that contains the given address.
  `AddressRange`
  `getRangeContaining(Address address)`
  Returns the range that contains the given address
  `protected static Address`
  `rewindIfBounding(AddressRangeIterator rev, Address start, boolean forward)`

  ### Methods inherited from class ghidra.util.AbstractAddressSetView

  `contains, contains, findFirstAddressInCommon, fixStart, getAddresses, getAddresses, getFirstRange, getLastRange, getMaxAddress, getMinAddress, getNumAddresses, getNumAddressRanges, hasSameAddresses, intersect, intersectRange, intersects, intersects, isEmpty, iterator, iterator, iterator, subtract, union, xor`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

  ### Methods inherited from interface ghidra.program.model.address.AddressSetView

  `getAddressCountBefore, spliterator, spliterator, spliterator, stream, stream, stream`

  ### Methods inherited from interface java.lang.Iterable

  `forEach`

- ## Constructor Details

  - ### SymmetricDifferenceAddressSetView

    public SymmetricDifferenceAddressSetView(AddressSetView a, AddressSetView b)
    Construct the symmetric difference between two address sets
    Parameters:
      `a` - the first set
      `b` - the second set

- ## 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.

  - ### 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.

  - ### fixStart

    protected static Address fixStart(AddressRangeIterator rev, boolean forward)

  - ### rewindIfBounding

    protected static Address rewindIfBounding(AddressRangeIterator rev, Address start, boolean forward)

  - ### 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.