Package mars.mips.hardware
Record Class MemoryLayout.Range
java.lang.Object
java.lang.Record
mars.mips.hardware.MemoryLayout.Range
- Record Components:
minAddress- The minimum address in the range.maxAddress- The maximum address in the range.
- Enclosing class:
- MemoryLayout
Representation of an address range defined by a minimum address and a maximum address.
-
Constructor Summary
ConstructorsConstructorDescriptionRange(int minAddress, int maxAddress) Construct a newRangegiven a minimum address and maximum address. -
Method Summary
Modifier and TypeMethodDescriptionbooleancontains(int address) Determine whether a given address lies within this range.static MemoryLayout.RangeDecode a string representation of a range, which should be two integers separated by a comma.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.intReturns the value of themaxAddressrecord component.intReturns the value of theminAddressrecord component.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
Range
public Range(int minAddress, int maxAddress) Construct a newRangegiven a minimum address and maximum address.- Parameters:
minAddress- The minimum address in the range.maxAddress- The maximum address in the range.- Throws:
IllegalArgumentException- Thrown ifminAddress>maxAddress(using unsigned comparison).
-
-
Method Details
-
decode
Decode a string representation of a range, which should be two integers separated by a comma. Whitespace is ignored everywhere except within the integers themselves.- Parameters:
string- The string to decode.- Returns:
- The range represented by the string.
- Throws:
IllegalArgumentException- Thrown if the string is improperly formatted, or ifminAddress>maxAddress(using unsigned comparison).
-
contains
public boolean contains(int address) Determine whether a given address lies within this range.- Parameters:
address- The address to check.- Returns:
trueif this range containsaddress, orfalseotherwise.
-
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with '=='. -
minAddress
public int minAddress()Returns the value of theminAddressrecord component.- Returns:
- the value of the
minAddressrecord component
-
maxAddress
public int maxAddress()Returns the value of themaxAddressrecord component.- Returns:
- the value of the
maxAddressrecord component
-