Package ghidra.program.util
Class ProgramSelection
java.lang.Object
ghidra.program.util.ProgramSelection
- All Implemented Interfaces:
AddressSetView
,Iterable<AddressRange>
Class to define a selection for a program.
-
Constructor Summary
ConstructorDescriptionConstruct a new empty ProgramSelection.ProgramSelection
(AddressFactory addressFactory) Deprecated, for removal: This API element is subject to removal in a future version.ProgramSelection
(AddressFactory addressFactory, Address from, Address to) Deprecated, for removal: This API element is subject to removal in a future version.ProgramSelection
(AddressFactory addressFactory, AddressSetView setView) Deprecated, for removal: This API element is subject to removal in a future version.ProgramSelection
(AddressFactory addressFactory, InteriorSelection sel) Deprecated, for removal: This API element is subject to removal in a future version.ProgramSelection
(Address from, Address to) Constructor.ProgramSelection
(AddressSetView setView) Construct a new ProgramSelectionConstruct a new ProgramSelection from the indicated interior selection. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Test if the address is contained within this set.boolean
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.boolean
Finds the first address in this collection that is also in the given addressSet.getAddresses
(boolean forward) Returns an iterator over all addresses in this set.getAddresses
(Address start, boolean forward) Returns an iterator over the addresses in this address set starting at the start addressgetAddressRanges
(boolean atStart) Returns an iterator over the ranges in the specified ordergetAddressRanges
(Address start, boolean forward) Returns an iterator of address ranges starting with the range that contains the given address.Returns the first range in this set or null if the set is empty;Get the interior selection.Returns the last range in this set or null if the set is empty;Get the maximum address for this address set.Get the minimum address for this address set.long
int
getRangeContaining
(Address address) Returns the range that contains the given addressint
hashCode()
boolean
Returns true if and only if this set and the given address set contains exactly the same addresses.intersect
(AddressSetView view) Computes the intersection of this address set with the given address set.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()
Returns an iterator over the address ranges in this address set.iterator
(boolean forward) Returns an iterator over the ranges in the specified orderReturns an iterator of address ranges starting with the range that contains the given address.subtract
(AddressSetView view) Computes the difference of this address set with the given address set (this - set).toString()
union
(AddressSetView view) Computes the union of this address set with the given address set.xor
(AddressSetView view) Computes the exclusive-or of this address set with the given set.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface ghidra.program.model.address.AddressSetView
getAddressCountBefore
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
ProgramSelection
public ProgramSelection()Construct a new empty ProgramSelection. -
ProgramSelection
Constructor.- Parameters:
from
- the start of the selectionto
- the end of the selection
-
ProgramSelection
Construct a new ProgramSelection- Parameters:
setView
- address set for the selection
-
ProgramSelection
Construct a new ProgramSelection from the indicated interior selection.- Parameters:
sel
- the interior selection
-
ProgramSelection
Deprecated, for removal: This API element is subject to removal in a future version.Construct a new empty ProgramSelection.- Parameters:
addressFactory
- NOT USED
-
ProgramSelection
@Deprecated(since="11.2", forRemoval=true) public ProgramSelection(AddressFactory addressFactory, Address from, Address to) Deprecated, for removal: This API element is subject to removal in a future version.Constructor.- Parameters:
addressFactory
- NOT USEDfrom
- the start of the selectionto
- the end of the selection
-
ProgramSelection
@Deprecated(since="11.2", forRemoval=true) public ProgramSelection(AddressFactory addressFactory, AddressSetView setView) Deprecated, for removal: This API element is subject to removal in a future version.Construct a new ProgramSelection- Parameters:
addressFactory
- NOT USEDsetView
- address set for the selection
-
ProgramSelection
@Deprecated(since="11.2", forRemoval=true) public ProgramSelection(AddressFactory addressFactory, InteriorSelection sel) Deprecated, for removal: This API element is subject to removal in a future version.Construct a new ProgramSelection from the indicated interior selection.- Parameters:
addressFactory
- NOT USEDsel
- the interior selection
-
-
Method Details
-
getInteriorSelection
Get the interior selection.- Returns:
- null if there is no interior selection
-
hashCode
public int hashCode() -
equals
-
contains
Description copied from interface:AddressSetView
Test if the address is contained within this set.- Specified by:
contains
in interfaceAddressSetView
- Parameters:
addr
- address to test.- Returns:
- true if addr exists in the set, false otherwise.
-
contains
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 singleAddressSpace
.- Specified by:
contains
in interfaceAddressSetView
- 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
Description copied from interface:AddressSetView
Test if the given address set is a subset of this set.- Specified by:
contains
in interfaceAddressSetView
- Parameters:
rangeSet
- the set to test.- Returns:
- true if the entire set is contained within this set, false otherwise.
-
intersects
Description copied from interface:AddressSetView
Determine if this address set intersects with the specified address set.- Specified by:
intersects
in interfaceAddressSetView
- Parameters:
addrSet
- address set to check intersection with.- Returns:
- true if this set intersects the specified addrSet else false
-
intersect
Description copied from interface:AddressSetView
Computes the intersection of this address set with the given address set. This method does not modify this address set.- Specified by:
intersect
in interfaceAddressSetView
- 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
Description copied from interface:AddressSetView
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 singleAddressSpace
.- Specified by:
intersectRange
in interfaceAddressSetView
- Parameters:
start
- start of rangeend
- end of range- Returns:
- AddressSet a new address set that contains all addresses that are contained in both this set and the given range.
-
isEmpty
public boolean isEmpty()- Specified by:
isEmpty
in interfaceAddressSetView
- Returns:
- true if this set is empty.
-
getMinAddress
Description copied from interface:AddressSetView
Get the minimum address for this address set. NOTE: AnAddressRange
should generally not be formed using this address andAddressSetView.getMaxAddress()
since it may span multipleAddressSpace
s.- Specified by:
getMinAddress
in interfaceAddressSetView
- Returns:
- the minimum address for this set. Returns null if the set is empty.
-
getMaxAddress
Description copied from interface:AddressSetView
Get the maximum address for this address set. NOTE: AnAddressRange
should generally not be formed using this address andAddressSetView.getMaxAddress()
since it may span multipleAddressSpace
s.- Specified by:
getMaxAddress
in interfaceAddressSetView
- Returns:
- the maximum address for this set. Returns null if the set is empty.
-
getNumAddressRanges
public int getNumAddressRanges()- Specified by:
getNumAddressRanges
in interfaceAddressSetView
- Returns:
- the number of address ranges in this set.
-
getAddressRanges
Description copied from interface:AddressSetView
Returns an iterator over the ranges in the specified order- Specified by:
getAddressRanges
in interfaceAddressSetView
- Parameters:
atStart
- 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
- Specified by:
getAddressRanges
in interfaceAddressSetView
- Returns:
- an iterator over the address ranges in this address set.
-
iterator
Description copied from interface:AddressSetView
Returns an iterator over the address ranges in this address set.- Specified by:
iterator
in interfaceAddressSetView
- Specified by:
iterator
in interfaceIterable<AddressRange>
-
getNumAddresses
public long getNumAddresses()- Specified by:
getNumAddresses
in interfaceAddressSetView
- Returns:
- the number of addresses in this set.
-
getAddresses
Description copied from interface:AddressSetView
Returns an iterator over all addresses in this set.- Specified by:
getAddresses
in interfaceAddressSetView
- 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
Description copied from interface:AddressSetView
Returns an iterator over the addresses in this address set starting at the start address- Specified by:
getAddresses
in interfaceAddressSetView
- Parameters:
start
- address to start iterating at in the address setforward
- 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
-
hasSameAddresses
Returns true if and only if this set and the given address set contains exactly the same addresses.- Specified by:
hasSameAddresses
in interfaceAddressSetView
- Parameters:
asv
- the address set to compare with this one.- Returns:
- true if the specified set has the same addresses.
-
intersects
Description copied from interface:AddressSetView
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 singleAddressSpace
.- Specified by:
intersects
in interfaceAddressSetView
- Parameters:
start
- start of rangeend
- end of range- Returns:
- true if the given range intersects this address set.
-
union
Description copied from interface:AddressSetView
Computes the union of this address set with the given address set. This method does not change this address set.- Specified by:
union
in interfaceAddressSetView
- Parameters:
view
- 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.
-
xor
Description copied from interface:AddressSetView
Computes the exclusive-or of this address set with the given set. This method does not modify this address set.- Specified by:
xor
in interfaceAddressSetView
- Parameters:
view
- 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
-
subtract
Description copied from interface:AddressSetView
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.- Specified by:
subtract
in interfaceAddressSetView
- Parameters:
view
- 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.
-
toString
-
getAddressRanges
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 the first range will be the next range greater than the start address if going forward, otherwise the range less than the start address- Specified by:
getAddressRanges
in interfaceAddressSetView
- Parameters:
start
- the address the the first range should contain.forward
- true iterators forward, false backwards- Returns:
- the AddressRange iterator
-
getFirstRange
Description copied from interface:AddressSetView
Returns the first range in this set or null if the set is empty;- Specified by:
getFirstRange
in interfaceAddressSetView
- Returns:
- the first range in this set or null if the set is empty;
-
getLastRange
Description copied from interface:AddressSetView
Returns the last range in this set or null if the set is empty;- Specified by:
getLastRange
in interfaceAddressSetView
- Returns:
- the last range in this set or null if the set is empty;
-
getRangeContaining
Description copied from interface:AddressSetView
Returns the range that contains the given address- Specified by:
getRangeContaining
in interfaceAddressSetView
- Parameters:
address
- the address for which to find a range.- Returns:
- the range that contains the given address.
-
iterator
Description copied from interface:AddressSetView
Returns an iterator over the ranges in the specified order- Specified by:
iterator
in interfaceAddressSetView
- 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.
-
iterator
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 the first range will be the next range greater than the start address if going forward, otherwise the range less than the start address- Specified by:
iterator
in interfaceAddressSetView
- Parameters:
start
- the address the the first range should contain.forward
- true iterators forward, false backwards- Returns:
- the AddressRange iterator
-
findFirstAddressInCommon
Description copied from interface:AddressSetView
Finds the first address in this collection that is also in the given addressSet.- Specified by:
findFirstAddressInCommon
in interfaceAddressSetView
- 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.
-
ProgramSelection()