本文整理汇总了Java中com.carrotsearch.hppc.IntArrayList.get方法的典型用法代码示例。如果您正苦于以下问题:Java IntArrayList.get方法的具体用法?Java IntArrayList.get怎么用?Java IntArrayList.get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.carrotsearch.hppc.IntArrayList
的用法示例。
在下文中一共展示了IntArrayList.get方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: State
import com.carrotsearch.hppc.IntArrayList; //导入方法依赖的package包/类
public State(String input) {
stateStack = new Stack<int[]>();
int[] neutral = new int[alphabet.features];
for (int i = 0; i < neutral.length; ++i)
neutral[i] = 0;
stateStack.push(neutral);
outputString = new IntArrayList();
inputString = new IntArrayList();
outputPointer = 0;
inputPointer = 0;
current_weight = 0.0f;
displayVector = new ArrayList<Result>();
IndexString inputLine = new IndexString(input);
while (inputLine.index < input.length()) {
inputString.add(letterTrie.findKey(inputLine));
if (inputString.get(inputString.size() - 1) == HfstOptimizedLookup.NO_SYMBOL_NUMBER) {
inputString.clear();
break;
}
}
inputString.add(HfstOptimizedLookup.NO_SYMBOL_NUMBER);
}
示例2: State
import com.carrotsearch.hppc.IntArrayList; //导入方法依赖的package包/类
public State(String input) {
stateStack = new Stack<int[]>();
int[] neutral = new int[alphabet.features];
for (int i = 0; i < neutral.length; ++i)
neutral[i] = 0;
stateStack.push(neutral);
outputString = new IntArrayList();
inputString = new IntArrayList();
outputPointer = 0;
inputPointer = 0;
displayVector = new ArrayList<Result>();
IndexString inputLine = new IndexString(input);
while (inputLine.index < input.length()) {
inputString.add(letterTrie.findKey(inputLine));
if (inputString.get(inputString.size() - 1) == HfstOptimizedLookup.NO_SYMBOL_NUMBER) {
inputString.clear();
break;
}
}
inputString.add(HfstOptimizedLookup.NO_SYMBOL_NUMBER);
}
示例3: mdsAlg
import com.carrotsearch.hppc.IntArrayList; //导入方法依赖的package包/类
@Override
public AbstractMDSResult mdsAlg(Graph g) {
ThreadMXBean bean = ManagementFactory.getThreadMXBean();
long start = bean.getCurrentThreadCpuTime();
IntArrayList W = new IntArrayList(g.getVertices());
prepTime = bean.getCurrentThreadCpuTime() - start;
Integer[] sorted = new Integer[W.size()];
for (int i = 0; i < W.size(); i++) {
sorted[i] = Integer.valueOf(W.buffer[i]);
}
Arrays.sort(sorted, new LessByN1AComparator(g));
for (int i = 0; i < W.size(); i++) {
W.buffer[i] = sorted[i].intValue();
}
IntOpenHashSet S = new IntOpenHashSet(W.size() / 10);
while (!W.isEmpty()) {
int pick = W.get(W.size() - 1);
W.removeAll(g.getN1(pick));
S.add(pick);
}
runTime = bean.getCurrentThreadCpuTime() - start;
MDSResultBackedByIntOpenHashSet result = new MDSResultBackedByIntOpenHashSet();
result.setResult(S);
return result;
}
示例4: shuffle
import com.carrotsearch.hppc.IntArrayList; //导入方法依赖的package包/类
private void shuffle(IntArrayList arrayList) {
for (int i = arrayList.size() - 1; i > 0; i--) {
int index = random.nextInt(i + 1);
// Swap
int value = arrayList.get(index);
arrayList.set(index,arrayList.get(i));
arrayList.set(i, value);
}
}
示例5: getBinaryLabels
import com.carrotsearch.hppc.IntArrayList; //导入方法依赖的package包/类
/** @return an array of 1 or -1. */
protected byte[] getBinaryLabels(IntArrayList ys, int currLabel)
{
int i, size = ys.size();
byte[] aY = new byte[size];
for (i=0; i<size; i++)
aY[i] = (ys.get(i) == currLabel) ? (byte)1 : (byte)-1;
return aY;
}
示例6: gms
import com.carrotsearch.hppc.IntArrayList; //导入方法依赖的package包/类
private IntOpenHashSet gms(IntArrayList choiceVertex,
IntOpenHashSet chosenVertices, Graph g) {
if (choiceVertex.size() == 0) {
// we have made our choice - let's compute it
IntOpenHashSet neighbours = new IntOpenHashSet(chosenVertices.size() << 1);
for (IntCursor vertex : chosenVertices) {
neighbours.addAll(g.getN1(vertex.value));
}
/*
* for (Integer l : chosenVertices) { System.out.print(l);
* System.out.print(" "); } System.out.print(" --> "); for (Integer l :
* neighbours) { System.out.print(l); System.out.print(" "); }
*/
if (neighbours.size() == g.getNumberOfVertices()) {
// System.out.println("*");
return chosenVertices;
} else {
// System.out.println("");
return null;
}
} else {
int v = choiceVertex.get(choiceVertex.size() - 1);
IntArrayList ch = new IntArrayList(choiceVertex);
ch.remove(choiceVertex.size() - 1);
// choose vertices
// don't choose current
IntOpenHashSet set1 = gms(ch, chosenVertices, g);
// choose current
IntOpenHashSet chV = new IntOpenHashSet(chosenVertices);
chV.add(v);
IntOpenHashSet set2 = gms(ch, chV, g);
if (set1 == null)
return set2;
if ((set2 != null) && (set2.size() <= set1.size()))
return set2;
return set1;
}
}
示例7: create
import com.carrotsearch.hppc.IntArrayList; //导入方法依赖的package包/类
@Override
public Mesh create() {
List<VertexAttribute> attributes = new ArrayList<>();
IntArrayList attributeOffsets = new IntArrayList();
int lastAttributeEnd = 0;
for(int attrOffset = 0; attrOffset < ATTRS.length; ++attrOffset) {
if(attributeSizes[attrOffset] > 0) {
String name = ATTR_NAMES[attrOffset];
int size = attributeSizes[attrOffset];
VertexAttribute attr = new VertexAttribute(name, size, lastAttributeEnd, 0);
attributes.add(attr);
attributeOffsets.add(attrOffset);
lastAttributeEnd += vertices.size() * size;
}
}
float[] meshVertices = new float[lastAttributeEnd];
int vertIdx = 0;
for(int i = 0; i < attributes.size(); ++i) {
VertexAttribute attribute = attributes.get(i);
int attributeOffset = attributeOffsets.get(i);
for(int[] vertex: this.vertices) {
for(int vertAttrPacked: vertex) {
int mask = unpackAttributeMask(vertAttrPacked);
int offset = log2(mask);
int attrIdx = unpackIndex(vertAttrPacked);
if(offset == attributeOffset) {
DoubleArrayList attrBuf = attributeBufs[offset];
int attrBufOffset = attrIdx * attribute.width;
for(int j = attrBufOffset; j < (attrBufOffset + attribute.width); ++j) {
meshVertices[vertIdx++] = (float) attrBuf.get(j);
}
break;
}
}
}
}
int[] meshIndexes = new int[faces.size() * getType().width];
int indexIdx = 0;
for(int[] face: faces) {
for(int vertexIdx: face) {
meshIndexes[indexIdx++] = vertexIdx;
}
}
return new Mesh(meshVertices, meshIndexes, getType(), attributes.toArray(new VertexAttribute[0]));
}
示例8: updateWeights
import com.carrotsearch.hppc.IntArrayList; //导入方法依赖的package包/类
@Override
public void updateWeights(AbstractTrainSpace space, boolean average)
{
final int D = space.getFeatureSize();
final int L = space.getLabelSize();
final int N = space.getInstanceSize();
final int WS = D * L;
IntArrayList ys = space.getYs();
ArrayList<int[]> xs = space.getXs();
ArrayList<double[]> vs = space.getVs();
AbstractModel model = space.getModel();
double[] cWeights = new double[WS];
double[] aWeights = average ? new double[WS] : null;
double[] gs = new double[WS];
double stdev, prevScore, currScore = 0;
int[] indices = UTArray.range(N);
int i, j, correct, count = 1;
int yi;
int[] xi;
double[] vi = null;
for (i=0; i<MAX_ITER; i++)
{
UTArray.shuffle(new Random(5), indices, N);
prevScore = currScore;
Arrays.fill(gs, 0);
correct = 0;
for (j=0; j<N; j++)
{
yi = ys.get(indices[j]);
xi = xs.get(indices[j]);
if (space.hasWeight()) vi = vs.get(indices[j]);
if (average)
{
if (!update(L, yi, xi, vi, gs, cWeights, aWeights, count))
correct++;
count++;
}
else if (!update(L, yi, xi, vi, gs, cWeights))
correct++;
}
currScore = 100d * correct / N;
stdev = UTMath.stdev(prevScore, currScore);
LOG.info(String.format("%4d: acc = %5.2f, stdev = %7.4f\n", i+1, currScore, stdev));
if (stdev < d_eps) break;
}
if (average) model.setWeights(getWeights(cWeights, aWeights, count));
else model.setWeights(UTArray.toFloatArray(cWeights));
}
示例9: swap
import com.carrotsearch.hppc.IntArrayList; //导入方法依赖的package包/类
static public void swap(IntArrayList array, int idx0, int idx1)
{
int temp = array.get(idx0);
array.set(idx0, array.get(idx1));
array.set(idx1, temp);
}