Class FileAllocationTree

  • All Implemented Interfaces:
    java.lang.Iterable<Region>, java.util.Collection<Region>, java.util.Set<Region>, java.util.SortedSet<Region>

    public final class FileAllocationTree
    extends AATreeSet<Region>
    File allocation tree allows C-like alloc/free operations on a random access file.
    Author:
    Chris Dennis
    • Constructor Summary

      Constructors 
      Constructor Description
      FileAllocationTree​(long maxSize, java.io.RandomAccessFile file)
      Create a file allocation tree for the given file, capping it's size at maxSize.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      Region alloc​(long size)
      Allocate a new region of the given size.
      void clear()
      Mark this whole file as free
      Region find​(long size)
      Find a region of the the given size.
      Region find​(java.lang.Object o)
      Find the node within this tree equal to the probe node.
      void free​(Region r)
      Mark this region as free.
      long getFileSize()
      Return the current occupied size of this file.
      void mark​(Region r)
      Mark this region as used
      Region removeAndReturn​(java.lang.Object o)
      Remove the node matching this object and return it.
      • Methods inherited from class java.util.AbstractSet

        equals, hashCode, removeAll
      • Methods inherited from class java.util.AbstractCollection

        addAll, contains, containsAll, retainAll, toArray, toArray, toString
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface java.util.Collection

        parallelStream, removeIf, stream, toArray
      • Methods inherited from interface java.lang.Iterable

        forEach
      • Methods inherited from interface java.util.Set

        addAll, contains, containsAll, equals, hashCode, removeAll, retainAll, toArray, toArray
      • Methods inherited from interface java.util.SortedSet

        spliterator
    • Constructor Detail

      • FileAllocationTree

        public FileAllocationTree​(long maxSize,
                                  java.io.RandomAccessFile file)
        Create a file allocation tree for the given file, capping it's size at maxSize.
    • Method Detail

      • alloc

        public Region alloc​(long size)
        Allocate a new region of the given size.
      • mark

        public void mark​(Region r)
        Mark this region as used
      • free

        public void free​(Region r)
        Mark this region as free.
      • clear

        public void clear()
        Mark this whole file as free
        Specified by:
        clear in interface java.util.Collection<Region>
        Specified by:
        clear in interface java.util.Set<Region>
        Overrides:
        clear in class AATreeSet<Region>
      • getFileSize

        public long getFileSize()
        Return the current occupied size of this file.
      • find

        public Region find​(java.lang.Object o)
        Description copied from class: AATreeSet
        Find the node within this tree equal to the probe node.
        Overrides:
        find in class AATreeSet<Region>
      • find

        public Region find​(long size)
        Find a region of the the given size.