Java Code Examples for java.util.Vector#isEmpty()

The following examples show how to use java.util.Vector#isEmpty() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: NativeGSSFactory.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
private GSSCredElement getCredFromSubject(GSSNameElement name,
                                          boolean initiate)
    throws GSSException {
    Oid mech = cStub.getMech();
    Vector<GSSCredElement> creds = GSSUtil.searchSubject
        (name, mech, initiate, GSSCredElement.class);

    // If Subject is present but no native creds available
    if (creds != null && creds.isEmpty()) {
        if (GSSUtil.useSubjectCredsOnly(caller)) {
            throw new GSSException(GSSException.NO_CRED);
        }
    }

    GSSCredElement result = ((creds == null || creds.isEmpty()) ?
                             null : creds.firstElement());
    // Force permission check before returning the cred to caller
    if (result != null) {
        result.doServicePermCheck();
    }
    return result;
}
 
Example 2
Source File: PrivateActivity.java    From SimplicityBrowser with MIT License 6 votes vote down vote up
@SuppressWarnings("deprecation")
private static void clearCookieByUrlInternal(String url, CookieManager pCookieManager, CookieSyncManager pCookieSyncManager) {
    if (TextUtils.isEmpty(url)) {
        return;
    }
    String cookieString = pCookieManager.getCookie(url);
    Vector<String> cookie = getCookieNamesByUrl(cookieString);
    if (cookie == null || cookie.isEmpty()) {
        return;
    }
    int len = cookie.size();
    for (int i = 0; i < len; i++) {
        pCookieManager.setCookie(url, cookie.get(i) + "=-1");
    }
    pCookieSyncManager.sync();
}
 
Example 3
Source File: SnmpQManager.java    From JDKSourceCode1.8 with MIT License 6 votes vote down vote up
public synchronized Vector<SnmpInformRequest> getAllOutstandingRequest(long margin) {
    int i ;
    Vector<SnmpInformRequest> outreq = new Vector<>();
    while (true) {
        if (waitUntilReady() == true) {
            long refTime = System.currentTimeMillis() + margin ;

            for (i = size() ; i > 0 ; i--) {
                SnmpInformRequest req = getRequestAt(i-1) ;
                if (req.getAbsNextPollTime() > refTime)
                    break ;
                outreq.addElement(req) ;
            }

            if (! outreq.isEmpty()) {
                elementCount -= outreq.size() ;
                return outreq ;
            }
        }
        else
            return null;
    }
}
 
Example 4
Source File: DecodeThread.java    From Mobike with Apache License 2.0 6 votes vote down vote up
DecodeThread(CaptureActivity activity,
             Vector<BarcodeFormat> decodeFormats,
             String characterSet,
             ResultPointCallback resultPointCallback) {

    this.activity = activity;
    handlerInitLatch = new CountDownLatch(1);

    hints = new Hashtable<DecodeHintType, Object>(3);

    if (decodeFormats == null || decodeFormats.isEmpty()) {
        decodeFormats = new Vector<BarcodeFormat>();
        decodeFormats.addAll(DecodeFormatManager.ONE_D_FORMATS);
        decodeFormats.addAll(DecodeFormatManager.QR_CODE_FORMATS);
        decodeFormats.addAll(DecodeFormatManager.DATA_MATRIX_FORMATS);
    }

    hints.put(DecodeHintType.POSSIBLE_FORMATS, decodeFormats);

    if (characterSet != null) {
        hints.put(DecodeHintType.CHARACTER_SET, characterSet);
    }

    hints.put(DecodeHintType.NEED_RESULT_POINT_CALLBACK, resultPointCallback);
}
 
Example 5
Source File: jtwain.java    From mmscomputing with GNU Lesser General Public License v3.0 6 votes vote down vote up
static /* public */ void getIdentities(TwainScanner sc, Vector list)throws TwainIOException{
  if(setScanner(sc)){
    TwainSourceManager sm=getSourceManager();                 // jtwain might not be up and running yet
    sm.getSource().checkState(3);                             // System.err.println("select: try "+name);

    Semaphore s = new Semaphore(0,true);                      // need to wait for native thread to retrieve list of identities
    Object[] parameter = {list,s};                            // need to transport two objects via one parameter to cbexecute
    trigger(parameter,2);                                     // call cbexecute case 2
    try{
      s.tryAcquire(3000,TimeUnit.MILLISECONDS);
      if(list.isEmpty() && (parameter[1]!=null)){
        throw new TwainIOException(jtwain.class.getName()+".getIdentities\n\tCould not retrieve device names. Request timed out.");
      }
    }catch(InterruptedException ie){
      throw new TwainIOException(jtwain.class.getName()+".getIdentities\n\tCould not retrieve device names. Request was interrupted.");
    }
  }
}
 
Example 6
Source File: Krb5MechFactory.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
private static Krb5CredElement getCredFromSubject(GSSNameSpi name,
                                                  boolean initiate)
    throws GSSException {
    Vector<Krb5CredElement> creds =
        GSSUtil.searchSubject(name, GSS_KRB5_MECH_OID, initiate,
                              (initiate ?
                               Krb5InitCredential.class :
                               Krb5AcceptCredential.class));

    Krb5CredElement result = ((creds == null || creds.isEmpty()) ?
                              null : creds.firstElement());

    // Force permission check before returning the cred to caller
    if (result != null) {
        if (initiate) {
            checkInitCredPermission((Krb5NameElement) result.getName());
        } else {
            checkAcceptCredPermission
                ((Krb5NameElement) result.getName(), name);
        }
    }
    return result;
}
 
Example 7
Source File: Game.java    From megamek with GNU General Public License v2.0 6 votes vote down vote up
public void removeMinefieldHelper(Minefield mf) {
    Vector<Minefield> mfs = minefields.get(mf.getCoords());
    if (mfs == null) {
        return;
    }

    Enumeration<Minefield> e = mfs.elements();
    while (e.hasMoreElements()) {
        Minefield mftemp = e.nextElement();
        if (mftemp.equals(mf)) {
            mfs.removeElement(mftemp);
            break;
        }
    }
    if (mfs.isEmpty()) {
        minefields.remove(mf.getCoords());
    }
}
 
Example 8
Source File: BundleImpl.java    From knopflerfish.org with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Get bundle data. Get resources from bundle or fragment jars.
 *
 * @see org.osgi.framework.Bundle#findEntries
 */
public Enumeration<URL> findEntries(String path, String filePattern, boolean recurse) {
  if (secure.okResourceAdminPerm(this)) {
    // Try to resolve, so that fragments attach.
    getUpdatedState(new BundleImpl [] { this }, false);
    final Vector<URL> res = secure.callFindEntries(current(), path, filePattern, recurse);
    if (!res.isEmpty()) {
      return res.elements();
    }
  }
  return null;
}
 
Example 9
Source File: BackTracker.java    From unitime with Apache License 2.0 5 votes vote down vote up
public static boolean doBack(HttpServletRequest request, HttpServletResponse response) throws IOException {
	synchronized (request.getSession()) {
		String uri = request.getParameter("uri");
		Vector back = getBackList(request.getSession());
		if (back.isEmpty()) {
			if (uri != null) {
				response.sendRedirect(response.encodeURL(uri));
				return true;
			}
			return false;
		}
		if (uri==null) {
			uri = ((String[])back.lastElement())[0];
			back.remove(back.size()-1);
		} else {
			String uriNoBack = uri;
			if (uriNoBack.indexOf("backType=")>=0)
				uriNoBack = uriNoBack.substring(0, uriNoBack.indexOf("backType=")-1);
			while (!back.isEmpty() && !uriNoBack.equals(((String[])back.lastElement())[0]))
				back.remove(back.size()-1);
			if (!back.isEmpty())
				back.remove(back.size()-1);
		}
		if (uri.indexOf("backType=")<0 && request.getAttribute("backType")!=null && request.getAttribute("backId")!=null) {
			if (uri.indexOf('?')>0)
				uri += "&backType="+request.getAttribute("backType")+"&backId="+request.getAttribute("backId")+"#back";
			else
				uri += "?backType="+request.getAttribute("backType")+"&backId="+request.getAttribute("backId")+"#back";
			
		}
		response.sendRedirect(response.encodeURL(uri));
		return true;
	}
}
 
Example 10
Source File: Session.java    From org.openntf.domino with Apache License 2.0 5 votes vote down vote up
@Override
public Collection<String> getUserNameCollection() {
	Collection<String> result = new ArrayList<String>();
	Vector<org.openntf.domino.Name> v = this.getUserNameList();
	if (!v.isEmpty()) {
		for (org.openntf.domino.Name name : v) {
			result.add(name.getCanonical());
			// DominoUtils.incinerate(name);
		}
	}
	return result;
}
 
Example 11
Source File: TSFileHandler.java    From translationstudio8 with GNU General Public License v2.0 5 votes vote down vote up
private Vector<NoteBean> getNotes(VTDUtils vu) throws XPathEvalException, NavException, XPathParseException {
	Vector<NoteBean> notes = new Vector<NoteBean>();
	VTDNav vn = vu.getVTDNav();
	AutoPilot ap = new AutoPilot(vn);
	ap.selectXPath("./note");
	while (ap.evalXPath() != -1) {
		NoteBean note = new NoteBean(vu.getElementContent());

		int attInx = vn.getAttrVal("xml:lang");
		if (attInx != -1) {
			note.setLang(vn.toString(attInx));
		}

		attInx = vn.getAttrVal("from");
		if (attInx != -1) {
			note.setFrom(vn.toString(attInx));
		}

		attInx = vn.getAttrVal("priority");
		if (attInx != -1) {
			note.setPriority(vn.toString(attInx));
		}

		attInx = vn.getAttrVal("annotates");
		if (attInx != -1) {
			note.setAnnotates(vn.toString(attInx));
		}

		notes.add(note);
	}

	if (notes.isEmpty()) {
		notes = null;
	}

	return notes;
}
 
Example 12
Source File: Area.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Tests whether the geometries of the two <code>Area</code> objects
 * are equal.
 * This method will return false if the argument is null.
 * @param   other  the <code>Area</code> to be compared to this
 *          <code>Area</code>
 * @return  <code>true</code> if the two geometries are equal;
 *          <code>false</code> otherwise.
 * @since 1.2
 */
public boolean equals(Area other) {
    // REMIND: A *much* simpler operation should be possible...
    // Should be able to do a curve-wise comparison since all Areas
    // should evaluate their curves in the same top-down order.
    if (other == this) {
        return true;
    }
    if (other == null) {
        return false;
    }
    Vector c = new AreaOp.XorOp().calculate(this.curves, other.curves);
    return c.isEmpty();
}
 
Example 13
Source File: HttpUserAgentTest.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
private void assertMatchingSet( String comment, Object[] expected, Vector foundItems ) {
    Vector expectedItems = new Vector();
    for (int i = 0; i < expected.length; i++) expectedItems.addElement( expected[ i ] );
    for (int i = 0; i < expected.length; i++) {
        if (!foundItems.contains( expected[ i ] )) {
            fail( comment + ": expected " + asText( expected ) + " but missing " + expected[ i ] );
        } else {
            foundItems.removeElement( expected[ i ] );
        }
    }

    if (!foundItems.isEmpty()) fail( comment + ": expected " + asText( expected ) + " but found superfluous" + foundItems.firstElement() );
}
 
Example 14
Source File: Main.java    From Gaalop with GNU Lesser General Public License v3.0 5 votes vote down vote up
private static boolean testEqual(Multivector m1, Multivector m2) {
    Vector<BladeRef> v1 = new Vector<BladeRef>(m1.getBlades());
    Vector<BladeRef> v2 = new Vector<BladeRef>(m2.getBlades());
    
    if (v1.size() != v2.size())
        return false;
    
    for (BladeRef b2: v2) {
        if (v1.contains(b2))
            v1.remove(b2);
    }
    
    return v1.isEmpty();
}
 
Example 15
Source File: Timer.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Removes all the timer notifications corresponding to the specified type from the list of notifications.
 *
 * @param type The timer notification type.
 *
 * @exception InstanceNotFoundException The specified type does not correspond to any timer notification
 * in the list of notifications of this timer MBean.
 */
public synchronized void removeNotifications(String type) throws InstanceNotFoundException {

    Vector<Integer> v = getNotificationIDs(type);

    if (v.isEmpty())
        throw new InstanceNotFoundException("Timer notifications to remove not in the list of notifications");

    for (Integer i : v)
        removeNotification(i);
}
 
Example 16
Source File: NameUtil.java    From MaxKey with Apache License 2.0 5 votes vote down vote up
/**
 * Gets the common name from the given X509Name.
 * 
 * @param name
 *            the X.509 name
 * @return the common name, null if not found
 */
public static String getCommonName(X509Name name) {
	if (name == null) {
		return null;
	}

	Vector<?> values = name.getValues(X509Name.CN);
	if (values == null || values.isEmpty()) {
		return null;
	}

	return values.get(0).toString();
}
 
Example 17
Source File: IsotopeGrouperTask.java    From mzmine3 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Helper method for fitPattern. Fits only one half of the pattern.
 *
 * @param p Pattern is fitted around this peak
 * @param charge Charge state of the fitted pattern
 * @param direction Defines which half to fit: -1=fit to peaks before start M/Z, +1=fit to peaks
 *        after start M/Z
 * @param fittedPeaks All matching peaks will be added to this set
 */
private void fitHalfPattern(Feature p, int charge, int direction, Vector<Feature> fittedPeaks,
    Feature[] sortedPeaks) {

  // Use M/Z and RT of the strongest peak of the pattern (peak 'p')
  double mainMZ = p.getMZ();
  double mainRT = p.getRT();

  // Variable n is the number of peak we are currently searching. 1=first
  // peak before/after start peak, 2=peak before/after previous, 3=...
  boolean followingPeakFound;
  int n = 1;
  do {

    // Assume we don't find match for n:th peak in the pattern (which
    // will end the loop)
    followingPeakFound = false;

    // Loop through all peaks, and collect candidates for the n:th peak
    // in the pattern
    Vector<Feature> goodCandidates = new Vector<Feature>();
    for (int ind = 0; ind < sortedPeaks.length; ind++) {

      Feature candidatePeak = sortedPeaks[ind];

      if (candidatePeak == null)
        continue;

      // Get properties of the candidate peak
      double candidatePeakMZ = candidatePeak.getMZ();
      double candidatePeakRT = candidatePeak.getRT();

      // Does this peak fill all requirements of a candidate?
      // - within tolerances from the expected location (M/Z and RT)
      // - not already a fitted peak (only necessary to avoid
      // conflicts when parameters are set too wide)
      double isotopeMZ = candidatePeakMZ - isotopeDistance * direction * n / charge;

      if (mzTolerance.checkWithinTolerance(isotopeMZ, mainMZ)
          && rtTolerance.checkWithinTolerance(candidatePeakRT, mainRT)
          && (!fittedPeaks.contains(candidatePeak))) {
        goodCandidates.add(candidatePeak);

      }

    }

    // Add all good candidates to the isotope pattern (note: in MZmine
    // 2.3 and older, only the highest candidate was added)
    if (!goodCandidates.isEmpty()) {

      fittedPeaks.addAll(goodCandidates);

      // n:th peak was found, so let's move on to n+1
      n++;
      followingPeakFound = true;
    }

  } while (followingPeakFound);

}
 
Example 18
Source File: XSDAbstractTraverser.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
XSAnnotationImpl traverseSyntheticAnnotation(Element annotationParent, String initialContent,
        Object[] parentAttrs, boolean isGlobal, XSDocumentInfo schemaDoc) {

    String contents = initialContent;

    // find the grammar; fSchemaHandler must be known!
    SchemaGrammar grammar = fSchemaHandler.getGrammar(schemaDoc.fTargetNamespace);
    // fish out local attributes passed from parent
    Vector annotationLocalAttrs = (Vector)parentAttrs[XSAttributeChecker.ATTIDX_NONSCHEMA];
    // optimize for case where there are no local attributes
    if (annotationLocalAttrs != null && !annotationLocalAttrs.isEmpty()) {
        StringBuffer localStrBuffer = new StringBuffer(64);
        localStrBuffer.append(" ");
        // Vector should contain rawname value pairs
        int i = 0;
        while (i < annotationLocalAttrs.size()) {
            String rawname = (String)annotationLocalAttrs.elementAt(i++);
            int colonIndex = rawname.indexOf(':');
            String prefix, localpart;
            if (colonIndex == -1) {
                prefix = "";
                localpart = rawname;
            }
            else {
                prefix = rawname.substring(0,colonIndex);
                localpart = rawname.substring(colonIndex+1);
            }
            String uri = schemaDoc.fNamespaceSupport.getURI(fSymbolTable.addSymbol(prefix));
            localStrBuffer.append(rawname)
            .append("=\"");
            String value = (String)annotationLocalAttrs.elementAt(i++);
            // search for pesky "s and <s within attr value:
            value = processAttValue(value);
            localStrBuffer.append(value)
            .append("\" ");
        }
        // and now splice it into place; immediately after the annotation token, for simplicity's sake
        StringBuffer contentBuffer = new StringBuffer(contents.length() + localStrBuffer.length());
        int annotationTokenEnd = contents.indexOf(SchemaSymbols.ELT_ANNOTATION);
        // annotation must occur somewhere or we're in big trouble...
        if(annotationTokenEnd == -1) return null;
        annotationTokenEnd += SchemaSymbols.ELT_ANNOTATION.length();
        contentBuffer.append(contents.substring(0,annotationTokenEnd));
        contentBuffer.append(localStrBuffer.toString());
        contentBuffer.append(contents.substring(annotationTokenEnd, contents.length()));
        final String annotation = contentBuffer.toString();
        if (fValidateAnnotations) {
            schemaDoc.addAnnotation(new XSAnnotationInfo(annotation, annotationParent));
        }
        return new XSAnnotationImpl(annotation, grammar);
    } else {
        if (fValidateAnnotations) {
            schemaDoc.addAnnotation(new XSAnnotationInfo(contents, annotationParent));
        }
        return new XSAnnotationImpl(contents, grammar);
    }
}
 
Example 19
Source File: XSDAbstractTraverser.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
XSAnnotationImpl traverseAnnotationDecl(Element annotationDecl, Object[] parentAttrs,
        boolean isGlobal, XSDocumentInfo schemaDoc) {
    // General Attribute Checking
    Object[] attrValues = fAttrChecker.checkAttributes(annotationDecl, isGlobal, schemaDoc);
    fAttrChecker.returnAttrArray(attrValues, schemaDoc);

    String contents = DOMUtil.getAnnotation(annotationDecl);
    Element child = DOMUtil.getFirstChildElement(annotationDecl);
    if (child != null) {
        do {
            String name = DOMUtil.getLocalName(child);

            // the only valid children of "annotation" are
            // "appinfo" and "documentation"
            if (!((name.equals(SchemaSymbols.ELT_APPINFO)) ||
                    (name.equals(SchemaSymbols.ELT_DOCUMENTATION)))) {
                reportSchemaError("src-annotation", new Object[]{name}, child);
            }
            else {
                // General Attribute Checking
                // There is no difference between global or local appinfo/documentation,
                // so we assume it's always global.
                attrValues = fAttrChecker.checkAttributes(child, true, schemaDoc);
                fAttrChecker.returnAttrArray(attrValues, schemaDoc);
            }

            child = DOMUtil.getNextSiblingElement(child);
        }
        while (child != null);
    }
    // if contents was null, must have been some kind of error;
    // nothing to contribute to PSVI
    if (contents == null) return null;

    // find the grammar; fSchemaHandler must be known!
    SchemaGrammar grammar = fSchemaHandler.getGrammar(schemaDoc.fTargetNamespace);
    // fish out local attributes passed from parent
    Vector annotationLocalAttrs = (Vector)parentAttrs[XSAttributeChecker.ATTIDX_NONSCHEMA];
    // optimize for case where there are no local attributes
    if(annotationLocalAttrs != null && !annotationLocalAttrs.isEmpty()) {
        StringBuffer localStrBuffer = new StringBuffer(64);
        localStrBuffer.append(" ");
        // Vector should contain rawname value pairs
        int i = 0;
        while (i < annotationLocalAttrs.size()) {
            String rawname = (String)annotationLocalAttrs.elementAt(i++);
            int colonIndex = rawname.indexOf(':');
            String prefix, localpart;
            if (colonIndex == -1) {
                prefix = "";
                localpart = rawname;
            }
            else {
                prefix = rawname.substring(0,colonIndex);
                localpart = rawname.substring(colonIndex+1);
            }
            String uri = schemaDoc.fNamespaceSupport.getURI(fSymbolTable.addSymbol(prefix));
            if (annotationDecl.getAttributeNS(uri, localpart).length() != 0) {
                i++; // skip the next value, too
                continue;
            }
            localStrBuffer.append(rawname)
            .append("=\"");
            String value = (String)annotationLocalAttrs.elementAt(i++);
            // search for pesky "s and <s within attr value:
            value = processAttValue(value);
            localStrBuffer.append(value)
            .append("\" ");
        }
        // and now splice it into place; immediately after the annotation token, for simplicity's sake
        StringBuffer contentBuffer = new StringBuffer(contents.length() + localStrBuffer.length());
        int annotationTokenEnd = contents.indexOf(SchemaSymbols.ELT_ANNOTATION);
        // annotation must occur somewhere or we're in big trouble...
        if(annotationTokenEnd == -1) return null;
        annotationTokenEnd += SchemaSymbols.ELT_ANNOTATION.length();
        contentBuffer.append(contents.substring(0,annotationTokenEnd));
        contentBuffer.append(localStrBuffer.toString());
        contentBuffer.append(contents.substring(annotationTokenEnd, contents.length()));
        final String annotation = contentBuffer.toString();
        if (fValidateAnnotations) {
            schemaDoc.addAnnotation(new XSAnnotationInfo(annotation, annotationDecl));
        }
        return new XSAnnotationImpl(annotation, grammar);
    } else {
        if (fValidateAnnotations) {
            schemaDoc.addAnnotation(new XSAnnotationInfo(contents, annotationDecl));
        }
        return new XSAnnotationImpl(contents, grammar);
    }

}
 
Example 20
Source File: MassListDeisotoper.java    From mzmine2 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Helper method for fitPattern. Fits only one half of the pattern.
 * 
 * @param p Pattern is fitted around this peak
 * @param charge Charge state of the fitted pattern
 * @param direction Defines which half to fit: -1=fit to peaks before start M/Z, +1=fit to peaks
 *        after start M/Z
 * @param fittedPeaks All matching peaks will be added to this set
 * @param mzTolerance
 */
private static void fitHalfPattern(DataPoint p, int charge, int direction,
    List<DataPoint> fittedPeaks, DataPoint[] sortedPeaks, double isotopeDistance,
    MZTolerance mzTolerance) {

  double mainMZ = p.getMZ();

  // Variable n is the number of peak we are currently searching. 1=first
  // peak before/after start peak, 2=peak before/after previous, 3=...
  boolean followingPeakFound;
  int n = 1;
  do {

    // Assume we don't find match for n:th peak in the pattern (which
    // will end the loop)
    followingPeakFound = false;

    // Loop through all peaks, and collect candidates for the n:th peak
    // in the pattern
    Vector<DataPoint> goodCandidates = new Vector<DataPoint>();
    for (int ind = 0; ind < sortedPeaks.length; ind++) {

      DataPoint candidatePeak = sortedPeaks[ind];

      if (candidatePeak == null || Double.compare(candidatePeak.getIntensity(), 0) == 0)
        continue;

      // Get properties of the candidate peak
      double candidatePeakMZ = candidatePeak.getMZ();

      // Does this peak fill all requirements of a candidate?
      // - within tolerances from the expected location (M/Z and RT)
      // - not already a fitted peak (only necessary to avoid
      // conflicts when parameters are set too wide)
      double isotopeMZ = candidatePeakMZ - isotopeDistance * direction * n / charge;

      if (mzTolerance.checkWithinTolerance(isotopeMZ, mainMZ)
          // && rtTolerance.checkWithinTolerance(candidatePeakRT, mainRT)
          && (!fittedPeaks.contains(candidatePeak))) {
        goodCandidates.add(candidatePeak);

      }

    }

    // Add all good candidates to the isotope pattern (note: in MZmine
    // 2.3 and older, only the highest candidate was added)
    if (!goodCandidates.isEmpty()) {

      fittedPeaks.addAll(goodCandidates);

      // n:th peak was found, so let's move on to n+1
      n++;
      followingPeakFound = true;
    }

  } while (followingPeakFound);

}