java - An unbounded set of hashes based on bounded sets of hashes based on paths -


Suppose that there is a tree, XML tree for logic and if you want to have a complete set of root paths for the node, Although you want to split that group into a group of i, where I specify the user.

For example an HTML document:

  / html / html / head / html / head / title / html / head / title / [text] / html / body For example, when I'm 3:  
  {{1, 11, 111}, {/ 1}, 11, 111}, / html / body / [text]  

1111, 12, 121}}

then becomes for example:

  {3, 4}  
< P> Using simplified tree classes which can only get node names; Get an array list of sub-streams; And check that this is a leaf node; What is the best way to make this set of hash?

Edit: See your sample solution answer below, it is far from optimal because it is very slow and probably not even the best approach.

My own solution is as follows, though I am unsure if this is the most to achieve this goal The effective way is ... maybe you can provide some insights into other Java's complexities.

  Public Arrestists & lt; Integer & gt; Makepathist (AbstraSttree & lt; String & gt; Tree) {StringBinder Buffer = New StringBuilder (); ArrayList & LT; Integer & gt; Pl = new arreelist & lt; Integer & gt; (); ArrayList & LT; StringBuilder & gt; Path = gatepath (tree, buffer); (Stringbilder sb: path) {pl.add (sb.toString (.); Hashode ()); } Return PL; } Public Arrestist & lt; Stringbuilder & gt; GetPaths (Abstraction End Lt; String & gt; Tree, StringBillder Parent) {ArrayList & lt; StringBuilder & gt; List = New Arrestist & lt; Stringbilder & gt; (); Parent.append ("/"); Parent.append (tree.getNodeName ()); List.add (new string builder); If (! Tree.isLeaf ()) {int i = 0; Iterator & LT; AbstractTree & LT; String & gt; & Gt; Baby = tree .get baby (). Iterator (); While (i & lt; tree.get Childen (). Size ()) {list.add all (getPaths (child.next), new stringbuilder (original))); I ++; }} Return list; } Public hashets & lt; Integer & gt; CreateShingleSet (ArrayList & lt; Integer & gt; Path, int shingleLength) {HashSet & lt; Integer & gt; ShingleSet = NewHashet & lt; Integer & gt; (); (Int i = 0; i & lt; paths.size (); i + = horny lang) {Multiset & lt; Integer & gt; Set = new multiset & lt; Integer & gt; (); For (int j = 0; j end lieant; horny langath; j ++) {if (i + j and lt; path size ()) set.ed (path gate (i + j)); } ShingleSet.add (set.hashCode ()); } Return shingleset; }  

EDIT: It is better to pass stringbilders for larger files

EDIT: For the same way to give the same hash code, Requires Enforcement


Comments