Package net.sf.ehcache.store.disk.ods
Class FileAllocationTree
- java.lang.Object
-
- java.util.AbstractCollection<E>
-
- java.util.AbstractSet<T>
-
- net.sf.ehcache.store.disk.ods.AATreeSet<Region>
-
- net.sf.ehcache.store.disk.ods.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
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class net.sf.ehcache.store.disk.ods.AATreeSet
AATreeSet.AbstractTreeNode<E>, AATreeSet.Node<E>
-
-
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 Regionalloc(long size)Allocate a new region of the given size.voidclear()Mark this whole file as freeRegionfind(long size)Find a region of the the given size.Regionfind(java.lang.Object o)Find the node within this tree equal to the probe node.voidfree(Region r)Mark this region as free.longgetFileSize()Return the current occupied size of this file.voidmark(Region r)Mark this region as usedRegionremoveAndReturn(java.lang.Object o)Remove the node matching this object and return it.-
Methods inherited from class net.sf.ehcache.store.disk.ods.AATreeSet
add, comparator, first, getRoot, headSet, isEmpty, iterator, last, remove, size, subSet, tailSet
-
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
-
-
-
-
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
-
getFileSize
public long getFileSize()
Return the current occupied size of this file.
-
removeAndReturn
public Region removeAndReturn(java.lang.Object o)
Description copied from class:AATreeSetRemove the node matching this object and return it.- Overrides:
removeAndReturnin classAATreeSet<Region>
-
find
public Region find(java.lang.Object o)
Description copied from class:AATreeSetFind the node within this tree equal to the probe node.
-
find
public Region find(long size)
Find a region of the the given size.
-
-