本文整理汇总了Java中gnu.trove.map.TMap类的典型用法代码示例。如果您正苦于以下问题:Java TMap类的具体用法?Java TMap怎么用?Java TMap使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
TMap类属于gnu.trove.map包,在下文中一共展示了TMap类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testTHashMap
import gnu.trove.map.TMap; //导入依赖的package包/类
public void testTHashMap() {
TMap<String,String> map = new THashMap<String, String>();
// Add 5, remove the first four, repeat
String[] to_remove = new String[ 4 ];
int batch_index = 0;
for( String s : Constants.STRING_OBJECTS ) {
if ( batch_index < 4 ) {
to_remove[ batch_index ] = s;
}
map.put( s, s );
batch_index++;
if ( batch_index == 5 ) {
for( String s_remove : to_remove ) {
map.remove( s_remove );
}
batch_index = 0;
}
}
}
示例2: allThreadsFinished
import gnu.trove.map.TMap; //导入依赖的package包/类
@Override
public void allThreadsFinished(List<DataSetFileEntry> _data) {
readDataSetFile(_data);
// execute feature selection
TMap<String, Double> all_features_scores = FeatureSelectionMetric.getInstance(
metric,
features_frequencies_per_class,
classes_frequencies,
features_frequencies,
records_count).execute();
// print the output
this.printOutput(all_features_scores);
synchronized (mutex) {
processing_done = true;
}
}
示例3: getInstance
import gnu.trove.map.TMap; //导入依赖的package包/类
public static FeatureSelectionMetric getInstance(
FeatureSelectionMetricEnum _type,
TMap<String, CustomStringIntHashMap> _features_frequencies_per_class,
CustomStringIntHashMap _classes_frequencies,
CustomStringIntHashMap _features_frequencies,
int _all_data_set_records_count) {
FeatureSelectionMetric metric = null;
if (_type == FeatureSelectionMetricEnum.PMI) {
metric = new MetricPMI();
} else if (_type == FeatureSelectionMetricEnum.CHI2) {
metric = new MetricChi2();
} else {
throw new IllegalArgumentException("Invalid FeatureSelectionMetric type");
}
metric.takeInput(
_features_frequencies_per_class,
_classes_frequencies,
_features_frequencies,
_all_data_set_records_count);
return metric;
}
示例4: registerKeyBinding
import gnu.trove.map.TMap; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public void registerKeyBinding(Runnable function, Key... keys) {
if (keys.length == 0) {
throw new IllegalArgumentException("Can not register key binding with no keys bound.");
}
final TMap<Key, Set<Runnable>> bindings = mKeyBindings;
for (int i = 0; i < keys.length; ++i) {
Set<Runnable> functions = bindings.get(keys[i]);
if (functions == null) {
functions = new THashSet<>();
bindings.put(keys[i], functions);
}
functions.add(function);
}
}
示例5: fill
import gnu.trove.map.TMap; //导入依赖的package包/类
private void fill (TMap<Integer, Integer> map) {
for (int i = 0; i < size; i++) {
Integer integer = Integer.valueOf((int) (Math.random() * Integer.MAX_VALUE));
map.put(integer, integer);
}
map.put(12345, 12345);
map.put(12346, 12346);
}
示例6: recordMatchingGenomeIntervals
import gnu.trove.map.TMap; //导入依赖的package包/类
public void recordMatchingGenomeIntervals(TMap<String, GenomeFeatureTester> intervalsMap) {
initializeGenomeIntervals();
intervalsMap.forEachEntry((setName, tester) -> {
if (tester instanceof BedComplement) {
return true;
}
addMatchingGenomeIntervals(setName, tester);
return true;
});
}
示例7: printOutput
import gnu.trove.map.TMap; //导入依赖的package包/类
private void printOutput(final TMap<String, Double> all_features_scores) {
PrintStream os = null;
if (output_file != null) {
try {
os = new PrintStream(output_file);
} catch (FileNotFoundException ex) {
CustomLogger.log(ex, "Cannot write to output file");
}
} else {
os = System.out;
}
// sort the features
SortedMap<String, Double> all_features_sorted_scores = new TreeMap(new Comparator<String>() {
@Override
public int compare(String o1, String o2) {
double diff = all_features_scores.get(o2) - all_features_scores.get(o1); // descendingly
if (diff > 0) {
return 1;
} else {
return -1;
}
}
});
all_features_sorted_scores.putAll(all_features_scores);
// put the top features in the outputfile
Iterator<String> features_names = all_features_sorted_scores.keySet().iterator();
int i = 0;
while (features_names.hasNext() && i < selected_features_count) {
String fname = features_names.next();
os.println(fname + "\t" + all_features_scores.get(fname));
i++;
}
if (output_file != null) {
os.close();
}
}
示例8: takeInput
import gnu.trove.map.TMap; //导入依赖的package包/类
protected void takeInput(
TMap<String, CustomStringIntHashMap> _features_frequencies_per_class,
CustomStringIntHashMap _classes_frequencies,
CustomStringIntHashMap _features_frequencies,
int _all_data_set_records_count) {
features_frequencies_per_class = _features_frequencies_per_class;
classes_frequencies = _classes_frequencies;
features_frequencies = _features_frequencies;
all_classes_count = _classes_frequencies.size();
all_features_count = _features_frequencies.size();
all_data_set_records_count = _all_data_set_records_count;
}
示例9: execute
import gnu.trove.map.TMap; //导入依赖的package包/类
@Override
public TMap<String, Double> execute() {
TMap<String, Double> scores = new THashMap(features_frequencies.size());
for (String feature_name : features_frequencies.keySet()) {
scores.put(feature_name, pmiOfFeatureForAllClasses(feature_name));
}
return scores;
}
示例10: load
import gnu.trove.map.TMap; //导入依赖的package包/类
@Override
public Material load(Path path) {
try (Stream<String> stream = Files.lines(path)) {
final TMap<String, String> values = new THashMap<>(17, 0.9f);
// Load the values
stream.forEachOrdered((String line) -> {
if (line.startsWith("program")) {
values.put("program", getValue(line));
} else if (line.startsWith("diffuse")) {
values.put("diffuse", getValue(line));
}
});
// Load the material program
final Program program = mFileSystem.getResource(FileSystem.DATA_DIRECTORY.resolve(values.get("program")));
// Load the diffuse texture
final Texture diffuse = mFileSystem.getResource(FileSystem.DATA_DIRECTORY.resolve(values.get("diffuse")));
/*
* TODO: Load other textures (normal etc...)
*/
// Create the material
final Material material = new Material(program);
material.addTexture(0, diffuse);
return material;
} catch (IOException ex) {
throw new IllegalArgumentException("Unable to load material: " + path, ex);
}
}
示例11: getCronRegex
import gnu.trove.map.TMap; //导入依赖的package包/类
public static String getCronRegex()
{
String cronRegex = "";
if (cronRegex == null)
{
// numbers intervals and regex
TMap<String, String> numbers = new THashMap<>();
numbers.put("sec", "[0-5]?\\d");
numbers.put("min", "[0-5]?\\d");
numbers.put("hour", "[01]?\\d|2[0-3]");
numbers.put("day", "0?[1-9]|[12]\\d|3[01]");
numbers.put("month", "[1-9]|1[012]");
numbers.put("dow", "[0-6]");
numbers.put("year", "|\\d{4}");
TMap<String, String> field_re = new THashMap<>();
// expand regex to contain different time specifiers
for (String field : numbers.keySet())
{
String number = numbers.get(field);
String range = "(?:" + number + ")(?:(?:-|\\/|\\," + ("dow".equals(field)? "|#" : "") +
")(?:" + number + "))?" + ("dow".equals(field)? "(?:L)?" : ("month".equals(field)? "(?:L|W)?" : ""));
field_re.put(field, "\\?|\\*|" + range + "(?:," + range + ")*");
}
// add string specifiers
String monthRE = field_re.get("month");
String monthREVal = "JAN|FEB|MAR|APR|MAY|JUN|JUL|AUG|SEP|OCT|NOV|DEC";
String monthRERange = "(?:" + monthREVal + ")(?:(?:-)(?:" + monthREVal + "))?" ;
monthRE = monthRE + "|\\?|\\*|" + monthRERange + "(?:," + monthRERange + ")*" ;
field_re.put("month", monthRE);
String dowRE = field_re.get("dow");
String dowREVal = "MON|TUE|WED|THU|FRI|SAT|SUN";
String dowRERange = "(?:" + dowREVal + ")(?:(?:-)(?:" + dowREVal + "))?" ;
dowRE = dowRE + "|\\?|\\*|" + dowRERange + "(?:," + dowRERange + ")*" ;
field_re.put("dow", dowRE);
StringBuilder fieldsReSB = new StringBuilder();
fieldsReSB.append("^\\s*(").append("$") //
.append("|#") //
.append("|\\w+\\s*=") //
.append("|") //
.append("(")//
.append(field_re.get("sec")).append(")\\s+(")//
.append(field_re.get("min")).append(")\\s+(")//
.append(field_re.get("hour")).append(")\\s+(")//
.append(field_re.get("day")).append(")\\s+(")//
.append(field_re.get("month")).append(")\\s+(")//
.append(field_re.get("dow")).append(")(|\\s)+(")//
.append(field_re.get("year"))//
.append(")")//
.append(")")//
.append("$");
cronRegex = fieldsReSB.toString();
}
return cronRegex;
}
示例12: load
import gnu.trove.map.TMap; //导入依赖的package包/类
@Override
public Texture load(Path path) {
// Open the texture file and read its attributes
try (Stream<String> stream = Files.lines(path)) {
final TMap<String, String> values = new THashMap<>(17, 0.9f);
stream.forEachOrdered((String line) -> {
if (line.startsWith(ANISOTROPIC_FILTERING_ATTRIBUTE)) {
values.put(ANISOTROPIC_FILTERING_ATTRIBUTE, getValue(line, false));
} else if (line.startsWith(COMPARE_FUNC_ATTRIBUTE)) {
values.put(COMPARE_FUNC_ATTRIBUTE, getValue(line, true));
} else if (line.startsWith(IMAGE_DATA_ATTRIBUTE)) {
values.put(IMAGE_DATA_ATTRIBUTE, getValue(line, false));
} else if (line.startsWith(MIN_FILTER_ATTRIBUTE)) {
values.put(MIN_FILTER_ATTRIBUTE, getValue(line, true));
} else if (line.startsWith(MAG_FILTER_ATTRIBUTE)) {
values.put(MAG_FILTER_ATTRIBUTE, getValue(line, true));
} else if (line.startsWith(S_WRAP_ATTRIBUTE)) {
values.put(S_WRAP_ATTRIBUTE, getValue(line, true));
} else if (line.startsWith(T_WRAP_ATTRIBUTE)) {
values.put(T_WRAP_ATTRIBUTE, getValue(line, true));
}
});
// Create a texture
final Texture texture = mEngine.getContext().newTexture();
texture.create();
texture.bind();
// Set the anisotropic filtering
final float anisotropicFiltering = Float.parseFloat(values.get(ANISOTROPIC_FILTERING_ATTRIBUTE));
texture.setAnisotropicFiltering(anisotropicFiltering);
// Set the min and max filters
final FilterMode minFilter = FilterMode.valueOf(values.get(MIN_FILTER_ATTRIBUTE));
final FilterMode magFilter = FilterMode.valueOf(values.get(MAG_FILTER_ATTRIBUTE));
texture.setFiltering(minFilter, magFilter);
// Set the S and T wrap modes
final WrapMode wrapS = WrapMode.valueOf(values.get(S_WRAP_ATTRIBUTE));
final WrapMode wrapT = WrapMode.valueOf(values.get(T_WRAP_ATTRIBUTE));
texture.setWrapMode(wrapS, wrapT);
// Set the compare function
final CompareFunc compareFunc = CompareFunc.valueOf(values.get(COMPARE_FUNC_ATTRIBUTE));
texture.setCompareFunc(compareFunc);
// Set the texture image data
final ImageData imageData = mEngine.getFileSystem().getResource(FileSystem.DATA_DIRECTORY.resolve(values.get(IMAGE_DATA_ATTRIBUTE)));
texture.setPixelData(imageData, minFilter.requiresMipmaps());
// Unbind the texture
texture.unbind();
// Check for errors
RenderUtil.checkGLError();
// Return a successful texture load
return texture;
} catch (IOException ex) {
throw new IllegalArgumentException("Unable to load texture: " + path, ex);
}
}
示例13: execute
import gnu.trove.map.TMap; //导入依赖的package包/类
/**
* Polls the OS for input events and then invoke events based on it.
*/
public void execute() {
// Check for display close
if (Display.isCloseRequested()) {
mEngine.stop("Displayed Closed");
}
// Get the keybindings
final TMap<Key, Set<Runnable>> bindings = mKeyBindings;
// Check and execute each key binding
bindings.keySet().stream()
.filter(key -> isKeyDown(key))
.map(key -> bindings.get(key))
.forEach(executors -> {
executors.stream().forEach(executor -> {
executor.run();
});
});
// Get the event manager
final EventManager evManager = mEventManager;
// Check for keyboard events
while (Keyboard.next()) {
// Get the event keycode
final int keycode = Keyboard.getEventKey();
// Call the KeyboardEvent
evManager.invoke(new KeyboardEvent(Key.fromKeycode(keycode), Keyboard.getEventKeyState(), Keyboard.isRepeatEvent()));
}
// Check for mouse events
while (Mouse.next()) {
// Get the event mouse button
final int mouseButton = Mouse.getEventButton();
if (mouseButton != -1) {
// Invoke the mouse button event
evManager.invoke(new MouseButtonEvent(mouseButton, Mouse.getEventX(), Mouse.getEventY(), Mouse.getEventButtonState()));
}
// Check if the mouse has moved
final int mouseDX = Mouse.getEventDX();
final int mouseDY = Mouse.getEventDY();
if (mouseDX != 0 || mouseDY != 0) {
// Invoke the mouse motion event
evManager.invoke(new MouseMotionEvent(mouseDX, mouseDY, Mouse.getEventX(), Mouse.getEventY()));
}
// Check if the mouse wheel has moved
final int mouseWheelDelta = Mouse.getEventDWheel();
if (mouseWheelDelta != 0) {
// Invoke the mouse wheel motion event
evManager.invoke(new MouseWheelMotionEvent(mouseWheelDelta));
}
}
// Check for display close
if (Display.isCloseRequested()) {
mEngine.stop("Displayed Closed");
}
//TODO: Possibilty of other input devices (Joystick, Touchscreen etc...)
}
示例14: selectedFeatures
import gnu.trove.map.TMap; //导入依赖的package包/类
public void selectedFeatures(TMap<String, Double> _features_scores);