com.googlecode.concurrenttrees.common.KeyValuePair Java Examples

The following examples show how to use com.googlecode.concurrenttrees.common.KeyValuePair. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AutoCompleteComponent.java    From openvisualtraceroute with GNU Lesser General Public License v3.0 6 votes vote down vote up
private void getAutoCompleteValues(final String search) {
	final Future<?> f = _future.getAndSet(_executor.submit(() -> {
		try {
			final List<KeyValuePair<Integer>> values = _provider.getFromHistory(search);
			final Future<?> current = _future.getAndSet(null);
			if (current != null) {
				// if null, been cancelled
				asyncAutoComplete(values);
			}
		} catch (final Throwable e) {
			LOGGER.error("Fail to get autocomplete", e);
			JOptionPane.showMessageDialog(null, "failed " + Arrays.toString(ExceptionUtils.getStackFrames(e)));
		}
	}));
	if (f != null) {
		f.cancel(true);
	}
}
 
Example #2
Source File: ConcurrentInvertedRadixTree.java    From concurrent-trees with Apache License 2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public Iterable<KeyValuePair<O>> getKeyValuePairsForKeysPrefixing(final CharSequence document) {
    return new Iterable<KeyValuePair<O>>() {
        @Override
        public Iterator<KeyValuePair<O>> iterator() {
            return new LazyIterator<KeyValuePair<O>>() {
                Iterator<KeyValuePair<O>> matchesForCurrentSuffix = radixTree.scanForKeysAtStartOfInput(document).iterator();

                @Override
                protected KeyValuePair<O> computeNext() {
                    if (matchesForCurrentSuffix.hasNext()) {
                        return matchesForCurrentSuffix.next();
                    }
                    else {
                        return endOfData();
                    }
                }
            };
        }
    };
}
 
Example #3
Source File: ConcurrentInvertedRadixTree.java    From concurrent-trees with Apache License 2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public Iterable<O> getValuesForKeysPrefixing(final CharSequence document) {
    return new Iterable<O>() {
        @Override
        public Iterator<O> iterator() {
            return new LazyIterator<O>() {
                Iterator<KeyValuePair<O>> matchesForCurrentSuffix = radixTree.scanForKeysAtStartOfInput(document).iterator();

                @Override
                protected O computeNext() {
                    if (matchesForCurrentSuffix.hasNext()) {
                        return matchesForCurrentSuffix.next().getValue();
                    }
                    else {
                        return endOfData();
                    }
                }
            };
        }
    };
}
 
Example #4
Source File: ConcurrentInvertedRadixTree.java    From concurrent-trees with Apache License 2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public Iterable<CharSequence> getKeysPrefixing(final CharSequence document) {
    return new Iterable<CharSequence>() {
        @Override
        public Iterator<CharSequence> iterator() {
            return new LazyIterator<CharSequence>() {
                Iterator<KeyValuePair<O>> matchesForCurrentSuffix = radixTree.scanForKeysAtStartOfInput(document).iterator();

                @Override
                protected CharSequence computeNext() {
                    if (matchesForCurrentSuffix.hasNext()) {
                        return matchesForCurrentSuffix.next().getKey();
                    }
                    else {
                        return endOfData();
                    }
                }
            };
        }
    };
}
 
Example #5
Source File: ConcurrentSuffixTree.java    From concurrent-trees with Apache License 2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public Iterable<KeyValuePair<O>> getKeyValuePairsForKeysEndingWith(final CharSequence suffix) {
    return new Iterable<KeyValuePair<O>>() {
        @Override
        public Iterator<KeyValuePair<O>> iterator() {
            return new LazyIterator<KeyValuePair<O>>() {
                Iterator<String> originalKeys = nullSafeIterator(radixTree.getValueForExactKey(suffix));

                @Override
                protected KeyValuePair<O> computeNext() {
                    String originalKey = null;
                    O value = null;
                    while (value == null) {
                        if (!originalKeys.hasNext()) {
                            return endOfData();
                        }
                        originalKey = originalKeys.next();
                        value = valueMap.get(originalKey);
                    }
                    return new ConcurrentRadixTree.KeyValuePairImpl<O>(originalKey, value);
                }
            };
        }
    };
}
 
Example #6
Source File: ConcurrentRadixTree.java    From concurrent-trees with Apache License 2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public Iterable<KeyValuePair<O>> getKeyValuePairsForKeysStartingWith(CharSequence prefix) {
    SearchResult searchResult = searchTree(prefix);
    Classification classification = searchResult.classification;
    switch (classification) {
        case EXACT_MATCH: {
            return getDescendantKeyValuePairs(prefix, searchResult.nodeFound);
        }
        case KEY_ENDS_MID_EDGE: {
            // Append the remaining characters of the edge to the key.
            // For example if we searched for CO, but first matching node was COFFEE,
            // the key associated with the first node should be COFFEE...
            CharSequence edgeSuffix = CharSequences.getSuffix(searchResult.nodeFound.getIncomingEdge(), searchResult.charsMatchedInNodeFound);
            prefix = CharSequences.concatenate(prefix, edgeSuffix);
            return getDescendantKeyValuePairs(prefix, searchResult.nodeFound);
        }
        default: {
            // Incomplete match means key is not a prefix of any node...
            return Collections.emptySet();
        }
    }
}
 
Example #7
Source File: LocalRouteStore.java    From onos with Apache License 2.0 5 votes vote down vote up
/**
 * Returns all routes in the route table.
 *
 * @return all routes
 */
public Collection<Route> getRoutes() {
    Iterator<KeyValuePair<Route>> it =
            routeTable.getKeyValuePairsForKeysStartingWith("").iterator();

    List<Route> routes = new LinkedList<>();

    while (it.hasNext()) {
        KeyValuePair<Route> entry = it.next();
        routes.add(entry.getValue());
    }

    return routes;
}
 
Example #8
Source File: ConcurrentRadixTreeTest.java    From concurrent-trees with Apache License 2.0 5 votes vote down vote up
@Test
public void testKeyValuePair_EqualsAndHashCode() {
    KeyValuePair<Integer> pair1 = new ConcurrentRadixTree.KeyValuePairImpl<Integer>("FOO", 5);
    KeyValuePair<Integer> pair2 = new ConcurrentRadixTree.KeyValuePairImpl<Integer>("FOO", 6);
    KeyValuePair<Integer> pair3 = new ConcurrentRadixTree.KeyValuePairImpl<Integer>("BAR", 5);
    assertTrue(pair1.equals(pair1));
    assertTrue(pair1.equals(pair2));
    assertFalse(pair1.equals(pair3));
    //noinspection NullableProblems,ObjectEqualsNull
    assertFalse(pair1.equals(null));
    //noinspection EqualsBetweenInconvertibleTypes
    assertFalse(pair1.equals("FOO"));
    assertTrue(pair1.hashCode() == pair2.hashCode());
    assertFalse(pair1.hashCode() == pair3.hashCode());
}
 
Example #9
Source File: ConcurrentRadixTreeTest.java    From concurrent-trees with Apache License 2.0 5 votes vote down vote up
@Test
public void testKeyValuePair_Accessor() {
    KeyValuePair<Integer> pair = new ConcurrentRadixTree.KeyValuePairImpl<Integer>("FOO", 5);
    assertEquals(pair.getKey(), "FOO");
    assertEquals(pair.getValue(), Integer.valueOf(5));
    assertEquals("(FOO, 5)", pair.toString());
}
 
Example #10
Source File: ConcurrentInvertedRadixTree.java    From concurrent-trees with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public Iterable<KeyValuePair<O>> getKeyValuePairsForKeysContainedIn(final CharSequence document) {
    return new Iterable<KeyValuePair<O>>() {
        @Override
        public Iterator<KeyValuePair<O>> iterator() {
            return new LazyIterator<KeyValuePair<O>>() {
                Iterator<CharSequence> documentSuffixes = CharSequences.generateSuffixes(document).iterator();
                Iterator<KeyValuePair<O>> matchesForCurrentSuffix = Collections.<KeyValuePair<O>>emptyList().iterator();

                @Override
                protected KeyValuePair<O> computeNext() {
                    while(!matchesForCurrentSuffix.hasNext()) {
                        if (documentSuffixes.hasNext()) {
                            CharSequence nextSuffix = documentSuffixes.next();
                            matchesForCurrentSuffix = radixTree.scanForKeysAtStartOfInput(nextSuffix).iterator();
                        }
                        else {
                            return endOfData();
                        }
                    }
                    return matchesForCurrentSuffix.next();
                }
            };
        }
    };
}
 
Example #11
Source File: ConcurrentInvertedRadixTree.java    From concurrent-trees with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public Iterable<O> getValuesForKeysContainedIn(final CharSequence document) {
    return new Iterable<O>() {
        @Override
        public Iterator<O> iterator() {
            return new LazyIterator<O>() {
                Iterator<CharSequence> documentSuffixes = CharSequences.generateSuffixes(document).iterator();
                Iterator<KeyValuePair<O>> matchesForCurrentSuffix = Collections.<KeyValuePair<O>>emptyList().iterator();

                @Override
                protected O computeNext() {
                    while(!matchesForCurrentSuffix.hasNext()) {
                        if (documentSuffixes.hasNext()) {
                            CharSequence nextSuffix = documentSuffixes.next();
                            matchesForCurrentSuffix = radixTree.scanForKeysAtStartOfInput(nextSuffix).iterator();
                        }
                        else {
                            return endOfData();
                        }
                    }
                    return matchesForCurrentSuffix.next().getValue();
                }
            };
        }
    };
}
 
Example #12
Source File: ConcurrentInvertedRadixTree.java    From concurrent-trees with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public Iterable<CharSequence> getKeysContainedIn(final CharSequence document) {
    return new Iterable<CharSequence>() {
        @Override
        public Iterator<CharSequence> iterator() {
            return new LazyIterator<CharSequence>() {
                Iterator<CharSequence> documentSuffixes = CharSequences.generateSuffixes(document).iterator();
                Iterator<KeyValuePair<O>> matchesForCurrentSuffix = Collections.<KeyValuePair<O>>emptyList().iterator();

                @Override
                protected CharSequence computeNext() {
                    while(!matchesForCurrentSuffix.hasNext()) {
                        if (documentSuffixes.hasNext()) {
                            CharSequence nextSuffix = documentSuffixes.next();
                            matchesForCurrentSuffix = radixTree.scanForKeysAtStartOfInput(nextSuffix).iterator();
                        }
                        else {
                            return endOfData();
                        }
                    }
                    return matchesForCurrentSuffix.next().getKey();
                }
            };
        }
    };
}
 
Example #13
Source File: RibManager.java    From atrium-odl with Apache License 2.0 5 votes vote down vote up
@Override
public Collection<RouteEntry> getRoutes4() {
	Iterator<KeyValuePair<RouteEntry>> it = ribTable4.getKeyValuePairsForKeysStartingWith("").iterator();

	List<RouteEntry> routes = new LinkedList<>();

	while (it.hasNext()) {
		KeyValuePair<RouteEntry> entry = it.next();
		routes.add(entry.getValue());
	}
	return routes;
}
 
Example #14
Source File: AutoCompleteProvider.java    From openvisualtraceroute with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Get from history
 * @param prefix
 * @return
 */
public List<KeyValuePair<Integer>> getFromHistory(final String prefix) {
	final List<KeyValuePair<Integer>> res = new ArrayList<>();
	final Iterable<KeyValuePair<Integer>> entries = _tree.getKeyValuePairsForKeysStartingWith(prefix);
	for (final KeyValuePair<Integer> entry : entries) {
		res.add(entry);
	}
	Collections.sort(res, _comp);
	return res.subList(0, Math.min(res.size(), MAX));
}
 
Example #15
Source File: FetchDataItem.java    From NioImapClient with Apache License 2.0 5 votes vote down vote up
public static FetchDataItemType getFetchType(String word) {
  TREE.getKeyValuePairsForClosestKeys(word);
  Iterator<KeyValuePair<FetchDataItemType>> responseType = TREE.getKeyValuePairsForClosestKeys(word).iterator();
  if (!responseType.hasNext()) {
    return INVALID;
  }

  KeyValuePair<FetchDataItemType> candidate = responseType.next();

  if (word.equalsIgnoreCase(candidate.getKey().toString())) {
    return candidate.getValue();
  } else {
    return INVALID;
  }
}
 
Example #16
Source File: ConcurrentRadixTree.java    From concurrent-trees with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings({"JavaDoc"})
<O> Iterable<KeyValuePair<O>> getDescendantKeyValuePairs(final CharSequence startKey, final Node startNode) {
    return new Iterable<KeyValuePair<O>> () {
        @Override
        public Iterator<KeyValuePair<O>> iterator() {
            return new LazyIterator<KeyValuePair<O>>() {
                Iterator<NodeKeyPair> descendantNodes = lazyTraverseDescendants(startKey, startNode).iterator();

                @Override
                protected KeyValuePair<O> computeNext() {
                    // Traverse to the next matching node in the tree and return its key and value...
                    while (descendantNodes.hasNext()) {
                        NodeKeyPair nodeKeyPair = descendantNodes.next();
                        Object value = nodeKeyPair.node.getValue();
                        if (value != null) {
                            // Dealing with a node explicitly added to tree (rather than an automatically-added split node).

                            // Call the transformKeyForResult method to allow key to be transformed before returning to client.
                            // Used by subclasses such as ReversedRadixTree implementations...
                            CharSequence optionallyTransformedKey = transformKeyForResult(nodeKeyPair.key);

                            // -> Convert the CharSequence to a String before returning, to avoid set equality issues,
                            // because equals() and hashCode() is not specified by the CharSequence API contract...
                            String keyString = CharSequences.toString(optionallyTransformedKey);
                            return new KeyValuePairImpl<O>(keyString, value);
                        }
                    }
                    // Finished traversing the tree, no more matching nodes to return...
                    return endOfData();
                }
            };
        }
    };
}
 
Example #17
Source File: ConcurrentInvertedRadixTree.java    From concurrent-trees with Apache License 2.0 4 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public CharSequence getLongestKeyPrefixing(CharSequence document) {
    KeyValuePair<O> match = radixTree.scanForLongestKeyAtStartOfInput(document);
    return match == null ? null : match.getKey();
}
 
Example #18
Source File: DefaultResolvedRouteStore.java    From onos with Apache License 2.0 4 votes vote down vote up
/**
 * Returns all routes in the route table.
 *
 * @return all routes
 */
public Collection<ResolvedRoute> getRoutes() {
    return Tools.stream(routeTable.getKeyValuePairsForKeysStartingWith(""))
            .map(KeyValuePair::getValue)
            .collect(GuavaCollectors.toImmutableList());
}
 
Example #19
Source File: ConcurrentReversedRadixTree.java    From concurrent-trees with Apache License 2.0 4 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public Iterable<KeyValuePair<O>> getKeyValuePairsForKeysEndingWith(CharSequence suffix) {
    return radixTree.getKeyValuePairsForKeysStartingWith(CharSequences.reverse(suffix));
}
 
Example #20
Source File: ConcurrentInvertedRadixTree.java    From concurrent-trees with Apache License 2.0 4 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public KeyValuePair<O> getKeyValuePairForLongestKeyPrefixing(CharSequence document) {
    return radixTree.scanForLongestKeyAtStartOfInput(document);
}
 
Example #21
Source File: ConcurrentInvertedRadixTree.java    From concurrent-trees with Apache License 2.0 4 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public O getValueForLongestKeyPrefixing(CharSequence document) {
    KeyValuePair<O> match = radixTree.scanForLongestKeyAtStartOfInput(document);
    return match == null ? null : match.getValue();
}
 
Example #22
Source File: ConcurrentInvertedRadixTree.java    From concurrent-trees with Apache License 2.0 4 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public Iterable<KeyValuePair<O>> getKeyValuePairsForClosestKeys(CharSequence candidate) {
    return radixTree.getKeyValuePairsForClosestKeys(candidate);
}
 
Example #23
Source File: ConcurrentInvertedRadixTree.java    From concurrent-trees with Apache License 2.0 4 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public Iterable<KeyValuePair<O>> getKeyValuePairsForKeysStartingWith(CharSequence prefix) {
    return radixTree.getKeyValuePairsForKeysStartingWith(prefix);
}
 
Example #24
Source File: ConcurrentInvertedRadixTree.java    From concurrent-trees with Apache License 2.0 4 votes vote down vote up
/**
 * Traverses the tree based on characters in the given input, and returns the longest key in the tree
 * which is a prefix of the input, and its associated value.
 * <p/>
 * This uses a similar algorithm as {@link #scanForKeysAtStartOfInput(CharSequence)} except it returns
 * the last result that would be returned, however this algorithm locates the last node more efficiently
 * by creating garbage objects during traversal due to not having to return the intermediate results.
 *
 * @param input A sequence of characters which controls traversal of the tree
 * @return The longest key in the tree which is a prefix of the input, and its associated value;
 * or null if no such key is contained in the tree
 */
protected KeyValuePair<O> scanForLongestKeyAtStartOfInput(final CharSequence input) {
    Node currentNode = root;
    int charsMatched = 0;

    final int documentLength = input.length();

    Node candidateNode = null;
    int candidateCharsMatched = 0;

    outer_loop: while (charsMatched < documentLength) {
        Node nextNode = currentNode.getOutgoingEdge(input.charAt(charsMatched));
        if (nextNode == null) {
            // Next node is a dead end...
            break;
        }

        currentNode = nextNode;
        CharSequence currentNodeEdgeCharacters = currentNode.getIncomingEdge();
        final int numCharsInEdge = currentNodeEdgeCharacters.length();
        if (numCharsInEdge + charsMatched > documentLength) {
            // This node can't be a match because it is too long...
            break;
        }
        for (int i = 0; i < numCharsInEdge; i++) {
            if (currentNodeEdgeCharacters.charAt(i) != input.charAt(charsMatched + i)) {
                // Found a difference between a character in the input
                // and a character in the edge represented by current node,
                // current node is a dead end...
                break outer_loop;
            }
        }
        // All characters in the current edge matched, add this number to total chars matched...
        charsMatched += numCharsInEdge;

        if (currentNode.getValue() != null) {
            // This is an explicit node and all of its chars match input, return a match...
            candidateNode = currentNode;
            candidateCharsMatched = charsMatched;
        } // else the node matches, but is not an explicit node so we should continue scanning...
    }
    return candidateNode == null ? null : new KeyValuePairImpl<O>(CharSequences.toString(input.subSequence(0, candidateCharsMatched)), candidateNode.getValue());
}
 
Example #25
Source File: ConcurrentInvertedRadixTree.java    From concurrent-trees with Apache License 2.0 4 votes vote down vote up
/**
 * Lazily traverses the tree based on characters in the given input, and returns from the tree the next node
 * and its value where the key associated with the node matches the characters from the input. More than
 * one matching keyword can be found for the same input, if there are keys in the tree which are prefixes of
 * each other.
 * <p/>
 * Example:<br/>
 * Given two keywords in the tree: "Ford" and "Ford Focus"<br/>
 * Given a document: "I am shopping for a Ford Focus car"<br/>
 * Where the given input in this instance is the suffix of the document: "Ford Focus car"<br/>
 * ...then this method will return both "Ford" and "Ford Focus".<br/>
 * The caller can invoke this method repeatedly for each suffix of the document.<br/>
 *
 * @param input A sequence of characters which controls traversal of the tree
 * @return An iterable which will search for the next node in the tree matching the input
 */
protected Iterable<KeyValuePair<O>> scanForKeysAtStartOfInput(final CharSequence input) {
    return new Iterable<KeyValuePair<O>>() {
        @Override
        public Iterator<KeyValuePair<O>> iterator() {
            return new LazyIterator<KeyValuePair<O>>() {

                Node currentNode = root;
                int charsMatched = 0;

                final int documentLength = input.length();

                @Override
                protected KeyValuePair<O> computeNext() {
                    while (charsMatched < documentLength) {
                        Node nextNode = currentNode.getOutgoingEdge(input.charAt(charsMatched));
                        if (nextNode == null) {
                            // Next node is a dead end...
                            return endOfData();
                        }

                        currentNode = nextNode;
                        CharSequence currentNodeEdgeCharacters = currentNode.getIncomingEdge();
                        final int numCharsInEdge = currentNodeEdgeCharacters.length();
                        if (numCharsInEdge + charsMatched > documentLength) {
                            // This node can't be a match because it is too long...
                            return endOfData();
                        }
                        for (int i = 0; i < numCharsInEdge; i++) {
                            if (currentNodeEdgeCharacters.charAt(i) != input.charAt(charsMatched + i)) {
                                // Found a difference between a character in the input
                                // and a character in the edge represented by current node,
                                // current node is a dead end...
                                return endOfData();
                            }
                        }
                        // All characters in the current edge matched, add this number to total chars matched...
                        charsMatched += numCharsInEdge;

                        if (currentNode.getValue() != null) {
                            // This is an explicit node and all of its chars match input, return a match...
                            return new KeyValuePairImpl<O>(CharSequences.toString(input.subSequence(0, charsMatched)), currentNode.getValue());
                        } // else the node matches, but is not an explicit node so we should continue scanning...
                    }
                    return endOfData();
                }
            };
        }
    };
}
 
Example #26
Source File: ConcurrentSuffixTree.java    From concurrent-trees with Apache License 2.0 4 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public Iterable<KeyValuePair<O>> getKeyValuePairsForKeysContaining(final CharSequence fragment) {
    return new Iterable<KeyValuePair<O>>() {
        @Override
        public Iterator<KeyValuePair<O>> iterator() {
            return new LazyIterator<KeyValuePair<O>>() {

                Iterator<Set<String>> originalKeysSets = radixTree.getValuesForKeysStartingWith(fragment).iterator();
                Iterator<String> keyIterator = Collections.<String>emptyList().iterator();

                // A given fragment can be contained many times within the same key, so track keys processed
                // so far, so that we can avoid re-processing the same key multiple times...
                Set<String> keysAlreadyProcessed = new HashSet<String>();

                @Override
                protected KeyValuePair<O> computeNext() {
                    String originalKey = null;
                    O value = null;
                    while (value == null) {
                        while (!keyIterator.hasNext()) {
                            if (!originalKeysSets.hasNext()) {
                                return endOfData();
                            }
                            keyIterator = originalKeysSets.next().iterator();
                        }
                        originalKey = keyIterator.next();

                        if (keysAlreadyProcessed.add(originalKey)) {
                            // Key was not in the already-processed set, so proceed with looking up the value...
                            value = valueMap.get(originalKey);

                            // value could still be null due to race condition if key/value was removed while
                            // iterating, hence if so, we loop again to find the next non-null key/value...
                        }
                    }
                    return new ConcurrentRadixTree.KeyValuePairImpl<O>(originalKey, value);
                }
            };
        }
    };
}
 
Example #27
Source File: InvertedRadixTree.java    From concurrent-trees with Apache License 2.0 2 votes vote down vote up
/**
 * Returns a lazy iterable which returns the set of {@link KeyValuePair}s for keys in the tree which prefix
 * the given document.
 *
 * @param document A document to be scanned for keys contained in the tree which prefix the given document
 * @return The set of {@link KeyValuePair}s for keys in the tree which prefix the given document
 */
Iterable<KeyValuePair<O>> getKeyValuePairsForKeysPrefixing(CharSequence document);
 
Example #28
Source File: InvertedRadixTree.java    From concurrent-trees with Apache License 2.0 2 votes vote down vote up
/**
 * Returns the {@link KeyValuePair} for the longest key in the tree which is a prefix of the given document.
 *
 * @param document A document to be scanned for a key contained in the tree which prefixes the given document
 * @return The {@link KeyValuePair} for the longest key in the tree which is a prefix of the given document,
 * or null if no such key is contained in the tree
 */
public KeyValuePair<O> getKeyValuePairForLongestKeyPrefixing(CharSequence document);
 
Example #29
Source File: InvertedRadixTree.java    From concurrent-trees with Apache License 2.0 2 votes vote down vote up
/**
 * Returns a lazy iterable which returns the set of {@link KeyValuePair}s for keys in the tree which are contained
 * in the given document.
 *
 * @param document A document to be scanned for keys contained in the tree
 * @return The set of {@link KeyValuePair}s for keys in the tree which are contained in the given document
 */
Iterable<KeyValuePair<O>> getKeyValuePairsForKeysContainedIn(CharSequence document);
 
Example #30
Source File: ReversedRadixTree.java    From concurrent-trees with Apache License 2.0 2 votes vote down vote up
/**
 * Returns a lazy iterable which returns the set of {@link KeyValuePair}s for keys and their associated values
 * in the tree, where the keys end with the given suffix.
 * <p/>
 * This is <i>inclusive</i> - if the given suffix is an exact match for a key in the tree, the {@link KeyValuePair}
 * for that key is also returned.
 *
 * @param suffix A suffix of keys in the tree for which associated {@link KeyValuePair}s are sought
 * @return The set of {@link KeyValuePair}s for keys in the tree which end with the given suffix, inclusive
 */
Iterable<KeyValuePair<O>> getKeyValuePairsForKeysEndingWith(CharSequence suffix);