public Reference search(int val) { // find index of target node for next round search int p = this.findPtrIndex(val); Node target = this.getPtr(p); // call itself recursively Reference result = target.search(val); return result; }
private void changeActivePoint() { Node activeNode = act_point.getNode(); if (activeNode == root) { suffix ob = suffixes.peek(); if (ob == null) return; String st = doc[ob.start]; Edge ed = activeNode.search(st, remainder); act_point.setActiveEdge(ed); act_point.decActiveLength(); } else { if (activeNode.getSuffixLink() != null) { /* System.out.println("suffix link is not null "); System.out.println("previous active node was "+act_point.node.label); System.out.println("previous active edge was "+act_point.edge.label); System.out.println("active len was "+act_point.activeLength);*/ int a = (act_point.getEdge()).getStartIndex(); // System.out.println("starting of previous active edge was at index "+a+" with value // "+doc[a]); act_point.setActiveNode((activeNode.getSuffixLink()).getDest()); activeNode = act_point.getNode(); // System.out.println("active node is now "+act_point.node.label); String st = doc[a]; Edge ed = activeNode.search(st, remainder); act_point.setActiveEdge(ed); /* System.out.println(" active edge is now "+act_point.edge.label); System.out.println("active len is now "+act_point.activeLength);*/ } else { act_point.setActiveNode(root); activeNode = act_point.getNode(); suffix ob = suffixes.peek(); if (ob == null) return; String st = doc[ob.start]; Edge ed = activeNode.search(st, remainder); act_point.setActiveEdge(ed); // act_point.decActiveLength(); } } }
public LinkedList<T> search(double[][] range) { return root.search(range); }
protected Node search(K key) { int value = compare(key, this.key); if (value == 0) return this; if (value < 0) return left.search(key); return right.search(key); }
@SuppressWarnings({"unchecked"}) public boolean contains(Object o) { return belongs((K) o) && root.search((K) o) != nullNode; }
public void insert(String s, int index) { // change the current index of remaining suffixes // System.out.println(s+" being added in the tree------------------------"); // System.out.println(" index= "+index); suffix ob = new suffix(index); suffix.setCurrent(index); suffixes.add(ob); // change the current index of all leafedges // updateLeafEdges(index); LeafEdge.setCurrent(index); // insert the given suffix at the active point while (suffixes.isEmpty() == false) { Node activeNode = act_point.getNode(); Edge activeEdge = act_point.getEdge(); int act_len = act_point.getActiveLength(); // System.out.println("Active POINT is:::::::"); // System.out.println("active node is "+activeNode.label); // if(activeEdge==null) // System.out.println("active Edge is null "); // else // System.out.println("active Edge is "+activeEdge.label); // System.out.println("active length is "+act_len); // search at the active node for the given word that is to be inserted Edge EdgeOfWord = activeNode.search(s, index); if (activeEdge == null) { if (EdgeOfWord == null) { // insertion at the root.jst directly add the edge with the given string in the tree at // the root; // this edge will be a leaf edge Node dest = new Node(s); dest.label = "Node" + Nid; Nid++; LeafEdge ed = new LeafEdge(index, index, activeNode, dest); ed.label = "Edge" + Eid; Eid++; // this edge will be added to the set of leafedges leafEdges.add(ed); // add this edge to the map of edges in active node activeNode.add(s, ed); // remove the suffix inserted // change the current of suffixes // suffixes.remove(); // System.out.println(s+" added in tree"); suffix ob1 = suffixes.remove(); // printLeafEdges(); } else { // given word is present at the active node // update the active point // active node remains same // active edge is changed // active length is incremented // remainder is incremented act_point.setActiveEdge(EdgeOfWord); act_point.incActiveLength(); remainder++; checkWhetherActEdgeEndsOnNode(); // System.out.println(s+" already presnt in tree"); // System.out.println("activeLength is "+act_point.activeLength); // printLeafEdges(); break; } } else { // check whether active edge contains the word to be inserted // retrieve the word present at the active length in the active edge int pos = activeEdge.getTrueIndex(act_len); // System.out.println("check whether active edge contains the "+ s +" to be inserted"); // System.out.println("comparing "+s +"and positon "+pos +" in array doc"); if (s.equalsIgnoreCase(doc[pos])) { act_point.incActiveLength(); // System.out.println(" active edge contains "+ s +" to be inserted"); // System.out.println("activeLength is "+act_point.activeLength); remainder++; checkWhetherActEdgeEndsOnNode(); // printLeafEdges(); break; } else { // split the activeedge and create one new edge // set the end of active edge // System.out.println("at active node "+activeNode.label); // System.out.println("splitting activeEdge which stats with"+ // doc[(act_point.getEdge()).getStartIndex()]); activeEdge.setEnd(index); // System.out.println("set end of activeEdge to // "+doc[(act_point.getEdge()).getEndIndex()]); Node n1 = new Node(); n1.label = "Node" + Nid; Nid++; Node n2 = new Node(); n2.label = "Node" + Nid; Nid++; Node source = activeEdge.getDestNode(); int start = activeEdge.getStartIndex(); int end = activeEdge.getEndIndex(); // create 2 new leaf edges LeafEdge e1 = new LeafEdge(start + act_len, end, source, n1); e1.label = "Edge" + Eid; Eid++; LeafEdge e2 = new LeafEdge(end, end, source, n2); e2.label = "Edge" + Eid; Eid++; // System.out.println("create one new edge stating with "+doc[e1.getStartIndex()]+" and // ending with "+doc[e1.getEndIndex()]); // System.out.println("create second new edge stating with "+doc[e2.getStartIndex()]+" // and ending with "+doc[e2.getEndIndex()]); // add these leafedges to their respective nodes source.add(doc[start + act_len], e1); source.add(s, e2); // update end of active edge activeEdge.setEnd(start + act_len - 1); // System.out.println("set end of activeEdge to // "+doc[(act_point.getEdge()).getEndIndex()]); // remove active edge fom the set of leafedges leafEdges.remove(activeEdge); // add above 2 newly created leaf edges into the set of leafedges leafEdges.add(e1); leafEdges.add(e2); remainder--; addLink(source); suffix ob1 = suffixes.remove(); changeActivePoint(); // System.out.println("activeLength is "+act_point.activeLength); // printLeafEdges(); } } } if (suffixes.isEmpty() == true) { suffix.setCurrent(-1); link = null; } // printSuffixes(); }
public StartAndLen search(int index, String[] test) { StartAndLen obj = new StartAndLen(0); return root.search(index, test, doc, 0, obj); }
public ArrayList<MemoNode> search(MemoNode algorithm, int topx) { ArrayList<MemoNode> preambles = algorithm.getChildrenByValue("PreAmble", -1); ArrayList<MemoNode> patterns = algorithm.getChildrenByValue("Pattern", -1); return myNode.search(preambles, patterns, topx); }
public ArrayList<MemoNode> search(MemoNode preamble, MemoNode pattern, int topx) { return myNode.search(preamble, pattern, topx); }
public ArrayList<MemoNode> search( ArrayList<MemoNode> preambles, ArrayList<MemoNode> patterns, int topx) { return myNode.search(preambles, patterns, topx); }