private static void assertEmpty(IntIterator it) { assertFalse(it.hasNext()); try { it.next(); fail("expected NoSuchElementException on it.next() after it.hasNext() = false"); } catch (NoSuchElementException ignore) { // expected } // expected to fail with NoSuchElementException it.nextInt(); }
public Integer next() { return iterator.next(); }
@Override public LocalTime next() { return PackedLocalTime.asLocalTime(intIterator.next()); } };
@Override public LocalDate next() { return PackedLocalDate.asLocalDate(intIterator.next()); } };
/** * Serializes an AnchorText object * * @param out * Output Stream */ public void write(DataOutput out) throws IOException { out.writeByte(type); if(hasValidText()) { out.writeUTF(text); } if(hasValidDocumentList()) { out.writeInt(documentList.size()); IntIterator iterator = documentList.iterator(); while(iterator.hasNext()) { out.writeInt(iterator.next()); } } if(hasValidWeight()) { out.writeFloat(weight); } }
@Override public String print() { StringBuilder buf = new StringBuilder(); int[] colWidths = colWidths(); buf.append(name()).append('\n'); List<String> names = this.columnNames(); for (int colNum = 0; colNum < columnCount(); colNum++) { buf.append(StringUtils.rightPad(StringUtils.defaultString(String.valueOf(names.get(colNum))), colWidths[colNum])); buf.append(' '); } buf.append('\n'); IntIterator iterator = intIterator(); while (iterator.hasNext()) { int r = iterator.next(); for (int i = 0; i < columnCount(); i++) { String cell = StringUtils.rightPad(get(i, r), colWidths[i]); buf.append(cell); buf.append(' '); } buf.append('\n'); } return buf.toString(); }
/** * Returns the minimal range that * {@linkplain IntRange#contains(int) contains} all of the given values. * The returned range is {@linkplain BoundType#CLOSED closed} on both ends. * * @throws ClassCastException if the parameters are not <i>mutually * comparable</i> * @throws NoSuchElementException if {@code values} is empty * @throws NullPointerException if any of {@code values} is null * @since 14.0 */ public static IntRange encloseAll(IntCollection values) { checkNotNull(values); if (values instanceof IntSortedSet) { IntSortedSet setValues = (IntSortedSet) values; return closed(setValues.firstInt(), setValues.lastInt()); } IntIterator valueIterator = values.iterator(); int min = checkNotNull(valueIterator.next()); int max = min; while (valueIterator.hasNext()) { int value = checkNotNull(valueIterator.next()); min = Integer.min(min, value); max = Integer.max(max, value); } return closed(min, max); }
/** * Adds the sources/targets from another AnchorText to the current object * * @param other The other AnchorText object from which the * sources/targets are to be copied. */ public void addDocumentsFrom(AnchorText other) { if(!hasValidDocumentList()) { return; } IntIterator iterator = other.documentList.iterator(); while(iterator.hasNext()) { addDocument(iterator.next()); } }
@Override public Table first(int nRows) { Selection newMap = new BitmapBackedSelection(); int count = 0; IntIterator it = intIterator(); while (it.hasNext() && count < nRows) { int row = it.next(); newMap.add(row); count++; } return table.selectWhere(newMap); }
public BooleanColumn(String name, Selection hits, int columnSize) { super(name); if (columnSize == 0) { return; } ByteArrayList data = new ByteArrayList(columnSize); for (int i = 0; i < columnSize; i++) { data.add((byte) 0); } IntIterator intIterator = hits.iterator(); while (intIterator.hasNext()) { byte b = (byte) 1; int i = intIterator.next(); data.set(i, b); } this.data = data; }
/** * Checks whether two lines of anchor text share a source/target document * * @param other The other anchor text * @return True if this line of anchor text has a common source/target * with the other line of anchor text. */ public boolean intersects(AnchorText other) { if(!hasValidDocumentList() || !other.hasValidDocumentList()) { return false; } if(getSize() < other.getSize()) { IntIterator iterator = documentList.iterator(); while(iterator.hasNext()) { if(other.containsDocument(iterator.next())) { return true; } } } else { IntIterator iterator = other.documentList.iterator(); while(iterator.hasNext()) { if(documentList.contains(iterator.next())) { return true; } } } return false; }
/** * Does a thorough comparison of two AnchorText objects. */ public boolean equals(Object obj) { AnchorText other = (AnchorText) obj; if(hasValidDocumentList() && other.hasValidDocumentList()) { if(documentList.size() != other.documentList.size()) { return false; } IntIterator iterator = documentList.iterator(); while(iterator.hasNext()) { if(!other.containsDocument(iterator.next())) { return false; } } } return equalsIgnoreSources(other); }