src/jdict/DictIndex.java
changeset 43 988a367ae8d2
parent 38 45c0a27c902f
equal deleted inserted replaced
41:b33eedeeabd3 43:988a367ae8d2
   442             }
   442             }
   443             test = getName();
   443             test = getName();
   444 
   444 
   445             if (test == null)
   445             if (test == null)
   446                 break;
   446                 break;
   447             if (test.startsWith(word))
   447             boolean does_start_with;
       
   448             does_start_with = test.startsWith(word);
       
   449             System.out.println("Prefix linear comparing to " + test +
       
   450                     ": " + does_start_with);
       
   451             if (does_start_with)
   448             {
   452             {
   449                 int offset = getOffset();
   453                 int offset = getOffset();
   450                 int length = getLength();
   454                 int length = getLength();
   451                 System.out.println("Definition for " + word + "("
   455                 System.out.println("Definition for " + word + "("
   452                         + test + ") at " +
   456                         + test + ") at " +
   546         Vector results = new Vector();
   550         Vector results = new Vector();
   547         int bounds[];
   551         int bounds[];
   548         int pivot = top_index / 2;
   552         int pivot = top_index / 2;
   549         int step = top_index / 2;
   553         int step = top_index / 2;
   550         boolean found = false;
   554         boolean found = false;
       
   555         boolean found_laste = false;
   551         String test;
   556         String test;
   552 
   557 
   553         /*
   558         /*
   554         System.gc();
   559         System.gc();
   555         */
   560         */
   594                 step = step / 2;
   599                 step = step / 2;
   595                 pivot = pivot - step;
   600                 pivot = pivot - step;
   596                 continue;
   601                 continue;
   597             }
   602             }
   598             int comparision = word.compareTo(test);
   603             int comparision = word.compareTo(test);
   599             /*
   604             System.out.println("Binary comparing to " + test +
   600             System.out.println("Comparing to " + bytesToString(test) +
       
   601                     ": " + new Integer(comparision).toString());
   605                     ": " + new Integer(comparision).toString());
   602                     */
       
   603             if (comparision <= 0)
   606             if (comparision <= 0)
   604             {
   607             {
   605                 /* If == 0, then we don't know that it is the
   608                 /* If == 0, then we don't know that it is the
   606                  * FIRST match possible in the dictionary.
   609                  * FIRST match possible in the dictionary.
   607                  * There may be more than one entry for the same word, and
   610                  * There may be more than one entry for the same word, and
   616         } while (step > 0);
   619         } while (step > 0);
   617 
   620 
   618         /* If we found the exact word in a non-last comparision,
   621         /* If we found the exact word in a non-last comparision,
   619          * it's possible that the final binary search points us
   622          * it's possible that the final binary search points us
   620          * to the word PREVIOUS to the good match. */
   623          * to the word PREVIOUS to the good match. */
   621         if (!word.startsWith(test))
   624         if (!test.startsWith(word))
   622         {
   625         {
       
   626             System.out.println("The word " + test +
       
   627                     " doesn't start with " + word);
   623             readUntilNewLine();
   628             readUntilNewLine();
   624         }
   629         }
   625         else
   630         else
   626         {
   631         {
   627             try {
   632             try {