本文整理汇总了Java中com.googlecode.concurrenttrees.common.KeyValuePair类的典型用法代码示例。如果您正苦于以下问题:Java KeyValuePair类的具体用法?Java KeyValuePair怎么用?Java KeyValuePair使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
KeyValuePair类属于com.googlecode.concurrenttrees.common包,在下文中一共展示了KeyValuePair类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getAutoCompleteValues
import com.googlecode.concurrenttrees.common.KeyValuePair; //导入依赖的package包/类
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);
}
}
示例2: invoke
import com.googlecode.concurrenttrees.common.KeyValuePair; //导入依赖的package包/类
public QuikInvocationResult invoke(String input) {
Deque<String> tokens = Tokenizer.tokenize(input);
if (tokens.isEmpty()) {
return QuikInvocationResult.fromNothing();
}
List<KeyValuePair<QuikCommandWrapper>> options = this.getPossibleCommandsFor(tokens.pop()).collect(Collectors.toList());
if (options.isEmpty()) {
return QuikInvocationResult.fromMissing(input);
} else if (options.size() > 1) {
final String[] names = new String[options.size()];
for (int i = 0; i < options.size(); i++) {
names[i] = options.get(i).getKey().toString();
}
return QuikInvocationResult.fromAmbiguous(input, names);
} else {
return options.get(0).getValue().invoke(mapify(tokens));
}
}
示例3: getKeyValuePairsForKeysStartingWith
import com.googlecode.concurrenttrees.common.KeyValuePair; //导入依赖的package包/类
/**
* {@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();
}
}
}
示例4: getKeyValuePairsForKeysEndingWith
import com.googlecode.concurrenttrees.common.KeyValuePair; //导入依赖的package包/类
/**
* {@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);
}
};
}
};
}
示例5: getKeysPrefixing
import com.googlecode.concurrenttrees.common.KeyValuePair; //导入依赖的package包/类
/**
* {@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();
}
}
};
}
};
}
示例6: getValuesForKeysPrefixing
import com.googlecode.concurrenttrees.common.KeyValuePair; //导入依赖的package包/类
/**
* {@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();
}
}
};
}
};
}
示例7: getKeyValuePairsForKeysPrefixing
import com.googlecode.concurrenttrees.common.KeyValuePair; //导入依赖的package包/类
/**
* {@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();
}
}
};
}
};
}
示例8: getPotentialFlowMods
import com.googlecode.concurrenttrees.common.KeyValuePair; //导入依赖的package包/类
@Override
public List<OVXFlowMod> getPotentialFlowMods(OVXFlowMod fm) {
String key = this.getKey(fm);
List<OVXFlowMod> flowMods = new ArrayList<OVXFlowMod>();
// get flowmods that match this field
List<KeyValuePair<PolicyFlowModStore>> keyValuePairs = this.flowModsTrie
.getIPKeyValuePairsForKeysStartingWith(key);
for (KeyValuePair<PolicyFlowModStore> keyValuePair : keyValuePairs) {
flowMods.addAll(keyValuePair.getValue().getPotentialFlowMods(fm));
}
// get flowmods that wildcard this field
flowMods.addAll(this.wildcardFlowStore.getFlowMods());
return flowMods;
}
示例9: getFetchType
import com.googlecode.concurrenttrees.common.KeyValuePair; //导入依赖的package包/类
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;
}
}
示例10: getFromHistory
import com.googlecode.concurrenttrees.common.KeyValuePair; //导入依赖的package包/类
/**
* 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));
}
示例11: getRoutes
import com.googlecode.concurrenttrees.common.KeyValuePair; //导入依赖的package包/类
/**
* 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;
}
示例12: getRoutes4
import com.googlecode.concurrenttrees.common.KeyValuePair; //导入依赖的package包/类
/**
* Gets all IPv4 routes from the RIB.
*
* @return all IPv4 routes from the RIB
*/
@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;
}
示例13: getRoutes6
import com.googlecode.concurrenttrees.common.KeyValuePair; //导入依赖的package包/类
/**
* Gets all IPv6 routes from the RIB.
*
* @return all IPv6 routes from the RIB
*/
@Override
public Collection<RouteEntry> getRoutes6() {
Iterator<KeyValuePair<RouteEntry>> it =
ribTable6.getKeyValuePairsForKeysStartingWith("").iterator();
List<RouteEntry> routes = new LinkedList<>();
while (it.hasNext()) {
KeyValuePair<RouteEntry> entry = it.next();
routes.add(entry.getValue());
}
return routes;
}
示例14: testGetPossibleCommandsFor
import com.googlecode.concurrenttrees.common.KeyValuePair; //导入依赖的package包/类
/**
* Test of getPossibleCommandsFor method, of class QuikCommandManager.
*/
@Test
public void testGetPossibleCommandsFor() {
System.out.println("getPossibleCommandsFor");
// Setup
QuikCommandManager instance = new QuikCommandManager();
instance.attemptAddCommand(getCommand("zero"));
instance.attemptAddCommand(getCommand("nada"));
Stream<KeyValuePair<QuikCommandWrapper>> possibles = instance.getPossibleCommandsFor("");
// Do tests
assertEquals(2, possibles.count());
}
示例15: getRoutes4
import com.googlecode.concurrenttrees.common.KeyValuePair; //导入依赖的package包/类
@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;
}