Impletringearch preliminary study

  SimpleStringSearch preliminary study by lostfire 

  Today was originally the station will be a replacement procedure, I think of a couple of days ago to see SimpleStringSearch, read about, the station's results made no replacement procedures, the study of this. 
  I used dox made a chm documents (Download), but look at that document is of no use.    I do not know because the data structure, the original has not been related aspects. 
  So I modified the source code to print the information to finally clear his data organization. 

  First look at the kind of inheritance, the data structure is important, the search tree structure.    SearchTreeNode which is the interface, AbstractSearchTreeNode is below the succession of abstract categories, including the realization of specific ExactSearchTreeNode, SingleWildcardSearchTreeNode and WildcardSearchTreeNode. 
  To the members of the variables stored in the data storage AbstractSearchTreeNode Therefore, I add a print code, but also on the AbstractSearchTreeNode in. 
  ? 1public? String? ToString ()???????? StringBuffer? Buffer? =? New? StringBuffer (); 
  ? 3 ???????? 
  ? 4 ???????? buffer.append ( "Depth:" + depth + "\ t"); 
  ? 5 ???????? buffer.append ( "Children? Num:" + children.size ()); 
  ? 6 ???????? buffer.append ( "\ t" + "Character:" character + + "\ n"); 
  ? 7 ???????? depth + +; 
  ? 8 ???????? for (int? I = 0?;? I <children.size ();? I ++)???????????? SearchTreeNode? Stn? =? Children . get (i); 
  10 ???????????? buffer.append (stn.toString ()); 
  11 ????????} 
  12 ???????? depth -; 
  13 ???????? return? Buffer.toString (); 
  14 ????} depth is a record level of static int variable. 

  Below are the test code: 
  ? 1public? Static? Void? Main (String []? Args )????????????? try ???????????????????? StringSearch ? s? =? new? StringSearch (); 
  ? 4 ???????????????????? MyHitHandler? Handler? =? New? MyHitHandler ();???????????????? ? 
  ? 5 ???????????????????? s.addSearchTerm ( "do", the handler );???????????????? ? 
  ? 6 ???????????????????? s.addSearchTerm ( "Java", the handler); 
  ? 7 ???????????????????? s.addSearchTerm ( "ava," handler); 
  ? 8 ???????????????????? s.addSearchTerm ( "da", the handler); 
  ? 9 ???????????????????? System.out.println (s.getRoot (). To2String ()); 
  10 //???????????????????? s.getRoot (). PrintString (); 
  11 ???????????????????? s.search ( "Do,? Or? Do? Not.? Except? In? Java .?–? Yoda"); 
  12 ???????????????????? System.out.println ( "Count? Is :?"?+? handler.getCount ()); 
  13 ????????????} 
  14 ???????????? catch (IOException? Ex )???????????????????? ex.printStackTrace (); 
  16 ????????????} 
  17 ????} 

  Several prompting StringSearch inside this after following the formation of a binary tree. 
?
  Here we can see very clearly. 
  In the root below, no sort, and beneath each node, according to the search string order of binary search trees, it is not a standard binary search tree, but the order related characters retrieval. 

  Posted on 2006-06-04 02:20 lostfire reading (908) Comments (0) edit their collections quoted Category: other 

Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • del.icio.us
  • Facebook
  • DotNetKicks
  • DZone
  • Netvouz
  • Propeller

Recommend Articles

Comments

Leave a Reply