本文整理匯總了Java中javafx.util.Pair.getKey方法的典型用法代碼示例。如果您正苦於以下問題:Java Pair.getKey方法的具體用法?Java Pair.getKey怎麽用?Java Pair.getKey使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javafx.util.Pair
的用法示例。
在下文中一共展示了Pair.getKey方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: saveLatexPerfLog
import javafx.util.Pair; //導入方法依賴的package包/類
static void saveLatexPerfLog(ArrayList<Pair<String, Long>> results) {
try {
// Save performance results also as latex
String logFileName = String.format("MPC_PERF_log_%d.tex", System.currentTimeMillis());
FileOutputStream perfFile = new FileOutputStream(logFileName);
String tableHeader = "\\begin{tabular}{|l|c|}\n"
+ "\\hline\n"
+ "\\textbf{Operation} & \\textbf{Time (ms)} \\\\\n"
+ "\\hline\n"
+ "\\hline\n";
perfFile.write(tableHeader.getBytes());
for (Pair<String, Long> measurement : results) {
String operation = measurement.getKey();
operation = operation.replace("_", "\\_");
perfFile.write(String.format("%s & %d \\\\ \\hline\n", operation, measurement.getValue()).getBytes());
}
String tableFooter = "\\hline\n\\end{tabular}";
perfFile.write(tableFooter.getBytes());
perfFile.close();
} catch (IOException ex) {
Logger.getLogger(MPCTestClient.class.getName()).log(Level.SEVERE, null, ex);
}
}
示例2: loadWord2VecfModel
import javafx.util.Pair; //導入方法依賴的package包/類
/** @return {@link Word2Vecf} */
public static Word2Vecf loadWord2VecfModel (String wordFilePath, String contextFilePath, boolean binary) {
Word2Vecf model = null;
try {
Pair<List<String>, INDArray> wordPair;
Pair<List<String>, INDArray> contextPair;
if (binary) {
wordPair = fromBinary(wordFilePath);
contextPair = fromBinary(contextFilePath);
} else {
wordPair = fromText(wordFilePath);
contextPair = fromText(contextFilePath);
}
model = new Word2Vecf(wordPair.getValue().columns(), wordPair.getKey(), wordPair.getValue(), contextPair.getKey(), contextPair.getValue(), true);
} catch (IOException e) {
e.printStackTrace();
}
return model;
}
示例3: Craft
import javafx.util.Pair; //導入方法依賴的package包/類
public Craft(AgentHost agentHost, String item) {
super(agentHost);
mItem = item;
if (!CRAFTS.containsKey(item))
throw new IllegalArgumentException("The item " + item + " cannot be crafted! (or isn't in the list of crafts");
String name;
int quantity;
Observations obs = ObservationFactory.getObservations(agentHost);
for (Pair<String, Integer> pair : CRAFTS.get(item).getValue()) {
name = pair.getKey();
quantity = pair.getValue();
this.preconditions.add(new Have(name, quantity));
this.effects.add(new Have(name, obs.numberOf(name) - quantity));
}
this.effects.add(new Have(item, obs.numberOf(item) + CRAFTS.get(item).getKey()));
}
示例4: BanCategory
import javafx.util.Pair; //導入方法依賴的package包/類
public BanCategory(String s, int id) {
if(!REGEX.matcher(s).matches()) return;
this.rawString = s;
this.id = id;
String[] split = s.split(":");
this.name = split[0];
String[] split0 = split[1].split(";");
// list duration
Pair<Integer, TimeUnit> timeDuration = TimeUtil.getTime(split0[0]);
this.duration = timeDuration.getKey();
this.timeUnit = timeDuration.getValue();
// banType
this.banType = split0.length > 1
? split0[1].equalsIgnoreCase(BanType.CHAT.name())
? BanType.CHAT : BanType.GLOBAL : BanType.GLOBAL;
}
示例5: replace
import javafx.util.Pair; //導入方法依賴的package包/類
/**
* Replaces given string with given {@link TextEntry}
*
* @param toReplace The string to be replaced (e.g. "%diamond")
* @param entry The entry to replace given string (e.g. a TextEntry with a {@link TranslatableComponent})
* @return This
*/
public MessageComponent replace(String toReplace, TextEntry entry) {
for(int i = 0; i < entryList.size(); i++) {
Pair<String, TextEntry> entryPair = entryList.get(i);
String raw = entryPair.getKey();
if(!raw.contains(toReplace)) continue;
String[] spl = raw.split(toReplace);
entryList.remove(i);
if(spl.length > 1) {
entryList.add(i, new Pair<>(spl[1], new TextEntry(spl[1])));
}
entryList.add(i, new Pair<>(toReplace, entry));
entryList.add(i, new Pair<>(spl[0], new TextEntry(spl[0])));
break;
}
return this;
}
示例6: deserializeHashEntry
import javafx.util.Pair; //導入方法依賴的package包/類
public static Hashtable<String,ArrayList<Microblog>> deserializeHashEntry(
byte[] keyData, Scheme scheme) {
ByteStream byteStream = new ByteStream(keyData);
int offset = 0;
Pair<String,Integer> result = deserializeKey(byteStream);
String deserializedKey = result.getKey();
int deserializedLen = result.getValue();
offset = deserializedLen;
ArrayList<Microblog> microblogs = deserializeValue(byteStream, scheme);
Hashtable<String, ArrayList<Microblog>> singleHashEntry = new
Hashtable<>();
singleHashEntry.put(deserializedKey, microblogs);
return singleHashEntry;
}
示例7: internalProcess
import javafx.util.Pair; //導入方法依賴的package包/類
@Override
protected void internalProcess() {
try {
while (isRunning && !Thread.currentThread().isInterrupted())
{
Pair<byte[], Long> toRead;
toRead = byteQueue.poll(5, TimeUnit.SECONDS);
if (toRead == null) {
continue;
}
byte[] bytesToRead = toRead.getKey();
if (bytesToRead.length == 0)
{
isRunning = false;
return;
}
ByteUtils.printableSpansWithIndexes(bytesToRead, DEFAULT_STRING_LENGTH, false, DEFAULT_RANDOM_THRESHOLD);
// TODO: What to do with this?
}
} catch (InterruptedException e) {
Logging.log(e);
return;
}
}
示例8: setSvgData
import javafx.util.Pair; //導入方法依賴的package包/類
public void setSvgData(ArrayList<Pair<String, SvgData>> svgData) {
this.svgData = svgData;
map = new HashMap<>();
ObservableList<String> data = FXCollections.observableArrayList();
int index = 0;
for (Pair<String, SvgData> i :
svgData) {
String name = i.getKey();
name = name.substring(0, 1).toUpperCase() + name.substring(1);
map.put(name, index++);
data.add(name);
}
listView.setItems(data);
showSvgs(0);
}
示例9: parseLine
import javafx.util.Pair; //導入方法依賴的package包/類
public static Pair<MethodRef, MethodRef> parseLine(String line) {
String[] splitted = line.split(" ");
Pair<String, String> ownerA = parseOwnerAndName(splitted[1]);
String descA = splitted[2];
Pair<String, String> ownerB = parseOwnerAndName(splitted[3]);
String descB = splitted[4];
MethodRef a = new MethodRef(ownerA.getKey(), ownerA.getValue(), descA);
MethodRef b = new MethodRef(ownerB.getKey(), ownerB.getValue(), descB);
return new Pair<>(a, b);
}
示例10: main
import javafx.util.Pair; //導入方法依賴的package包/類
public static void main(String[] args) {
/*
* READ DATA
*/
CsvReader reader = new CsvReader();
Pair<List<Observation>, Map<String, Set<Object>>> data = reader.readObservations();
Map<String, Set<Object>> dataDomain = data.getValue();
List<Observation> observations = data.getKey();
/*
* Test classifiers
*/
// Instances standardInstances = FeatureVectorsFactory.constructInstances(
// FeatureSetFactory.getStandardFeatureSet(dataDomain),
// observations);
// Instances extendedInstances = FeatureVectorsFactory.constructInstances(
// FeatureSetFactory.getExtendedFeatureSet(dataDomain),
// observations);
int split = (int) (observations.size() * 0.9);
List<Observation> trainObservations = observations.subList(0, split);
List<Observation> testObservations = observations.subList(split, observations.size());
Instances extendedTrainInstances = FeatureVectorsFactory.constructInstances(
FeatureSetFactory.getExtendedFeatureSet(dataDomain),
trainObservations);
Instances extendedTestInstances = FeatureVectorsFactory.constructInstances(
FeatureSetFactory.getExtendedFeatureSet(dataDomain),
testObservations);
// Classification.runJ48(extendedInstances);
// Classification.runNaiveBayes(extendedInstances);
// Classification.runSMO(extendedInstances);
// Classification.runIBk(extendedInstances);
Classification.runJ48(extendedTrainInstances, extendedTestInstances);
Classification.runNaiveBayes(extendedTrainInstances, extendedTestInstances);
Classification.runSMO(extendedTrainInstances, extendedTestInstances);
Classification.runIBk(extendedTrainInstances, extendedTestInstances);
}
示例11: floodFill
import javafx.util.Pair; //導入方法依賴的package包/類
/**
* BFS implementation of flood fill algorithm.
* @param r row to start from
* @param c column to start from
* @param channel the color channel
* @param currentLabel the label that should be set to this pixel
*/
private void floodFill(int r, int c, int channel, int currentLabel) {
// Pair (r, c) represents the starting pixel
Pair<Integer, Integer> source = new Pair(r, c);
Queue<Pair<Integer, Integer>> queue = new LinkedList<>();
// we add the starting pixel to the queue
queue.add(source);
// while there are still unvisited pixels
while (!queue.isEmpty()) {
// pop from the head of the queue
Pair<Integer, Integer> u = queue.poll();
r = u.getKey();
c = u.getValue();
// if this pixel is outside the image boundary, or if it is already visited, ignore it
if (r < 0 || c < 0 || r >= grayscaleMat.height() || c >= grayscaleMat.width() || label[r][c] > 0)
continue;
double color[] = grayscaleMat.get(r, c);
// if the color difference of this pixel is insignificant, ignore it
if (color[channel] < EPS)
continue;
// mark the pixel with the current label and increase the total count of such pixels
label[r][c] = currentLabel;
counts[currentLabel]++;
// push all the neighboring pixels into the queue
queue.add(new Pair(r, c + 1));
queue.add(new Pair(r, c - 1));
queue.add(new Pair(r - 1, c));
queue.add(new Pair(r + 1, c));
}
}
示例12: loadWord2VecModel
import javafx.util.Pair; //導入方法依賴的package包/類
/** @return {@link Word2Vec} */
public static Word2Vec loadWord2VecModel (String wordFilePath, boolean binary) {
Word2Vec model = null;
try {
Pair<List<String>, INDArray> pair;
if (binary) pair = fromBinary(wordFilePath);
else pair = fromText(wordFilePath);
model = new Word2Vec(pair.getValue().columns(), pair.getKey(), pair.getValue(), true);
} catch (IOException e) {
e.printStackTrace();
}
return model;
}
示例13: getRecord
import javafx.util.Pair; //導入方法依賴的package包/類
public Microblog getRecord(Long id) {
Pair<Integer,Integer> locator = locateRecord(id);
if(locator == null)
return null;
int chunkId = locator.getKey();
int chunckInd = locator.getValue();
if(chunkId < 0)
return currChunk[chunckInd];
else
return data.get(chunkId)[chunckInd];
}
示例14: getImageName
import javafx.util.Pair; //導入方法依賴的package包/類
private String getImageName(Image image) {
String toReturn = "";
for (Pair<String, Image> p : myScreenObjects.keySet()) {
String imageName = p.getKey();
Image imageValue = p.getValue();
if (imageValue.equals(image)) {
toReturn = imageName;
}
}
return toReturn;
}
示例15: serializeHashEntry
import javafx.util.Pair; //導入方法依賴的package包/類
public static Pair<Integer, Integer> serializeHashEntry(
Cache.Entry<String, ArrayList<Long>> entry, StreamDataset stream,
ByteStream recordBytes, int entryInd) {
int bytesLen = 0;
bytesLen += serializeKey(entry.getKey(), recordBytes);
Pair<Integer,Integer> results = serializeMemoryValue(entry.getValue(),
stream, recordBytes, entryInd);
return new Pair<Integer,Integer>(results.getKey()+bytesLen,
results.getValue());
}