use of java.util.NoSuchElementException in project intellij-community by JetBrains.
the class VisualLineFragmentsIterator method next.
@Override
public Fragment next() {
if (!hasNext())
throw new NoSuchElementException();
if (mySegmentStartOffset == getCurrentFoldRegionStartOffset()) {
myDelegate = null;
myFoldRegion = myRegions[myCurrentFoldRegionIndex];
assert myFoldRegion.isValid();
mySegmentStartOffset = myFoldRegion.getEndOffset();
myCurrentX += getFoldRegionWidthInPixels(myFoldRegion);
myCurrentVisualColumn += getFoldRegionWidthInColumns(myFoldRegion);
myCurrentStartLogicalLine = myCurrentEndLogicalLine;
myCurrentEndLogicalLine = myDocument.getLineNumber(mySegmentStartOffset);
myCurrentFoldRegionIndex++;
setInlaysAndFragmentIterator();
} else if (myFragmentIterator == null) {
myDelegate = null;
myFoldRegion = null;
myCurrentStartLogicalLine = myCurrentEndLogicalLine;
myCurrentX += getCurrentInlaysWidth();
myCurrentVisualColumn++;
setFragmentIterator();
} else {
myDelegate = myFragmentIterator.next();
myFoldRegion = null;
myCurrentX = myDelegate.getEndX();
myCurrentVisualColumn = myDelegate.getEndVisualColumn();
myCurrentStartLogicalLine = myCurrentEndLogicalLine;
if (!myFragmentIterator.hasNext()) {
myCurrentInlayIndex = getNextInlayIndex();
if (myCurrentInlayIndex < myInlays.size()) {
myFragmentIterator = null;
} else {
mySegmentStartOffset = mySegmentEndOffset;
}
}
}
return myFragment;
}
use of java.util.NoSuchElementException in project intellij-community by JetBrains.
the class FList method iterator.
@NotNull
@Override
public Iterator<E> iterator() {
return new Iterator<E>() {
private FList<E> list = FList.this;
@Override
public boolean hasNext() {
return list.size() > 0;
}
@Override
public E next() {
if (list.size() == 0)
throw new NoSuchElementException();
E res = list.myHead;
list = list.getTail();
assert list != null;
return res;
}
@Override
public void remove() {
throw new UnsupportedOperationException();
}
};
}
use of java.util.NoSuchElementException in project intellij-community by JetBrains.
the class HashSetQueue method iterator.
@NotNull
@Override
public PositionalIterator<T> iterator() {
return new PositionalIterator<T>() {
private QueueEntry<T> cursor = TOMB;
private long count;
@Override
public boolean hasNext() {
return cursor.next != TOMB;
}
@Override
public T next() {
cursor = cursor.next;
count++;
return cursor.t;
}
@Override
public void remove() {
if (cursor == TOMB)
throw new NoSuchElementException();
HashSetQueue.this.remove(cursor.t);
}
@NotNull
@Override
public IteratorPosition<T> position() {
return new MyIteratorPosition<T>(cursor, count, TOMB);
}
};
}
use of java.util.NoSuchElementException in project GDSC-SMLM by aherbert.
the class PeakResultsReader method createPeakResultDeviationsV1.
private PeakResult createPeakResultDeviationsV1(String line) {
try {
float[] params = new float[7];
float[] paramsStdDev = new float[7];
if (isUseScanner()) {
// Code using a Scanner
Scanner scanner = new Scanner(line);
scanner.useDelimiter(tabPattern);
scanner.useLocale(Locale.US);
int id = 0, endPeak = 0;
if (readId)
id = scanner.nextInt();
int peak = scanner.nextInt();
if (readEndFrame)
endPeak = scanner.nextInt();
int origX = scanner.nextInt();
int origY = scanner.nextInt();
float origValue = scanner.nextFloat();
double chiSquared = scanner.nextDouble();
float noise = scanner.nextFloat();
// Ignored but must be read
float signal = scanner.nextFloat();
for (int i = 0; i < params.length; i++) {
params[i] = scanner.nextFloat();
paramsStdDev[i] = scanner.nextFloat();
}
params[Gaussian2DFunction.SIGNAL] = signal;
scanner.close();
if (readId || readEndFrame)
return new ExtendedPeakResult(peak, origX, origY, origValue, chiSquared, noise, params, paramsStdDev, endPeak, id);
else
return new PeakResult(peak, origX, origY, origValue, chiSquared, noise, params, paramsStdDev);
} else {
// JUnit test shows this is faster than the scanner
// Code using split and parse
String[] fields = tabPattern.split(line);
int j = 0;
int id = (readId) ? Integer.parseInt(fields[j++]) : 0;
int peak = Integer.parseInt(fields[j++]);
int endPeak = (readEndFrame) ? Integer.parseInt(fields[j++]) : 0;
int origX = Integer.parseInt(fields[j++]);
int origY = Integer.parseInt(fields[j++]);
float origValue = Float.parseFloat(fields[j++]);
double chiSquared = Double.parseDouble(fields[j++]);
float noise = Float.parseFloat(fields[j++]);
float signal = Float.parseFloat(fields[j++]);
for (int i = 0; i < params.length; i++) {
params[i] = Float.parseFloat(fields[j++]);
paramsStdDev[i] = Float.parseFloat(fields[j++]);
}
params[Gaussian2DFunction.SIGNAL] = signal;
if (readId || readEndFrame)
return new ExtendedPeakResult(peak, origX, origY, origValue, chiSquared, noise, params, paramsStdDev, endPeak, id);
else
return new PeakResult(peak, origX, origY, origValue, chiSquared, noise, params, paramsStdDev);
}
} catch (InputMismatchException e) {
} catch (NoSuchElementException e) {
} catch (IndexOutOfBoundsException e) {
} catch (NumberFormatException e) {
}
return null;
}
use of java.util.NoSuchElementException in project GDSC-SMLM by aherbert.
the class PeakResultsReader method createMALKResult.
private PeakResult createMALKResult(String line) {
try {
float[] params = new float[7];
// To avoid problems handling the data
params[Gaussian2DFunction.X_SD] = params[Gaussian2DFunction.Y_SD] = 1;
if (isUseScanner()) {
// Code using a Scanner
Scanner scanner = new Scanner(line);
scanner.useDelimiter(whitespacePattern);
scanner.useLocale(Locale.US);
params[Gaussian2DFunction.X_POSITION] = scanner.nextFloat();
params[Gaussian2DFunction.Y_POSITION] = scanner.nextFloat();
int peak = scanner.nextInt();
params[Gaussian2DFunction.SIGNAL] = scanner.nextFloat();
scanner.close();
return new PeakResult(peak, 0, 0, 0, 0, 0, params, null);
} else {
// Code using split and parse
String[] fields = whitespacePattern.split(line);
params[Gaussian2DFunction.X_POSITION] = Float.parseFloat(fields[0]);
params[Gaussian2DFunction.Y_POSITION] = Float.parseFloat(fields[1]);
int peak = Integer.parseInt(fields[2]);
params[Gaussian2DFunction.SIGNAL] = Float.parseFloat(fields[3]);
return new PeakResult(peak, 0, 0, 0, 0, 0, params, null);
}
} catch (InputMismatchException e) {
} catch (NoSuchElementException e) {
} catch (IndexOutOfBoundsException e) {
} catch (NumberFormatException e) {
}
return null;
}
Aggregations