Package ghidra.program.model.address

# Interface AddressSetView

All Superinterfaces:
  `Iterable<AddressRange>`

All Known Subinterfaces:
  `CodeBlock`, `Memory`, `MemoryAdapter`, `ProgramFragment`, `TraceProgramViewMemory`

All Known Implementing Classes:
  `AbstractAddressSetView`, `AbstractDBTraceProgramViewMemory`, `AddressSet`, `AddressSetViewAdapter`, `CachedAddressSetView`, `CodeBlockImpl`, `DBTraceAddressSnapRangePropertyMapAddressSetView`, `DBTraceGuestPlatformMappedMemory`, `DBTraceObjectValueMapAddressSetView`, `DBTraceProgramViewFragment`, `DBTraceProgramViewMemory`, `DifferenceAddressSetView`, `ExtCodeBlockImpl`, `ImmutableAddressSet`, `IntersectionAddressSetView`, `MemoryMapDB`, `NormalizedAddressSet`, `ProgramSelection`, `StubMemory`, `SymmetricDifferenceAddressSetView`, `UnionAddressSetView`

public interface AddressSetView extends Iterable<AddressRange>
Defines a read-only interface for an address set.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `boolean`
  `contains(Address addr)`
  Test if the address is contained within this set.
  `boolean`
  `contains(Address start, Address end)`
  Test if the given address range is contained in this set.
  `boolean`
  `contains(AddressSetView rangeSet)`
  Test if the given address set is a subset of this set.
  `Address`
  `findFirstAddressInCommon(AddressSetView set)`
  Finds the first address in this collection that is also in the given addressSet.
  `default long`
  `getAddressCountBefore(Address address)`
  Returns the number of address in this address set before the given address.
  `AddressIterator`
  `getAddresses(boolean forward)`
  Returns an iterator over all addresses in this set.
  `AddressIterator`
  `getAddresses(Address start, boolean forward)`
  Returns an iterator over the addresses in this address set starting at the start address
  `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`
  `getFirstRange()`
  Returns the first range in this set or null if the set is empty
  `AddressRange`
  `getLastRange()`
  Returns the last range in this set or null if the set is empty
  `Address`
  `getMaxAddress()`
  Get the maximum address for this address set.
  `Address`
  `getMinAddress()`
  Get the minimum address for this address set.
  `long`
  `getNumAddresses()`
  `int`
  `getNumAddressRanges()`
  `AddressRange`
  `getRangeContaining(Address address)`
  Returns the range that contains the given address
  `boolean`
  `hasSameAddresses(AddressSetView view)`
  Returns true if the given address set contains the same set of addresses as this set.
  `AddressSet`
  `intersect(AddressSetView view)`
  Computes the intersection of this address set with the given address set.
  `AddressSet`
  `intersectRange(Address start, Address end)`
  Computes the intersection of this address set with the given address range.
  `boolean`
  `intersects(Address start, Address end)`
  Determine if the start and end range intersects with the specified address set.
  `boolean`
  `intersects(AddressSetView addrSet)`
  Determine if this address set intersects with the specified address set.
  `boolean`
  `isEmpty()`
  `Iterator<AddressRange>`
  `iterator()`
  Returns an iterator over the address ranges in this address set.
  `Iterator<AddressRange>`
  `iterator(boolean forward)`
  Returns an iterator over the ranges in the specified order
  `Iterator<AddressRange>`
  `iterator(Address start, boolean forward)`
  Returns an iterator of address ranges starting with the range that contains the given address.
  `default Spliterator<AddressRange>`
  `spliterator()`
  `default Spliterator<AddressRange>`
  `spliterator(boolean forward)`
  Create a spliterator over the ranges, as in `iterator(boolean)`
  `default Spliterator<AddressRange>`
  `spliterator(Address start, boolean forward)`
  Create a spliterator over the ranges, as in `iterator(boolean)`
  `default Stream<AddressRange>`
  `stream()`
  Stream the ranges in this set
  `default Stream<AddressRange>`
  `stream(boolean forward)`
  Stream the ranges in the set forward or backward
  `default Stream<AddressRange>`
  `stream(Address start, boolean forward)`
  Stream the ranges in the set as in `iterator(Address, boolean)`
  `AddressSet`
  `subtract(AddressSetView addrSet)`
  Computes the difference of this address set with the given address set (this - set).
  `static AddressSetView`
  `trimEnd(AddressSetView set, Address addr)`
  Trim address set removing all addresses greater-than-or-equal to specified address based upon `Address` comparison.
  `static AddressSetView`
  `trimStart(AddressSetView set, Address addr)`
  Trim address set removing all addresses less-than-or-equal to specified address based upon `Address` comparison.
  `AddressSet`
  `union(AddressSetView addrSet)`
  Computes the union of this address set with the given address set.
  `AddressSet`
  `xor(AddressSetView addrSet)`
  Computes the exclusive-or of this address set with the given set.

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

  `forEach`

- ## Method Details

  - ### contains

    boolean contains(Address addr)
    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

    boolean contains(Address start, Address end)
    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`.

    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

    boolean contains(AddressSetView rangeSet)
    Test if the given address set is a subset of this set.
    Parameters:
      `rangeSet` - the set to test.
    Returns:
      true if the entire set is contained within this set, false otherwise.

  - ### isEmpty

    boolean isEmpty()
    Returns:
      true if this set is empty.

  - ### getMinAddress

    Address getMinAddress()
    Get the minimum address for this address set.

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

    Returns:
      the minimum address for this set. Returns null if the set is empty.

  - ### getMaxAddress

    Address getMaxAddress()
    Get the maximum address for this address set.

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

    Returns:
      the maximum address for this set. Returns null if the set is empty.

  - ### getNumAddressRanges

    int getNumAddressRanges()
    Returns:
      the number of address ranges in this set.

  - ### getAddressRanges

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

  - ### getAddressRanges

    AddressRangeIterator getAddressRanges(boolean forward)
    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

    AddressRangeIterator getAddressRanges(Address start, boolean forward)
    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

  - ### iterator

    Iterator<AddressRange> iterator()
    Returns an iterator over the address ranges in this address set.
    Specified by:
      `iterator` in interface `Iterable<AddressRange>`

  - ### spliterator

    default Spliterator<AddressRange> spliterator()
    Specified by:
      `spliterator` in interface `Iterable<AddressRange>`

  - ### stream

    default Stream<AddressRange> stream()
    Stream the ranges in this set
    Returns:
      the stream

  - ### iterator

    Iterator<AddressRange> iterator(boolean forward)
    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 address ranges in the set.

  - ### spliterator

    default Spliterator<AddressRange> spliterator(boolean forward)
    Create a spliterator over the ranges, as in `iterator(boolean)`
    Parameters:
      `forward` - true to traverse lowest to highest, false for reverse
    Returns:
      a spliterator over all the address ranges in the set.

  - ### stream

    default Stream<AddressRange> stream(boolean forward)
    Stream the ranges in the set forward or backward
    Parameters:
      `forward` - true to stream lowest to highest, false for reverse
    Returns:
      a stream over all the address ranges in the set.

  - ### iterator

    Iterator<AddressRange> iterator(Address start, boolean forward)
    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 that the first range should contain.
      `forward` - true iterators forward, false backwards
    Returns:
      the AddressRange iterator

  - ### spliterator

    default Spliterator<AddressRange> spliterator(Address start, boolean forward)
    Create a spliterator over the ranges, as in `iterator(boolean)`
    Parameters:
      `start` - the address that the first range should contain.
      `forward` - true to traverse lowest to highest, false for reverse
    Returns:
      a spliterator over the address ranges.

  - ### stream

    default Stream<AddressRange> stream(Address start, boolean forward)
    Stream the ranges in the set as in `iterator(Address, boolean)`
    Parameters:
      `start` - the address that the first range should contain.
      `forward` - true to stream lowest to highest, false for reverse
    Returns:
      a stream over the address ranges.

  - ### getNumAddresses

    long getNumAddresses()
    Returns:
      the number of addresses in this set.

  - ### getAddresses

    AddressIterator getAddresses(boolean forward)
    Returns an iterator over all addresses in this set.
    Parameters:
      `forward` - if true the address are return in increasing order, otherwise in decreasing order.
    Returns:
      an iterator over all addresses in this set.

  - ### getAddresses

    AddressIterator getAddresses(Address start, boolean forward)
    Returns an iterator over the addresses in this address set starting at the start address
    Parameters:
      `start` - address to start iterating at in the address set
      `forward` - if true address are return from lowest to highest, else from highest to lowest
    Returns:
      an iterator over the addresses in this address set starting at the start address

  - ### intersects

    boolean intersects(AddressSetView addrSet)
    Determine if this address set intersects with the specified address set.
    Parameters:
      `addrSet` - address set to check intersection with.
    Returns:
      true if this set intersects the specified addrSet else false

  - ### intersects

    boolean intersects(Address start, Address end)
    Determine if the start and end range intersects with the specified address set.

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

    Parameters:
      `start` - start of range
      `end` - end of range
    Returns:
      true if the given range intersects this address set.

  - ### intersect

    AddressSet intersect(AddressSetView view)
    Computes the intersection of this address set with the given address set.

    This method does not modify this address set.

    Parameters:
      `view` - the address set to intersect with.
    Returns:
      AddressSet a new address set that contains all addresses that are contained in both this set and the given set.

  - ### intersectRange

    AddressSet intersectRange(Address start, Address end)
    Computes the intersection of this address set with the given address range.

    This method does not modify this address set. The specified start and end addresses must form a valid range within a single `AddressSpace`.

    Parameters:
      `start` - start of range
      `end` - end of range
    Returns:
      AddressSet a new address set that contains all addresses that are contained in both this set and the given range.

  - ### union

    AddressSet union(AddressSetView addrSet)
    Computes the union of this address set with the given address set.

    This method does not change this address set.

    Parameters:
      `addrSet` - The address set to be unioned with this address set.
    Returns:
      AddressSet A new address set which contains all the addresses from both this set and the given set.

  - ### subtract

    AddressSet subtract(AddressSetView addrSet)
    Computes the difference of this address set with the given address set (this - set).

    Note that this is not the same as (set - this). This method does not change this address set.

    Parameters:
      `addrSet` - the set to subtract from this set.
    Returns:
      AddressSet a new address set which contains all the addresses that are in this set, but not in the given set.

  - ### xor

    AddressSet xor(AddressSetView addrSet)
    Computes the exclusive-or of this address set with the given set.

    This method does not modify this address set.

    Parameters:
      `addrSet` - address set to exclusive-or with.
    Returns:
      AddressSet a new address set containing all addresses that are in either this set or the given set, but not in both sets

  - ### hasSameAddresses

    boolean hasSameAddresses(AddressSetView view)
    Returns true if the given address set contains the same set of addresses as this set.
    Parameters:
      `view` - the address set to compare.
    Returns:
      true if the given set contains the same addresses as this set.

  - ### getFirstRange

    AddressRange getFirstRange()
    Returns the first range in this set or null if the set is empty
    Returns:
      the first range in this set or null if the set is empty

  - ### getLastRange

    AddressRange getLastRange()
    Returns the last range in this set or null if the set is empty
    Returns:
      the last range in this set or null if the set is empty

  - ### getRangeContaining

    AddressRange getRangeContaining(Address address)
    Returns the range that contains the given address
    Parameters:
      `address` - the address for which to find a range.
    Returns:
      the range that contains the given address.

  - ### findFirstAddressInCommon

    Address findFirstAddressInCommon(AddressSetView set)
    Finds the first address in this collection that is also in the given addressSet.
    Parameters:
      `set` - the addressSet to search for the first (lowest) common address.
    Returns:
      the first address that is contained in this set and the given set.

  - ### getAddressCountBefore

    default long getAddressCountBefore(Address address)
    Returns the number of address in this address set before the given address.
    Parameters:
      `address` - the address after the last address to be counted
    Returns:
      the number of address in this address set before the given address

  - ### trimStart

    static AddressSetView trimStart(AddressSetView set, Address addr)
    Trim address set removing all addresses less-than-or-equal to specified address based upon `Address` comparison.

    The address set may contain address ranges from multiple address spaces.

    Parameters:
      `set` - address set to be trimmed
      `addr` - trim point. Only addresses greater than this address will be returned.
    Returns:
      trimmed address set view

  - ### trimEnd

    static AddressSetView trimEnd(AddressSetView set, Address addr)
    Trim address set removing all addresses greater-than-or-equal to specified address based upon `Address` comparison.

    The address set may contain address ranges from multiple address spaces.

    Parameters:
      `set` - address set to be trimmed
      `addr` - trim point. Only addresses less than this address will be returned.
    Returns:
      trimmed address set view