Java Code Examples for gnu.trove.list.array.TIntArrayList#get()

The following examples show how to use gnu.trove.list.array.TIntArrayList#get() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Convert.java    From paintera with GNU General Public License v2.0 6 votes vote down vote up
/**
 * @param vertices vertices
 * @param triangleVertexLUT triangleVertexLUT
 *
 * @return vertices
 */
public static float[] convertFromLUT(
		final TFloatArrayList vertices,
		final ArrayList<TIntArrayList> triangleVertexLUT)
{

	final float[] export = new float[triangleVertexLUT.size() * 9];
	int           t      = -1;
	for (final TIntArrayList triangleVertices : triangleVertexLUT)
	{
		final TIntArrayList vertexIndices = triangleVertices;
		for (int i = 0; i < vertexIndices.size(); ++i)
		{
			int vertexIndex = vertexIndices.get(i) * 3;
			export[++t] = vertices.get(vertexIndex);
			export[++t] = vertices.get(++vertexIndex);
			export[++t] = vertices.get(++vertexIndex);
		}
	}
	return export;
}
 
Example 2
Source File: QuestEngine.java    From aion-germany with GNU General Public License v3.0 6 votes vote down vote up
public boolean onKillRanked(QuestEnv env, AbyssRankEnum playerRank) {
	try {
		if (playerRank != null) {
			TIntArrayList questList = getOnKillRankedQuests(playerRank);
			for (int index = 0; index < questList.size(); index++) {
				int id = questList.get(index);
				QuestHandler questHandler = getQuestHandlerByQuestId(id);
				if (questHandler != null) {
					env.setQuestId(id);
					questHandler.onKillRankedEvent(env);
				}
			}
		}
	}
	catch (Exception ex) {
		log.error("[QuestEngine] exception in onKillRanked - QuestId: " + env.getQuestId() + " Error: ", ex);
		return false;
	}
	return true;
}
 
Example 3
Source File: AudioFingerprint.java    From cineast with MIT License 6 votes vote down vote up
/**
 * This method represents the first step that's executed when processing query. The associated SegmentContainer is
 * examined and feature-vectors are being generated. The generated vectors are returned by this method together with an
 * optional weight-vector.
 *
 * <strong>Important: </strong> The weight-vector must have the same size as the feature-vectors returned by the method.
 *
 * @param sc SegmentContainer that was submitted to the feature module
 * @param qc A QueryConfig object that contains query-related configuration parameters. Can still be edited.
 * @return A pair containing a List of features and an optional weight vector.
 */
@Override
protected List<float[]> preprocessQuery(SegmentContainer sc, ReadableQueryConfig qc) {
    /* Prepare empty list of features. */
    List<float[]> features = new ArrayList<>();

    /* Extract filtered spectrum and create query-vectors. */
    final TIntArrayList filteredSpectrum = this.filterSpectrum(sc);
    final int shift = RANGES.length-1;
    final int lookups = Math.max(1,Math.min(30, filteredSpectrum.size() - FINGERPRINT));

    for (int i=1;i<=lookups;i++) {
        float[] feature = new float[FINGERPRINT];
        for (int j=0; j< FINGERPRINT; j++) {
            if (i * shift + j < filteredSpectrum.size()) {
                feature[j] = filteredSpectrum.get(i * shift + j);
            }
        }
        features.add(feature);
    }
    return features;
}
 
Example 4
Source File: Tree.java    From fnlp with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * 由上到下存储路径
 */
public void CalcPath() {
	treepath = new int[size][];
	for(int i=0;i<size;i++){
		TIntArrayList  list= new TIntArrayList ();
		list.add(i);
		Integer j=i;
		while((j=edgesInv.get(j))!=null){
			list.add(j);
		}
		int s = list.size();
		treepath[i] = new int[s];
		for(int k=0;k<s;k++){
			treepath[i][s-k-1] = list.get(k);
		}
	}		
}
 
Example 5
Source File: NodeBreakerVoltageLevel.java    From powsybl-core with Mozilla Public License 2.0 5 votes vote down vote up
@Override
public boolean isValid(UndirectedGraph<? extends TerminalExt, SwitchImpl> graph, TIntArrayList nodes, List<NodeTerminal> terminals) {
    int feederCount = 0;
    int branchCount = 0;
    int busbarSectionCount = 0;
    for (int i = 0; i < nodes.size(); i++) {
        int node = nodes.get(i);
        TerminalExt terminal = graph.getVertexObject(node);
        if (terminal != null) {
            AbstractConnectable connectable = terminal.getConnectable();
            switch (connectable.getType()) {
                case LINE:
                case TWO_WINDINGS_TRANSFORMER:
                case THREE_WINDINGS_TRANSFORMER:
                case HVDC_CONVERTER_STATION:
                case DANGLING_LINE:
                    branchCount++;
                    feederCount++;
                    break;

                case LOAD:
                case GENERATOR:
                case BATTERY:
                case SHUNT_COMPENSATOR:
                case STATIC_VAR_COMPENSATOR:
                    feederCount++;
                    break;

                case BUSBAR_SECTION:
                    busbarSectionCount++;
                    break;

                default:
                    throw new AssertionError();
            }
        }
    }
    return (busbarSectionCount >= 1 && feederCount >= 1)
            || (branchCount >= 1 && feederCount >= 2);
}
 
Example 6
Source File: AudioFingerprint.java    From cineast with MIT License 5 votes vote down vote up
/**
 *
 * @param segment
 */
@Override
public void processSegment(SegmentContainer segment) {
    TIntArrayList filteredSpectrum = this.filterSpectrum(segment);
    int vectors = filteredSpectrum.size()/FINGERPRINT;
    List<PersistentTuple> tuples = new ArrayList<>();
    for (int i = 0; i < vectors; i++) {
        float[] feature = new float[FINGERPRINT];
        for (int j=0; j < FINGERPRINT; j++) {
            feature[j] = filteredSpectrum.get(i * FINGERPRINT + j);
        }
        tuples.add(this.phandler.generateTuple(segment.getId(), feature));
    }
    this.phandler.persist(tuples);
}
 
Example 7
Source File: Document.java    From JGibbLabeledLDA with GNU General Public License v2.0 5 votes vote down vote up
public Document(TIntArrayList doc){
    this.length = doc.size();
    this.words = new int[length];
    for (int i = 0; i < length; i++){
        this.words[i] = doc.get(i);
    }
}