当前位置: 首页>>代码示例>>Java>>正文


Java Pair.getKey方法代码示例

本文整理汇总了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);
    }
}
 
开发者ID:OpenCryptoProject,项目名称:Myst,代码行数:24,代码来源:MPCTestClient.java

示例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;
}
 
开发者ID:IsaacChanghau,项目名称:Word2VecfJava,代码行数:20,代码来源:WordVectorSerializer.java

示例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()));
}
 
开发者ID:carlo-,项目名称:MalmoAgent,代码行数:17,代码来源:Craft.java

示例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;
}
 
开发者ID:Superioz,项目名称:MooProject,代码行数:20,代码来源:BanCategory.java

示例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;
}
 
开发者ID:Superioz,项目名称:MooProject,代码行数:27,代码来源:MessageComponent.java

示例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;
}
 
开发者ID:amrmagdy4,项目名称:kite,代码行数:18,代码来源:Serializer.java

示例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;
    }
}
 
开发者ID:ciphertechsolutions,项目名称:IO,代码行数:25,代码来源:StringCarver.java

示例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);
}
 
开发者ID:xfangfang,项目名称:PhotoScript,代码行数:16,代码来源:GraphicBoard.java

示例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);
}
 
开发者ID:PizzaCrust,项目名称:Mixinite,代码行数:11,代码来源:MethodRef.java

示例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);
    }
 
开发者ID:GeorgiMateev,项目名称:twitter-user-gender-classification,代码行数:41,代码来源:Main.java

示例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));
    }
}
 
开发者ID:kmhasan-class,项目名称:fall2017ip,代码行数:42,代码来源:FloodFillDemo.java

示例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;
}
 
开发者ID:IsaacChanghau,项目名称:Word2VecfJava,代码行数:14,代码来源:WordVectorSerializer.java

示例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];
}
 
开发者ID:amrmagdy4,项目名称:kite,代码行数:12,代码来源:ArrayBigDataset.java

示例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;
}
 
开发者ID:LtubSalad,项目名称:voogasalad-ltub,代码行数:12,代码来源:ScreenObjectHolder.java

示例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());
}
 
开发者ID:amrmagdy4,项目名称:kite,代码行数:11,代码来源:Serializer.java


注:本文中的javafx.util.Pair.getKey方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。