/** * @return the number of strings that are matched by the given pattern. * @throws StackOverflowError * if the given pattern generates a large, possibly infinite, number of strings. */ public long matchedStringsSize() { buildRootNode(); return rootNode.getNbrMatchedString(); }
/** * @return the number of strings that are matched by the given pattern. * @throws StackOverflowError if the given pattern generates a large, possibly infinite, number of strings. */ public long matchedStringsSize() { buildRootNode(); return rootNode.getNbrMatchedString(); }
/** * Calculate the number of string that will be generated until the * transaction presented by this node, and set the result in * <code>nbrMatchedString</code>. */ public void updateNbrMatchedString() { if (isNbrMatchedStringUpdated) return; if (nextNodes.size() == 0) nbrMatchedString = nbrChar; else for (Node childNode : nextNodes) { childNode.updateNbrMatchedString(); long childNbrChar = childNode.getNbrMatchedString(); nbrMatchedString += nbrChar * childNbrChar; } isNbrMatchedStringUpdated = true; }
/** * Calculate the number of string that will be generated until the * transaction presented by this node, and set the result in * <code>nbrMatchedString</code>. */ public void updateNbrMatchedString() { if (isNbrMatchedStringUpdated) return; if (nextNodes.size() == 0) nbrMatchedString = nbrChar; else for (Node childNode : nextNodes) { childNode.updateNbrMatchedString(); long childNbrChar = childNode.getNbrMatchedString(); nbrMatchedString += nbrChar * childNbrChar; } isNbrMatchedStringUpdated = true; }
private String buildStringFromNode(Node node, int indexOrder) { String result = ""; long passedStringNbr = 0; long step = node.getNbrMatchedString() / node.getNbrChar(); for (char usedChar = node.getMinChar(); usedChar <= node.getMaxChar(); ++ usedChar) { passedStringNbr += step; if (passedStringNbr >= indexOrder) { passedStringNbr -= step; indexOrder -= passedStringNbr; result = result.concat("" + usedChar); break; } } long passedStringNbrInChildNode = 0; if (result.length() == 0) passedStringNbrInChildNode = passedStringNbr; for (Node childN : node.getNextNodes()) { passedStringNbrInChildNode += childN.getNbrMatchedString(); if (passedStringNbrInChildNode >= indexOrder) { passedStringNbrInChildNode -= childN.getNbrMatchedString(); indexOrder -= passedStringNbrInChildNode; result = result.concat(buildStringFromNode(childN, indexOrder)); break; } } return result; }
private String buildStringFromNode(Node node, int indexOrder) { String result = ""; long passedStringNbr = 0; long step = node.getNbrMatchedString() / node.getNbrChar(); for (char usedChar = node.getMinChar(); usedChar <= node.getMaxChar(); ++usedChar) { passedStringNbr += step; if (passedStringNbr >= indexOrder) { passedStringNbr -= step; indexOrder -= passedStringNbr; result = result.concat("" + usedChar); break; } } long passedStringNbrInChildNode = 0; if (result.length() == 0) passedStringNbrInChildNode = passedStringNbr; for (Node childN : node.getNextNodes()) { passedStringNbrInChildNode += childN.getNbrMatchedString(); if (passedStringNbrInChildNode >= indexOrder) { passedStringNbrInChildNode -= childN.getNbrMatchedString(); indexOrder -= passedStringNbrInChildNode; result = result.concat(buildStringFromNode(childN, indexOrder)); break; } } return result; }