package Dic; import java.util.*; import java.io.*; import Add.*; import Fil.*; public class IndexData { private char id; private long volume = 0; private Vector child; private Vector address; public long position; public IndexData( char name) { 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; if(child.size() != 0) { pos = (max-small)/2+small; do { temp = pos; int comp = id.getName().compareTo(child.get(pos).getName()); if(comp > 0) { small = pos; max = max; pos = (max-small)/2 + small; } else if(comp ==0) { break; } else if(comp < 0) { small = small; max = pos; pos = (max-small)/2 + small; } }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 { 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 void free() { IndexData temp ; for(int i= 0;i