public boolean add(int e) { if (size >= vals.length) { expand(); } vals[size++] = e; return true; }
@Override public void remove() { if (n > 0) { IntList.this.remove(n - 1); } } };
private static void filterBySalients(File corpusFile, Object2DoubleMap<NGram> ngrams, PrintStream out, String[] wordMap, int N, SourceType sourceType) throws IOException { final IntList doc[] = {new IntList(), new IntList()}; final double[] salience = {0.0, 0.0}; final DataInputStream in = new DataInputStream(CLIOpts.openInputAsMaybeZipped(corpusFile)); if (docNo % 2 == 0) { carousel.reset(); out.print(df.format(salience[sourceType == SourceType.FIRST ? 0 : 1] / doc[sourceType == SourceType.FIRST ? 0 : 1].size()) + " "); for (int w2 : doc[sourceType == SourceType.FIRST ? 1 : 0]) { carousel.offer(w2); doc[0].clear(); doc[1].clear(); salience[0] = 0.0; salience[1] = 0.0; doc[docNo % 2].add(w); carousel.offer(w); for (int i = 1; i <= carousel.maxNGram(); i++) {
public IntList subList(int fromIndex, int toIndex) { if (toIndex < fromIndex || fromIndex < 0 || toIndex > size) { throw new IndexOutOfBoundsException(); } final IntList subList = new IntList(); System.arraycopy(vals, fromIndex, subList.vals, 0, toIndex - fromIndex); subList.size = toIndex - fromIndex; return subList; }
public void add(int index, Integer element) { if (index > size) { throw new IndexOutOfBoundsException(); } else if (index == size) { add(element); } else { System.arraycopy(vals, index, vals, index + 1, size - index); vals[index] = element; size++; } }
public boolean addAll(int index, IntList c) { if (index == size) { return addAll(c); } else if (index < size) { while (size + c.size >= vals.length) { expand(); } System.arraycopy(vals, index, vals, index + c.size, size - index); System.arraycopy(c.vals, 0, vals, index, c.size); size += c.size; return true; } else { throw new UnsupportedOperationException("Inserting list after end of this list"); } }
public boolean addAll(IntList c) { while (size + c.size >= vals.length) { expand(); } System.arraycopy(c.vals, 0, vals, size, c.size); size += c.size; return true; }