public class FreeSpaceBitSet
extends java.lang.Object
| Constructor and Description |
|---|
FreeSpaceBitSet(int firstFreeBlock,
int blockSize)
Create a new free space map.
|
| Modifier and Type | Method and Description |
|---|---|
long |
allocate(int length)
Allocate a number of blocks and mark them as used.
|
void |
clear()
Reset the list.
|
void |
free(long pos,
int length)
Mark the space as free.
|
int |
getFillRate()
Get the fill rate of the space in percent.
|
long |
getFirstFree()
Get the position of the first free space.
|
long |
getLastFree()
Get the position of the last (infinite) free space.
|
boolean |
isFree(long pos,
int length)
Check whether one of the blocks is free.
|
boolean |
isUsed(long pos,
int length)
Check whether one of the blocks is in use.
|
void |
markUsed(long pos,
int length)
Mark the space as in use.
|
java.lang.String |
toString() |
public FreeSpaceBitSet(int firstFreeBlock,
int blockSize)
firstFreeBlock - the first free blockblockSize - the block sizepublic void clear()
public boolean isUsed(long pos,
int length)
pos - the position in byteslength - the number of bytespublic boolean isFree(long pos,
int length)
pos - the position in byteslength - the number of bytespublic long allocate(int length)
length - the number of bytes to allocatepublic void markUsed(long pos,
int length)
pos - the position in byteslength - the number of bytespublic void free(long pos,
int length)
pos - the position in byteslength - the number of bytespublic int getFillRate()
public long getFirstFree()
public long getLastFree()
public java.lang.String toString()
toString in class java.lang.Object