public class Subspace extends Object
Subspace provides a number of useful facilities to many drivers, and is useful even if the Space comprises just a single contiguous region.
A subspace keeps track of the start and end address of the region, the index of its first block, the size of the blocks in this space, and the number of blocks in this subspace.
Modifier and Type | Field and Description |
---|---|
private int |
blockNum_
the number of blocks in this space
|
private int |
blockSize_
the block size
|
private static boolean |
DEBUG |
private Address |
end_
end address of the subspace.
|
private int |
firstIndex_
The index of the block in which
start_ lies |
private Address |
start_
start address of the subspace.
|
Constructor and Description |
---|
Subspace(Address start,
Address end,
int firstIndex,
int blockSize,
int blockNum)
Create a new subspace
|
Modifier and Type | Method and Description |
---|---|
boolean |
addressInRange(Address addr)
Is address in the range of this subspace?
|
private void |
dump()
Dump a representation of the subspace
|
Address |
getAddress(int index)
Get the address of start of block from its index
|
int |
getBlockNum()
Get the number of tiles in this subspace
|
int |
getBlockSize()
Get the blocksize for this subspace
|
Address |
getEnd()
Get the end of this subspace
|
int |
getFirstIndex()
Get the first index of subspace
|
int |
getIndex(Address addr)
Get the block index from an address
|
Address |
getStart()
Get the start of the subspace
|
boolean |
indexInRange(int index)
Is an index in the range of this subspace?
|
void |
reset(Address start,
Address end,
int blockNum)
Reset a new subspace.
|
void |
reset(Address start,
Address end,
int firstIndex,
int blockNum)
Reset a new subspace
|
private void |
reset(Address start,
Address end,
int firstIndex,
int blockSize,
int blockNum)
Reset a subspace.
|
void |
reset(int firstIndex,
int blockNum)
Reset a new subspace.
|
int |
spaceRemaining(Address addr)
Calculate the space remaining in a block after this address
|
private Address start_
[start_, end_)
private Address end_
[start_, end_)
private int firstIndex_
start_
liesprivate int blockSize_
private int blockNum_
private static final boolean DEBUG
public Subspace(Address start, Address end, int firstIndex, int blockSize, int blockNum)
start
- The address of the start of the subspaceend
- The address of the end of the subspacefirstIndex
- The index of the first block of the subspaceblockSize
- The size of blocks in this spaceblockNum
- The number of blocks in this subspaceprivate void reset(Address start, Address end, int firstIndex, int blockSize, int blockNum)
start
- The address of the start of the subspaceend
- The address of the end of the subspacefirstIndex
- The index of the first block of the subspaceblockSize
- The size of blocks in this subspaceblockNum
- The number of blocks in this subspacepublic void reset(Address start, Address end, int firstIndex, int blockNum)
start
- The address of the start of the subspaceend
- The address of the end of the subspacefirstIndex
- The index of the first block of the subspaceblockNum
- The number of blocks in this subspacepublic void reset(Address start, Address end, int blockNum)
start
- The address of the start of the subspaceend
- The address of the end of the subspaceblockNum
- The number of blocks in this subspacepublic void reset(int firstIndex, int blockNum)
firstIndex
- The index of the first block of the subspaceblockNum
- The number of blocks in this subspacepublic boolean indexInRange(int index)
index
- The index of the blocktrue
if this block lies in this subspacepublic boolean addressInRange(Address addr)
addr
- An addresstrue
if this address is in a block in this subspacepublic int getIndex(Address addr)
addr
- The addresspublic Address getAddress(int index)
index
- The index of the blockpublic Address getStart()
public Address getEnd()
public int getFirstIndex()
public int getBlockSize()
public int getBlockNum()
public int spaceRemaining(Address addr)
addr
- the Addressprivate void dump()