import java.util.*; import java.io.*; public class IndexData { private char id; private long volume = 0; // private LinkedList child; private Vector child; private Vector address; public long position; public IndexData( char name) { // child = new LinkedList(); child = new Vector(); address = new Vector(); id = name; } public int ChildSize() { return child.size(); } public String getName() { return (new Character(id)).toString(); } public char getID() { return id; } public void setID(char id) { this.id = id; } public void addChild(IndexData id) { int small = 0; int max = child.size(); int pos = 0; int temp = 0; //System.out.println("!ALL!"+ child.get(i).getName()); /* System.out.println("this is *" + id.getName()+"*"); for(int i= 0 ; i= max ){child.insertElementAt(id,pos);break;} // if(pos <=small){child.insertElementAt(id,pos);break;} int comp = id.getName().compareTo(child.get(pos).getName()); if(comp > 0) { //if(pos == max){break;} // System.out.println("+"); small = pos; max = max; pos = (max-small)/2 + small; } else if(comp ==0) { break; } else if(comp < 0) { //if(small == pos){break;} // System.out.println("-"); small = small; max = pos; pos = (max-small)/2 + small; //System.out.println(pos); } }while(temp != pos); if( pos < child.size()-1 && id.getName().compareTo(child.get(pos+1).getName()) > 0) { child.insertElementAt(id,pos+1); } else if(0 < pos && id.getName().compareTo(child.get(pos-1).getName()) < 0) { child.insertElementAt(id,pos-1); } else if(id.getName().compareTo(child.get(pos).getName()) > 0) { child.insertElementAt(id,pos+1); } else { child.insertElementAt(id,pos); } } else { // System.out.println("sf"); child.addElement(id); } } public IndexData getChild(int i) { if( i < child.size() ) { return (IndexData)child.get(i); } return null; } public IndexData getChild() { if(child.size() != 0) { return (IndexData)child.get(0); } return null; } public void addAddress(Address str) { address.addElement(str); } public Address getAddress() { return (Address)address.get(0); } public long VolumePlus(long plus) { volume +=plus; return volume; } public long getVolumu() { return volume; } public IndexData search(char c) { for(int i=0; i < child.size();i++) { if( ((IndexData)child.get(i)).getID() == c) { return (IndexData)child.get(i); } } return null; } public int getHeadSize() { return 2+8+8+ ChildSize()*(2+8); } public long getSaveSize() { long sum = 0; sum += getHeadSize(); for(int i= 0;i