public class FreeSpaceBitSet extends 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.
|
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.
|
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()
Copyright © 2017 JBoss by Red Hat. All rights reserved.