net.metanotion.io.block

## Class FreeListBlock

- java.lang.Object
- - net.metanotion.io.block.FreeListBlock

-     class FreeListBlock
      extends Object

  Manages free pages in a block file.

  Tracks available pages for allocation using a linked list of blocks. Each block contains multiple free page references and fits on a single disk page.

  On-disk format:

          Magic number (long)
          next freelist block page (unsigned int)
          size (unsigned int)
          that many free pages (unsigned ints)

  Free page format:

          Magic number (long)

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `int` | `page`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `FreeListBlock(RandomAccessInterface file, int startPage)`

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addPage(int freePage)` Adds free page and writes new len to disk
    `boolean` | `flbck(boolean fix)` Recursive.
    `int` | `getNextPage()`
    `static void` | `initPage(RandomAccessInterface file, int page)`
    `boolean` | `isEmpty()`
    `boolean` | `isFull()`
    `void` | `setNextPage(int nxt)` Set and write the next page only
    `int` | `takePage()` Takes next page and writes new len to disk
    `String` | `toString()`
    `void` | `writeBlock()`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Field Detail

    - #### page

          public final int page

  - ### Constructor Detail

    - #### FreeListBlock

          public FreeListBlock(RandomAccessInterface file,
                               int startPage)
                        throws IOException

      Throws:
        `IOException`

  - ### Method Detail

    - #### addPage

          public void addPage(int freePage)
                       throws IOException

      Adds free page and writes new len to disk
      Throws:
        `IllegalStateException` - if full
        `IOException`

    - #### flbck

          public boolean flbck(boolean fix)
                        throws IOException

      Recursive.
      Throws:
        `IOException`

    - #### getNextPage

          public int getNextPage()

    - #### initPage

          public static void initPage(RandomAccessInterface file,
                                      int page)
                               throws IOException

      Throws:
        `IOException`

    - #### isEmpty

          public boolean isEmpty()

    - #### isFull

          public boolean isFull()

    - #### setNextPage

          public void setNextPage(int nxt)
                           throws IOException

      Set and write the next page only
      Throws:
        `IOException`

    - #### takePage

          public int takePage()
                       throws IOException

      Takes next page and writes new len to disk
      Throws:
        `IllegalStateException` - if empty
        `IOException`

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

    - #### writeBlock

          public void writeBlock()
                          throws IOException

      Throws:
        `IOException`