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 newRange
given a minimum address and maximum address. -
Method Summary
Modifier and TypeMethodDescriptionboolean
contains
(int address) Determine whether a given address lies within this range.static MemoryLayout.Range
Decode a string representation of a range, which should be two integers separated by a comma.final boolean
Indicates whether some other object is "equal to" this one.final int
hashCode()
Returns a hash code value for this object.int
Returns the value of themaxAddress
record component.int
Returns the value of theminAddress
record component.final String
toString()
Returns a string representation of this record class.
-
Constructor Details
-
Range
public Range(int minAddress, int maxAddress) Construct a newRange
given 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:
true
if this range containsaddress
, orfalse
otherwise.
-
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 theminAddress
record component.- Returns:
- the value of the
minAddress
record component
-
maxAddress
public int maxAddress()Returns the value of themaxAddress
record component.- Returns:
- the value of the
maxAddress
record component
-