private void RegenerateTree() { List <String> names = new List <string>(); foreach (Node n in Entries) { names.Add(n.Name); } PatriciaTreeGenerator p = PatriciaTreeGenerator.Generate(names.ToArray()); bool first = true; foreach (var v in p.TreeNodes) { if (first) { v.idxEntry = -1; RootNode.LeftIndex = (ushort)(v.left.idxEntry + 1); RootNode.RightIndex = (ushort)(v.right.idxEntry + 1); RootNode.RefBit = 0xFFFFFFFF; first = false; continue; } Entries[v.idxEntry].LeftIndex = (ushort)(v.left.idxEntry + 1); Entries[v.idxEntry].RightIndex = (ushort)(v.right.idxEntry + 1); Entries[v.idxEntry].RefBit = (uint)v.refbit; } }
public static PatriciaTreeGenerator Generate(string[] Names) { int length = 0; foreach (String n in Names) if (n.Length > length) length = n.Length; PatriciaTreeGenerator p = new PatriciaTreeGenerator(length); for (int i = 0; i < Names.Length; i++) { p.AddPatTreeNode(Names[i], i); } p.Sort(); return p; }
public static PatriciaTreeGenerator Generate(string[] Names) { int length = 0; foreach (String n in Names) { if (n.Length > length) { length = n.Length; } } PatriciaTreeGenerator p = new PatriciaTreeGenerator(length); for (int i = 0; i < Names.Length; i++) { p.AddPatTreeNode(Names[i], i); } p.Sort(); return(p); }