1 21 package com.db4o.inside.freespace; 22 23 import com.db4o.*; 24 import com.db4o.foundation.*; 25 import com.db4o.inside.ix.*; 26 27 28 class FreespaceIxAddress extends FreespaceIx{ 29 30 FreespaceIxAddress(YapFile file, MetaIndex metaIndex){ 31 super(file, metaIndex); 32 } 33 34 void add(int address, int length) { 35 _index._handler.prepareComparison(new Integer (address)); 36 _indexTrans.add(length, new Integer (address)); 37 } 38 39 int address() { 40 return _visitor._value; 41 } 42 43 int length() { 44 return _visitor._key; 45 } 46 47 void remove(int address, int length) { 48 _index._handler.prepareComparison(new Integer (address)); 49 _indexTrans.remove(length, new Integer (address)); 50 } 51 52 int freeSize(){ 53 final MutableInt mint = new MutableInt(); 54 final IntObjectVisitor freespaceVisitor = new IntObjectVisitor(){ 55 public void visit(int anInt, Object anObject) { 56 mint.add(anInt); 57 } 58 }; 59 traverse(new Visitor4() { 60 public void visit(Object obj) { 61 ((IxTree)obj).visitAll(freespaceVisitor); 62 } 63 }); 64 return mint.value(); 65 } 66 } 67 | Popular Tags |