Class ProgramSelection

  • All Implemented Interfaces:
    AddressSetView, java.lang.Iterable<AddressRange>

    public class ProgramSelection
    extends java.lang.Object
    implements AddressSetView
    Class to define a selection for a program.
    • Constructor Detail

      • ProgramSelection

        public ProgramSelection()
        Construct a new empty ProgramSelection.
      • ProgramSelection

        public ProgramSelection​(AddressFactory addressFactory)
        Construct a new empty ProgramSelection.
        Parameters:
        addressFactory - the address factory for the address set associated with this program selection.
      • ProgramSelection

        public ProgramSelection​(Address from,
                                Address to)
        Constructor.
        Parameters:
        from - the start of the selection
        to - the end of the selection
      • ProgramSelection

        public ProgramSelection​(AddressFactory addressFactory,
                                Address from,
                                Address to)
        Constructor.
        Parameters:
        addressFactory - the address factory for the address set associated with this program selection.
        from - the start of the selection
        to - the end of the selection
      • ProgramSelection

        public ProgramSelection​(AddressSetView setView)
        Construct a new ProgramSelection
        Parameters:
        setView - address set for the selection
      • ProgramSelection

        public ProgramSelection​(AddressFactory addressFactory,
                                AddressSetView setView)
        Construct a new ProgramSelection
        Parameters:
        addressFactory - the address factory for the address set associated with this program selection.
        setView - address set for the selection
      • ProgramSelection

        public ProgramSelection​(AddressFactory addressFactory,
                                InteriorSelection sel)
        Construct a new ProgramSelection from the indicated interior selection.
        Parameters:
        addressFactory - the address factory for the address set associated with this program selection.
        sel - the interior selection
      • ProgramSelection

        public ProgramSelection​(InteriorSelection sel)
        Construct a new ProgramSelection from the indicated interior selection.
        Parameters:
        sel - the interior selection
    • Method Detail

      • getInteriorSelection

        public InteriorSelection getInteriorSelection()
        Get the interior selection.
        Returns:
        null if there is no interior selection
      • equals

        public boolean equals​(java.lang.Object obj)
        Return whether this ProgramSelection is equal to obj.
        Overrides:
        equals in class java.lang.Object
      • contains

        public boolean contains​(Address addr)
        Test if the address exists within this set.

        Specified by:
        contains in interface AddressSetView
        Parameters:
        addr - address to test.
        Returns:
        true if addr exists in the set, false otherwise.
      • contains

        public boolean contains​(Address start,
                                Address end)
        Test if the given address range is in the set.

        Specified by:
        contains in interface AddressSetView
        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)
        Test if the given address set is a subset of this set.

        Specified by:
        contains in interface AddressSetView
        Parameters:
        rangeSet - the set to test.
        Returns:
        true if the entire set is contained within this set, false otherwise.
      • intersects

        public boolean intersects​(AddressSetView addrSet)
        Determine if this program selection intersects with the specified address set.
        Specified by:
        intersects in interface AddressSetView
        Parameters:
        addrSet - address set to check intersection with.
      • isEmpty

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

        public int getNumAddressRanges()
        Return the number of address ranges in this set.
        Specified by:
        getNumAddressRanges in interface AddressSetView
      • getAddressRanges

        public AddressRangeIterator getAddressRanges​(boolean atStart)
        Returns an iterator over the address ranges in this address set.
        Specified by:
        getAddressRanges in interface AddressSetView
        Parameters:
        atStart - if true, the iterator is positioned at the minimum address. if false, the iterator is positioned at the maximum address.
        Returns:
        an iterator over all the addresse ranges in the set.
      • iterator

        public java.util.Iterator<AddressRange> iterator()
        Description copied from interface: AddressSetView
        Returns an iterator over the address ranges in this address set.
        Specified by:
        iterator in interface AddressSetView
        Specified by:
        iterator in interface java.lang.Iterable<AddressRange>
      • getNumAddresses

        public long getNumAddresses()
        Returns the number of addresses in this set.
        Specified by:
        getNumAddresses in interface AddressSetView
      • hasSameAddresses

        public boolean hasSameAddresses​(AddressSetView asv)
        Returns true if and only if this set and the given address set contains exactly the same addresses.
        Specified by:
        hasSameAddresses in interface AddressSetView
        Parameters:
        asv - the address set to compare with this one.
        Returns:
        true if the specified set has the same addresses.
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • 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 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 interface AddressSetView
        Parameters:
        start - the address the the first range should contain.
        forward - true iterators forward, false backwards
        Returns:
        the AddressRange iterator
      • getFirstRange

        public AddressRange getFirstRange()
        Description copied from interface: AddressSetView
        Returns the first range in this set or null if the set is empty;
        Specified by:
        getFirstRange in interface AddressSetView
        Returns:
        the first range in this set or null if the set is empty;
      • getLastRange

        public AddressRange getLastRange()
        Description copied from interface: AddressSetView
        Returns the last range in this set or null if the set is empty;
        Specified by:
        getLastRange in interface AddressSetView
        Returns:
        the last range in this set or null if the set is empty;
      • 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
        Parameters:
        address - the address for which to find a range.
        Returns:
        the range that contains the given address.
      • iterator

        public java.util.Iterator<AddressRange> iterator​(boolean forward)
        Description copied from interface: AddressSetView
        Returns an iterator over the ranges in the specified order
        Specified by:
        iterator in interface AddressSetView
        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

        public java.util.Iterator<AddressRange> iterator​(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 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 interface AddressSetView
        Parameters:
        start - the address the the first range should contain.
        forward - true iterators forward, false backwards
        Returns:
        the AddressRange iterator
      • findFirstAddressInCommon

        public Address findFirstAddressInCommon​(AddressSetView set)
        Description copied from interface: AddressSetView
        Finds the first address in this collection that is also in the given addressSet.
        Specified by:
        findFirstAddressInCommon in interface AddressSetView
        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.