本文整理汇总了Java中com.googlecode.concurrenttrees.radix.ConcurrentRadixTree类的典型用法代码示例。如果您正苦于以下问题:Java ConcurrentRadixTree类的具体用法?Java ConcurrentRadixTree怎么用?Java ConcurrentRadixTree使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ConcurrentRadixTree类属于com.googlecode.concurrenttrees.radix包,在下文中一共展示了ConcurrentRadixTree类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getKeyValuePairsForKeysEndingWith
import com.googlecode.concurrenttrees.radix.ConcurrentRadixTree; //导入依赖的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);
}
};
}
};
}
示例2: main
import com.googlecode.concurrenttrees.radix.ConcurrentRadixTree; //导入依赖的package包/类
public static void main(String[] args) {
RadixTree<Integer> tree = new ConcurrentRadixTree<Integer>(new DefaultCharArrayNodeFactory());
tree.put("TEST", 1);
tree.put("TOAST", 2);
tree.put("TEAM", 3);
System.out.println("Tree structure:");
// PrettyPrintable is a non-public API for testing, prints semi-graphical representations of trees...
PrettyPrinter.prettyPrint((PrettyPrintable) tree, System.out);
System.out.println();
System.out.println("Value for 'TEST' (exact match): " + tree.getValueForExactKey("TEST"));
System.out.println("Value for 'TOAST' (exact match): " + tree.getValueForExactKey("TOAST"));
System.out.println();
System.out.println("Keys starting with 'T': " + Iterables.toString(tree.getKeysStartingWith("T")));
System.out.println("Keys starting with 'TE': " + Iterables.toString(tree.getKeysStartingWith("TE")));
System.out.println();
System.out.println("Values for keys starting with 'TE': " + Iterables.toString(tree.getValuesForKeysStartingWith("TE")));
System.out.println("Key-Value pairs for keys starting with 'TE': " + Iterables.toString(tree.getKeyValuePairsForKeysStartingWith("TE")));
System.out.println();
System.out.println("Keys closest to 'TEMPLE': " + Iterables.toString(tree.getClosestKeys("TEMPLE")));
}
示例3: gitAttributes
import com.googlecode.concurrenttrees.radix.ConcurrentRadixTree; //导入依赖的package包/类
/** Returns all of the .gitattributes files which affect the given files. */
static List<File> gitAttributes(Iterable<File> files) {
// build a radix tree out of all the parent folders in these files
ConcurrentRadixTree<String> tree = new ConcurrentRadixTree<>(new DefaultCharSequenceNodeFactory());
for (File file : files) {
String parentPath = file.getParent() + File.separator;
tree.putIfAbsent(parentPath, parentPath);
}
// traverse the edge nodes to find the outermost folders
List<File> edgeFolders = TreeStream.depthFirst(Node::getOutgoingEdges, tree.getNode())
.filter(node -> node.getOutgoingEdges().isEmpty() && node.getValue() != null)
.map(node -> new File((String) node.getValue()))
.collect(Collectors.toList());
List<File> gitAttrFiles = new ArrayList<>();
Set<File> visitedFolders = new HashSet<>();
for (File edgeFolder : edgeFolders) {
gitAttrAddWithParents(edgeFolder, visitedFolders, gitAttrFiles);
}
return gitAttrFiles;
}
示例4: OVXMap
import com.googlecode.concurrenttrees.radix.ConcurrentRadixTree; //导入依赖的package包/类
/**
* Creates a new map instance, by initializing all mapping data structures.
*/
private OVXMap() {
this.virtualSwitchMap = new ConcurrentHashMap<OVXSwitch, ArrayList<PhysicalSwitch>>();
this.virtualSwitchPlumbingMap = new ConcurrentHashMap<OVXSwitch, ArrayList<Tuple<PhysicalSwitch, Integer>>>();
this.physicalSwitchMap = new ConcurrentHashMap<PhysicalSwitch, ConcurrentHashMap<Integer, OVXSwitch>>();
this.virtualLinkMap = new ConcurrentHashMap<OVXLink, ArrayList<PhysicalLink>>();
this.physicalLinkMap = new ConcurrentHashMap<PhysicalLink, ConcurrentHashMap<Integer, List<OVXLink>>>();
this.routetoPhyLinkMap = new ConcurrentHashMap<SwitchRoute, ArrayList<PhysicalLink>>();
this.phyLinktoRouteMap = new ConcurrentHashMap<PhysicalLink, ConcurrentHashMap<Integer, Set<SwitchRoute>>>();
this.networkMap = new ConcurrentHashMap<Integer, OVXNetwork>();
this.physicalIPMap = new ConcurrentRadixTree<OVXIPAddress>(
new DefaultCharArrayNodeFactory());
this.virtualIPMap = new ConcurrentRadixTree<ConcurrentHashMap<Integer, PhysicalIPAddress>>(
new DefaultCharArrayNodeFactory());
this.macMap = new ConcurrentRadixTree<Integer>(
new DefaultCharArrayNodeFactory());
}
示例5: OVXMap
import com.googlecode.concurrenttrees.radix.ConcurrentRadixTree; //导入依赖的package包/类
/**
* Creates a new map instance, by initializing all mapping data structures.
*/
private OVXMap() {
this.virtualSwitchMap = new ConcurrentHashMap<OVXSwitch, ArrayList<PhysicalSwitch>>();
this.physicalSwitchMap = new ConcurrentHashMap<PhysicalSwitch, ConcurrentHashMap<Integer, OVXSwitch>>();
this.virtualLinkMap = new ConcurrentHashMap<OVXLink, ArrayList<PhysicalLink>>();
this.physicalLinkMap = new ConcurrentHashMap<PhysicalLink, ConcurrentHashMap<Integer, List<OVXLink>>>();
this.routetoPhyLinkMap = new ConcurrentHashMap<SwitchRoute, ArrayList<PhysicalLink>>();
this.phyLinktoRouteMap = new ConcurrentHashMap<PhysicalLink, ConcurrentHashMap<Integer, Set<SwitchRoute>>>();
this.networkMap = new ConcurrentHashMap<Integer, OVXNetwork>();
this.physicalIPMap = new ConcurrentRadixTree<OVXIPAddress>(
new DefaultCharArrayNodeFactory());
this.virtualIPMap = new ConcurrentRadixTree<ConcurrentHashMap<Integer, PhysicalIPAddress>>(
new DefaultCharArrayNodeFactory());
this.macMap = new ConcurrentRadixTree<Integer>(
new DefaultCharArrayNodeFactory());
}
示例6: main
import com.googlecode.concurrenttrees.radix.ConcurrentRadixTree; //导入依赖的package包/类
public static void main(String[] args) {
RadixTree<Integer> tree = new ConcurrentRadixTree<Integer>(new DefaultCharArrayNodeFactory());
tree.put("TEST", 1);
tree.put("TOAST", 2);
tree.put("TEAM", 3);
Iterable<CharSequence> keysStartingWithT = tree.getKeysStartingWith("T");
List<CharSequence> listOfKeysStartingWithT = Iterables.toList (keysStartingWithT);
Set<CharSequence> setOfKeysStartingWithT = Iterables.toSet (keysStartingWithT);
String toStringOfKeysStartingWithT = Iterables.toString(keysStartingWithT);
System.out.println("Keys starting with 'T': " + toStringOfKeysStartingWithT);
}
示例7: main
import com.googlecode.concurrenttrees.radix.ConcurrentRadixTree; //导入依赖的package包/类
public static void main(String[] args) {
ConcurrentRadixTree<WordValue> tree = new ConcurrentRadixTree<WordValue>(new DefaultCharArrayNodeFactory());
for (String file : files) {
Set<String> wordsInFile = IOUtil.loadWordsFromTextFileOnClasspath(file, true); // true = convert to lowercase
for (String word : wordsInFile) {
WordValue wordValue = tree.getValueForExactKey(word);
if (wordValue == null) {
wordValue = new WordValue(word);
tree.put(word, wordValue); // not using concurrency support here
}
wordValue.manuscriptsContainingWord.add(file.replaceAll("/.*/.*/", "").replace(".txt", ""));
}
}
final String radixTreePrinted = PrettyPrinter.prettyPrint(tree);
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
JTextArea textArea = new JTextArea();
textArea.setFont(new Font(Font.MONOSPACED, Font.PLAIN, 14));
textArea.setText(radixTreePrinted);
JScrollPane scrollPane = new JScrollPane(textArea);
textArea.setEditable(false);
JFrame frame = new JFrame("Shakespeare Radix Tree");
frame.add(scrollPane);
frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
frame.setSize(640, 480);
frame.setVisible(true);
}
});
}
示例8: RadixTreeIndex
import com.googlecode.concurrenttrees.radix.ConcurrentRadixTree; //导入依赖的package包/类
/**
* Package-private constructor, used by static factory methods.
*/
protected RadixTreeIndex(Attribute<O, A> attribute, NodeFactory nodeFactory) {
super(attribute, new HashSet<Class<? extends Query>>() {{
add(Equal.class);
add(In.class);
add(StringStartsWith.class);
}});
this.nodeFactory = nodeFactory;
this.tree = new ConcurrentRadixTree<StoredResultSet<O>>(nodeFactory);
}
示例9: clear
import com.googlecode.concurrenttrees.radix.ConcurrentRadixTree; //导入依赖的package包/类
public void clear() {
hiddenfiles = new ConcurrentRadixTree<>(new DefaultCharArrayNodeFactory());
gridfiles = new ArrayList<>();
listfiles = new ArrayList<>();
history.clear();
storages = new ArrayList<>();
servers = new ArrayList<>();
books = new ArrayList<>();
accounts = new ArrayList<>();
}
示例10: toHybridFileConcurrentRadixTree
import com.googlecode.concurrenttrees.radix.ConcurrentRadixTree; //导入依赖的package包/类
public static ArrayList<HybridFile> toHybridFileConcurrentRadixTree(ConcurrentRadixTree<VoidValue> a) {
ArrayList<HybridFile> b = new ArrayList<>();
for (CharSequence o : a.getKeysStartingWith("")) {
HybridFile hFile = new HybridFile(OpenMode.UNKNOWN, o.toString());
hFile.generateMode(null);
b.add(hFile);
}
return b;
}
示例11: getHiddenFilesConcurrentRadixTree
import com.googlecode.concurrenttrees.radix.ConcurrentRadixTree; //导入依赖的package包/类
public ConcurrentRadixTree<VoidValue> getHiddenFilesConcurrentRadixTree() {
ConcurrentRadixTree<VoidValue> paths = new ConcurrentRadixTree<>(new DefaultCharArrayNodeFactory());
Cursor cursor = getReadableDatabase().query(getTableForOperation(Operation.HIDDEN), null,
null, null, null, null, null);
cursor.moveToFirst();
while (cursor.moveToNext()) {
paths.put(cursor.getString(cursor.getColumnIndex(COLUMN_PATH)), VoidValue.SINGLETON);
}
cursor.close();
return paths;
}
示例12: resolveDirectory
import com.googlecode.concurrenttrees.radix.ConcurrentRadixTree; //导入依赖的package包/类
private ConcurrentRadixTree<Long> resolveDirectory(long inodeNumber, boolean createIfDoesntExist) {
ConcurrentRadixTree<Long> parentDirectoryEntry = directoryTable.get(inodeNumber);
if (parentDirectoryEntry == null && createIfDoesntExist) {
parentDirectoryEntry = new ConcurrentRadixTree<>(directoryNodeFactory);
ConcurrentRadixTree<Long> alreadyThere = directoryTable.putIfAbsent(inodeNumber, parentDirectoryEntry);
return alreadyThere != null ? alreadyThere : parentDirectoryEntry;
}
return parentDirectoryEntry;
}
示例13: resolveChild
import com.googlecode.concurrenttrees.radix.ConcurrentRadixTree; //导入依赖的package包/类
private Long resolveChild(long directoryInodeNumber, String name) {
ConcurrentRadixTree<Long> parentDirectoryEntry = directoryTable.get(directoryInodeNumber);
if (parentDirectoryEntry == null) {
return null;
}
return parentDirectoryEntry.getValueForExactKey(name);
}
示例14: clear
import com.googlecode.concurrenttrees.radix.ConcurrentRadixTree; //导入依赖的package包/类
/**
* Clear history
*/
public void clear() {
_map.clear();
_tree = new ConcurrentRadixTree<>(new DefaultByteArrayNodeFactory());
}
示例15: getKeyValuePairsForKeysContaining
import com.googlecode.concurrenttrees.radix.ConcurrentRadixTree; //导入依赖的package包/类
/**
* {@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);
}
};
}
};
}