Пример #1
0
 public OutgoingTransitionsMap(CompressedDAWGNode cparent, boolean desc) {
   this.cparent = cparent;
   this.desc = desc;
   from = cparent.getTransitionSetBeginIndex();
   to = from + (cparent.getOutgoingTransitionsSize() - 1) * transitionSizeInInts;
   fromChars = cparent.getIndex() + 1;
   toChars = cparent.getIndex() + transitionSizeInInts - 1;
 }
Пример #2
0
 @Override
 Collection<? extends DAWGNode> getNodesBySuffix(String suffix) {
   char suffixText[] = suffix.toCharArray();
   char lastChar = suffixText[suffixText.length - 1];
   Iterable<CompressedDAWGNode> ret = getEndNode().getIncomingTransitions(lastChar);
   for (int i = suffixText.length - 1; i >= 0; i--) {
     List<CompressedDAWGNode> levelNodes = new ArrayList<CompressedDAWGNode>();
     char c = suffixText[i];
     for (CompressedDAWGNode node : ret)
       if (node.getId() != DAWGNode.START)
         for (CompressedDAWGNode incoming : node.getIncomingTransitions(c))
           levelNodes.add(incoming);
     if (i == 0) return levelNodes;
     ret = levelNodes;
   }
   // This can never happen.
   // If the string is empty then an ArrayIndexOutOfBoundsException would be thrown
   // when trying to get the last char of suffix.
   // If the string is not empty then a loop would be entered and a list would be
   // returned at last iteration.
   throw new IllegalArgumentException("This method should not be called on empty strings");
 }
Пример #3
0
 public IncomingTransitionsMap(CompressedDAWGNode cparent, boolean desc) {
   this.cparent = cparent;
   this.desc = desc;
   int index = cparent.getIndex();
   // Start node has no incoming transitions.
   if (index == DAWGNode.START) {
     from = 1;
     to = 0;
   } else {
     // End node is located at the beginning.
     if (index == DAWGNode.END) index = 0;
     from = incomingData[index + 1];
     to = from + (incomingData[index + 2] - 1) * INCOMING_TRANSITION_SIZE_IN_INTS;
   }
 }
Пример #4
0
 @Override
 public boolean isEmpty() {
   return cparent.getOutgoingTransitionsSize() == 0;
 }
Пример #5
0
 private void countNodes(CompressedDAWGNode node, HashSet<Integer> nodeIDHashSet) {
   if (node.getOutgoingTransitionsSize() != 0)
     nodeIDHashSet.add(node.getTransitionSetBeginIndex());
   for (CompressedDAWGNode child : node.getOutgoingTransitionsNodes())
     countNodes(child, nodeIDHashSet);
 }
Пример #6
0
 int getMaxLength(CompressedDAWGNode node, int length) {
   int ret = length;
   for (CompressedDAWGNode child : node.getOutgoingTransitionsNodes())
     ret = Math.max(ret, getMaxLength(child, length + 1));
   return ret;
 }