/[gzz]/gzz/gzz/vob/OrthoCoordsysMap.java
ViewVC logotype

Diff of /gzz/gzz/vob/OrthoCoordsysMap.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.5 by benja, Thu Aug 22 17:26:57 2002 UTC revision 1.6 by tjl, Wed Sep 25 14:45:43 2002 UTC
# Line 22  OrthoCoordsysMap.java Line 22  OrthoCoordsysMap.java
22   */   */
23  package gzz.vob;  package gzz.vob;
24  class OrthoCoordsysMap {  class OrthoCoordsysMap {
     OrthoCoordsys sys;  
     int[] hashtable;  
     boolean canInterpolate;  
   
     OrthoCoordsysMap(OrthoCoordsys sys, int initialSize) {  
         this.sys = sys;  
         hashtable = new int[initialSize];  
         canInterpolate = true;  
     }  
   
     void clear() {  
         for(int i=0; i<hashtable.length; i++)  
             hashtable[i] = 0;  
         canInterpolate = true;  
     }  
   
     final int hash(int cs) {  
         return Math.abs(sys.key[cs].hashCode()) ^ sys.parent[cs];  
     }  
   
     void add(int cs) {  
         if(sys.key[cs] == null) return;  
         if(get(sys.parent[cs], sys.key[cs]) >= 0) {  
             canInterpolate = false; return;  
         }  
   
         if(sys.nsys > hashtable.length) { rehash(); return; }  
   
         int i = hash(cs) % hashtable.length;  
         sys.nextHashtableEntry[cs] = hashtable[i];  
         hashtable[i] = cs;  
     }  
   
     int get(int parent, Object key) {  
         if(key == null) return -1;  
         int hash = Math.abs(key.hashCode()) ^ parent;  
         int i = hash % hashtable.length;  
         int cs = hashtable[i];  
         while(cs > 0) {  
             if(parent == sys.parent[cs])  
                 if(key.equals(sys.key[cs]))  
                     return cs;  
   
             cs = sys.nextHashtableEntry[cs];  
         }  
         return -1;  
     }  
   
     void rehash() {  
         hashtable = new int[sys.nsys * 2];  
         for(int i=1; i<sys.nsys; i++)  
             add(i);  
     }  
25  }  }

Legend:
Removed from v.1.5  
changed lines
  Added in v.1.6

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26