List of usage examples for com.google.common.base Preconditions checkPositionIndex
public static int checkPositionIndex(int index, int size)
From source file:cz.cuni.mff.ms.brodecva.botnicek.ide.check.common.views.ResultsTableModel.java
@Override public String getColumnName(final int column) { Preconditions.checkPositionIndex(column, COLUMNS_NAMES.size()); return COLUMNS_NAMES.get(column); }
From source file:com.alibaba.supersonic.base.infrastructure.View.java
/** * Advances the view by the specified offset. Reduces view size accordingly. * In debug mode, guards against moving past the range. * Note: views can only more forward; the offset is unsigned. * //from w w w . j a v a2 s . c o m * @param offset */ void advance(int offset) { Preconditions.checkPositionIndex(offset, rowCount()); for (int i = 0; i < columnCount(); i++) { Column column = mutableColumn(i); column.resetFromPlusOffset(column, offset); } row_count_ -= (row_count_ < offset ? row_count_ : offset); }
From source file:io.github.msdk.util.MsSpectrumUtil.java
/** * Returns the index of the highest intensity value. Returns null if the * list has no data points.//from w w w .j av a 2 s. c o m * * @return a {@link java.lang.Integer} object. * @param intensityValues * an array of float. * @param size * a {@link java.lang.Integer} object. */ public static @Nullable Integer getBasePeakIndex(@Nonnull float intensityValues[], @Nonnull Integer size) { // Parameter check Preconditions.checkNotNull(intensityValues); Preconditions.checkNotNull(size); Preconditions.checkPositionIndex(size, intensityValues.length); Integer topIndex = null; for (int i = 0; i < size; i++) { if ((topIndex == null) || ((intensityValues[i] > intensityValues[topIndex]))) topIndex = i; } return topIndex; }
From source file:org.sosy_lab.cpachecker.core.algorithm.pdr.DynamicFrameSet.java
@Override public Set<BooleanFormula> getStatesForLocation(CFANode pLocation, int pLevel) { Preconditions.checkPositionIndex(pLevel, currentMaxLevel + 1); if (!frames.containsKey(pLocation)) { initFrameSetForLocation(pLocation); }// w w w . j a v a 2 s . co m /* * Initially start with states at the specified level * and add all states of higher levels afterwards (delta encoding) */ Set<BooleanFormula> states = frames.get(pLocation).get(pLevel).getStates(); for (int i = pLevel + 1; i <= currentMaxLevel; ++i) { states.addAll(frames.get(pLocation).get(i).getStates()); } return states; }
From source file:cz.cuni.mff.ms.brodecva.botnicek.ide.utils.swing.components.draglist.DragOrderableList.java
/** * Pesune prvek v rmci seznamu. Indexy mus bt v mezch po?tu prvk. * //from w ww . j av a 2 s. c o m * @param fromIndex * pvodn index prvku * @param toIndex * nov index prvku * @throws IllegalStateException * pokud byl zmnn model seznamu na jin ne vchoz */ public final void moveToIndex(final int fromIndex, final int toIndex) { final ListModel<E> model = getModel(); Preconditions.checkPositionIndex(fromIndex, model.getSize()); Preconditions.checkPositionIndex(toIndex, model.getSize()); if (fromIndex == toIndex) { return; } Preconditions.checkState(model instanceof DefaultListModel<?>); final DefaultListModel<E> defaultModel = (DefaultListModel<E>) model; if (fromIndex > toIndex) { final E movedElement = defaultModel.remove(fromIndex); defaultModel.add(toIndex, movedElement); } else if (fromIndex < toIndex) { final E movedElement = defaultModel.get(fromIndex); defaultModel.add(toIndex, movedElement); defaultModel.remove(fromIndex); } else { assert false; } }
From source file:io.github.msdk.util.ChromatogramUtil.java
/** * Returns the retention time of this feature. * * @return a float./* ww w.jav a 2 s .c om*/ * @param rtValues * an array of * {@link io.github.msdk.datamodel.rawdata.ChromatographyInfo} * objects. * @param intensityValues * an array of float. * @param size * a {@link java.lang.Integer} object. */ public static @Nullable Float getRt(@Nonnull ChromatographyInfo rtValues[], @Nonnull float[] intensityValues, @Nonnull Integer size) { // Parameter check Preconditions.checkNotNull(rtValues); Preconditions.checkNotNull(intensityValues); Preconditions.checkNotNull(size); Preconditions.checkPositionIndex(size, rtValues.length); Preconditions.checkPositionIndex(size, intensityValues.length); if (size == 0) return null; // Find the maximum intensity index int max = 0; for (int i = 1; i < size; i++) { if (intensityValues[i] > intensityValues[max]) { max = i; } } return rtValues[max].getRetentionTime(); }
From source file:org.sosy_lab.cpachecker.core.algorithm.pdr.DynamicFrameSet.java
@Override public Map<CFANode, Set<BooleanFormula>> getStatesForAllLocations(int pLevel) { Preconditions.checkPositionIndex(pLevel, currentMaxLevel + 1); Map<CFANode, Set<BooleanFormula>> statesPerLocation = Maps.newHashMap(); for (CFANode location : frames.keySet()) { statesPerLocation.put(location, getStatesForLocation(location, pLevel)); }//from w w w . java 2 s.com return statesPerLocation; }
From source file:org.sosy_lab.cpachecker.core.algorithm.pdr.DynamicFrameSet.java
@Override public void blockState(BooleanFormula pState, int pMaxLevel, CFANode pLocation) { Preconditions.checkPositionIndex(pMaxLevel, currentMaxLevel); if (!frames.containsKey(pLocation)) { initFrameSetForLocation(pLocation); }/*w w w. j av a 2 s . c om*/ // TODO subsume here too? // Only need to add to highest level (delta encoding) frames.get(pLocation).get(pMaxLevel).addState(bfmgr.not(pState)); }
From source file:io.github.msdk.util.MsSpectrumUtil.java
/** * Returns the index of the highest intensity value. Returns null if the * list has no data points or if no data point was found within the mz * range./*from w w w . j a va 2s . c o m*/ * * @param mzRange * a {@link com.google.common.collect.Range} object. * @return a {@link java.lang.Integer} object. * @param mzValues * an array of double. * @param intensityValues * an array of float. * @param size * a {@link java.lang.Integer} object. */ public static @Nullable Integer getBasePeakIndex(@Nonnull double mzValues[], @Nonnull float intensityValues[], @Nonnull Integer size, @Nonnull Range<Double> mzRange) { // Parameter check Preconditions.checkNotNull(intensityValues); Preconditions.checkNotNull(mzValues); Preconditions.checkNotNull(size); Preconditions.checkPositionIndex(size, mzValues.length); Preconditions.checkPositionIndex(size, intensityValues.length); Preconditions.checkNotNull(mzRange); Integer topIndex = null; for (int i = 0; i < size; i++) { if ((topIndex == null || intensityValues[i] > intensityValues[topIndex]) && mzRange.contains(mzValues[i])) topIndex = i; } return topIndex; }
From source file:cz.cuni.mff.ms.brodecva.botnicek.ide.utils.swing.components.draglist.DragOrderableList.java
/** * Smae prvek danho indexu./*from w w w .j a va2 s . c om*/ * * @param index * index smazanho prvku * @throws IllegalStateException * pokud byl zmnn model na jin ne vchoz */ public final void removeElementAt(final int index) { final ListModel<E> model = getModel(); Preconditions.checkPositionIndex(index, model.getSize()); Preconditions.checkState(model instanceof DefaultListModel<?>); final DefaultListModel<E> defaultModel = (DefaultListModel<E>) model; defaultModel.remove(index); }