Exemple #1
0
 public void build(EventSet e) {
   for (int i = 0; i < e.size(); i++) {
     Event start = e.eventAt(i);
     if (!root.isEventInLevel(start)) {
       insertAtRoot(start, e, i);
     } else {
       insertBelowRoot(start, e, i);
     }
   }
   root.key = null;
 }
Exemple #2
0
 private void insertAtRoot(Event start, EventSet e, int offset) {
   root.addEventToLevel(start);
   XEDictionaryNode node;
   node = root;
   int j = offset;
   while (j < e.size() - 1) {
     node = node.get(e.eventAt(j));
     j++;
     // System.out.println("Adding Event: " + e.eventAt(j));
     node.addEventToLevel(e.eventAt(j));
   }
 }
Exemple #3
0
 public int find(EventSet e) {
   int matchlength = 0;
   boolean matched = false;
   XEDictionaryNode node = root;
   while ((matchlength < e.size()) && !matched) {
     if (node.isEventInLevel(e.eventAt(matchlength))) {
       node = node.get(e.eventAt(matchlength));
       matchlength++;
     } else {
       matched = true;
     }
   }
   return matchlength;
 }
Exemple #4
0
 private void insertBelowRoot(Event start, EventSet e, int offset) {
   XEDictionaryNode node;
   node = root;
   // System.out.println("Event at offset: " + e.eventAt(offset));
   node = node.get(e.eventAt(offset));
   int j = offset;
   boolean matches = true; // match the events up to a given level
   while (matches && (j < e.size() - 1)) {
     j++;
     if (node.isEventInLevel(e.eventAt(j))) {
       // System.out.println("Match at level: " + e.eventAt(j));
       node = node.get(e.eventAt(j));
     } else {
       matches = false;
     }
   }
   for (int i = j; i < e.size(); i++) {
     // System.out.println("Adding Event: " + e.eventAt(i));
     node.addEventToLevel(e.eventAt(i));
     node = node.get(e.eventAt(i));
   }
 }
Exemple #5
0
 void addEventToLevel(Event e) {
   XEDictionaryNode node = new XEDictionaryNode();
   node.key = e;
   child.put(e, node);
 }
Exemple #6
0
 @Override
 public String toString() {
   return root.toString();
 }