Class FreeSpaceBitSet


  • public class FreeSpaceBitSet
    extends java.lang.Object
    A free space bit set.
    • Constructor Summary

      Constructors 
      Constructor Description
      FreeSpaceBitSet​(int firstFreeBlock, int blockSize)
      Create a new free space map.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method 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.
      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()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • FreeSpaceBitSet

        public FreeSpaceBitSet​(int firstFreeBlock,
                               int blockSize)
        Create a new free space map.
        Parameters:
        firstFreeBlock - the first free block
        blockSize - the block size
    • Method Detail

      • clear

        public void clear()
        Reset the list.
      • isUsed

        public boolean isUsed​(long pos,
                              int length)
        Check whether one of the blocks is in use.
        Parameters:
        pos - the position in bytes
        length - the number of bytes
        Returns:
        true if a block is in use
      • isFree

        public boolean isFree​(long pos,
                              int length)
        Check whether one of the blocks is free.
        Parameters:
        pos - the position in bytes
        length - the number of bytes
        Returns:
        true if a block is free
      • allocate

        public long allocate​(int length)
        Allocate a number of blocks and mark them as used.
        Parameters:
        length - the number of bytes to allocate
        Returns:
        the start position in bytes
      • markUsed

        public void markUsed​(long pos,
                             int length)
        Mark the space as in use.
        Parameters:
        pos - the position in bytes
        length - the number of bytes
      • free

        public void free​(long pos,
                         int length)
        Mark the space as free.
        Parameters:
        pos - the position in bytes
        length - the number of bytes
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object