示例#1
0
  public String toString() {
    String s = new String();
    SortedSet antecedent = getAntecedent();
    Iterator it2 = antecedent.iterator();
    SortedSet consequence = getConsequence();
    Iterator it3 = consequence.iterator();
    while (it2.hasNext()) {
      String itemCourantant = it2.next().toString();
      s = s + (itemCourantant = itemCourantant + " ");
    }
    String itemCourantcons;
    for (s = s + " --> "; it3.hasNext(); s = s + itemCourantcons + " ")
      itemCourantcons = it3.next().toString();

    s = s + "\t\t";
    s = s + "(S = ";
    String sup = Double.toString((double) (int) (getSupport() * 100D) / 100D);
    s = s + sup;
    s = s + "% ; ";
    s = s + "C = ";
    String c = Double.toString((double) (int) (getConfiance() * 100D) / 100D);
    s = s + c;
    s = s + ")";
    return s;
  }
示例#2
0
  /**
   * Takes a potentially non-sequential alignment and guesses a sequential version of it. Residues
   * from each structure are sorted sequentially and then compared directly.
   *
   * <p>The results of this method are consistent with what one might expect from an identity
   * function, and are therefore useful with {@link #getSymmetryOrder(Map, Map identity, int,
   * float)}.
   *
   * <ul>
   *   <li>Perfect self-alignments will have the same pre-image and image, so will map X->X
   *   <li>Gaps and alignment errors will cause errors in the resulting map, but only locally.
   *       Errors do not propagate through the whole alignment.
   * </ul>
   *
   * <h4>Example:</h4>
   *
   * A non sequential alignment, represented schematically as
   *
   * <pre>
   * 12456789
   * 78912345</pre>
   *
   * would result in a map
   *
   * <pre>
   * 12456789
   * 12345789</pre>
   *
   * @param alignment The non-sequential input alignment
   * @param inverseAlignment If false, map from structure1 to structure2. If true, generate the
   *     inverse of that map.
   * @return A mapping from sequential residues of one protein to those of the other
   * @throws IllegalArgumentException if the input alignment is not one-to-one.
   */
  public static Map<Integer, Integer> guessSequentialAlignment(
      Map<Integer, Integer> alignment, boolean inverseAlignment) {
    Map<Integer, Integer> identity = new HashMap<Integer, Integer>();

    SortedSet<Integer> aligned1 = new TreeSet<Integer>();
    SortedSet<Integer> aligned2 = new TreeSet<Integer>();

    for (Entry<Integer, Integer> pair : alignment.entrySet()) {
      aligned1.add(pair.getKey());
      if (!aligned2.add(pair.getValue()))
        throw new IllegalArgumentException(
            "Alignment is not one-to-one for residue "
                + pair.getValue()
                + " of the second structure.");
    }

    Iterator<Integer> it1 = aligned1.iterator();
    Iterator<Integer> it2 = aligned2.iterator();
    while (it1.hasNext()) {
      if (inverseAlignment) { // 2->1
        identity.put(it2.next(), it1.next());
      } else { // 1->2
        identity.put(it1.next(), it2.next());
      }
    }
    return identity;
  }
示例#3
0
 /**
  * Constructs a new instance of {@code TreeSet} containing the elements of the specified SortedSet
  * and using the same Comparator.
  *
  * @param set the SortedSet of elements to add.
  */
 public TreeSet(SortedSet<E> set) {
   this(set.comparator());
   Iterator<E> it = set.iterator();
   while (it.hasNext()) {
     add(it.next());
   }
 }
示例#4
0
  public Usuario BuscarUsuarioDevolver(Usuario objeto) {
    boolean encontrado = false;
    Usuario auxiliar = null;

    /*
     * Se define un iterador inicializado con el iterador de la colección
     */
    Iterator iterador = UsuariosRegistrados.iterator();

    /*
     * Mientras no se encuentre el elemento y existan mas elementos en la
     * colección, se sigue entrando en el ciclo
     */
    while (!encontrado && iterador.hasNext()) {
      /*
       *  Se obtiene el siguiente objeto del iterador y se le hace un cast
       *  para asignarlo al objeto de tipo Nodo
       */
      auxiliar = (Usuario) iterador.next();

      /*
       * Se invoca al método equals de la clase Nodo para determinar si son
       * iguales. En caso de serlo, se encontró el elemento buscado
       */
      // if (objeto.equals(auxiliar))
      if ((objeto.getNickname().contentEquals(auxiliar.getNickname()))
          && (objeto.getClave().contentEquals(auxiliar.getClave()))) return (auxiliar);
    }
    return (objeto);
  }
 @SuppressWarnings("EmptyCatchBlock")
 static void ensureNotDirectlyModifiable(SortedSet<Integer> unmod) {
   try {
     unmod.add(4);
     fail("UnsupportedOperationException expected");
   } catch (UnsupportedOperationException expected) {
   }
   try {
     unmod.remove(4);
     fail("UnsupportedOperationException expected");
   } catch (UnsupportedOperationException expected) {
   }
   try {
     unmod.addAll(Collections.singleton(4));
     fail("UnsupportedOperationException expected");
   } catch (UnsupportedOperationException expected) {
   }
   try {
     Iterator<Integer> iterator = unmod.iterator();
     iterator.next();
     iterator.remove();
     fail("UnsupportedOperationException expected");
   } catch (UnsupportedOperationException expected) {
   }
 }
示例#6
0
 /** @tests java.util.TreeSet#addAll(java.util.Collection) */
 public void test_addAllLjava_util_Collection() {
   // Test for method boolean
   // java.util.TreeSet.addAll(java.util.Collection)
   SortedSet s = db.createTreeSet("test");
   s.addAll(ts);
   assertTrue("Incorrect size after add", s.size() == ts.size());
   Iterator i = ts.iterator();
   while (i.hasNext()) assertTrue("Returned incorrect set", s.contains(i.next()));
 }
示例#7
0
 /** @tests java.util.TreeSet#iterator() */
 public void test_iterator() {
   // Test for method java.util.Iterator java.util.TreeSet.iterator()
   SortedSet s = db.createTreeSet("test");
   s.addAll(ts);
   Iterator i = ts.iterator();
   Set as = new HashSet(Arrays.asList(objArray));
   while (i.hasNext()) as.remove(i.next());
   assertEquals("Returned incorrect iterator", 0, as.size());
 }
示例#8
0
  private SSLContext createSSLContext(LDAPConnectionHandlerCfg config) throws DirectoryException {
    try {
      DN keyMgrDN = config.getKeyManagerProviderDN();
      KeyManagerProvider<?> keyManagerProvider = DirectoryServer.getKeyManagerProvider(keyMgrDN);
      if (keyManagerProvider == null) {
        logger.error(ERR_NULL_KEY_PROVIDER_MANAGER, keyMgrDN, friendlyName);
        disableAndWarnIfUseSSL(config);
        keyManagerProvider = new NullKeyManagerProvider();
        // The SSL connection is unusable without a key manager provider
      } else if (!keyManagerProvider.containsAtLeastOneKey()) {
        logger.error(ERR_INVALID_KEYSTORE, friendlyName);
        disableAndWarnIfUseSSL(config);
      }

      final SortedSet<String> aliases = new TreeSet<>(config.getSSLCertNickname());
      final KeyManager[] keyManagers;
      if (aliases.isEmpty()) {
        keyManagers = keyManagerProvider.getKeyManagers();
      } else {
        final Iterator<String> it = aliases.iterator();
        while (it.hasNext()) {
          if (!keyManagerProvider.containsKeyWithAlias(it.next())) {
            logger.error(ERR_KEYSTORE_DOES_NOT_CONTAIN_ALIAS, aliases, friendlyName);
            it.remove();
          }
        }

        if (aliases.isEmpty()) {
          disableAndWarnIfUseSSL(config);
        }
        keyManagers =
            SelectableCertificateKeyManager.wrap(
                keyManagerProvider.getKeyManagers(), aliases, friendlyName);
      }

      DN trustMgrDN = config.getTrustManagerProviderDN();
      TrustManagerProvider<?> trustManagerProvider =
          DirectoryServer.getTrustManagerProvider(trustMgrDN);
      if (trustManagerProvider == null) {
        trustManagerProvider = new NullTrustManagerProvider();
      }

      SSLContext sslContext = SSLContext.getInstance(SSL_CONTEXT_INSTANCE_NAME);
      sslContext.init(keyManagers, trustManagerProvider.getTrustManagers(), null);
      return sslContext;
    } catch (Exception e) {
      logger.traceException(e);
      ResultCode resCode = DirectoryServer.getServerErrorResultCode();
      LocalizableMessage message =
          ERR_CONNHANDLER_SSL_CANNOT_INITIALIZE.get(getExceptionMessage(e));
      throw new DirectoryException(resCode, message, e);
    }
  }
示例#9
0
  private Object sampleFromPOPApp(ObjectSet satisfiers, Set exceptions, int n) {
    SortedSet exceptionIndices = new TreeSet();
    for (Iterator iter = exceptions.iterator(); iter.hasNext(); ) {
      Object exception = iter.next();
      exceptionIndices.add(new Integer(satisfiers.indexOf(exception)));
    }

    for (Iterator iter = exceptionIndices.iterator(); iter.hasNext(); ) {
      Integer exceptionIndex = (Integer) iter.next();
      if (exceptionIndex.intValue() <= n) {
        ++n; // skip over this removed index
      } else {
        break;
      }
    }

    return satisfiers.sample(n);
  }
示例#10
0
 /**
  * Does this match?
  *
  * @param token The current token
  * @param no The token number
  * @param stack The fork stack... may be used if there are partial matches
  * @param lookBackStack The reverse stack (ignored)
  */
 public TypeExpr matches(Token token, int no, Stack<MatchFork> stack, List<Token> lookBackStack) {
   if (matches == null) {
     if (set) {
       matches = new TreeSet<WordListEntry>();
       WordListSet wls = WordListSet.getWordListSetByName(wordListName);
       if (wls == null) {
         throw new IllegalArgumentException("Cannot find word list set %" + wordListName);
       }
       for (Map.Entry<String, WordList> entry : wls.getWordListSets()) {
         matches.addAll(WordListSet.getMatchSet(entry.getKey(), token.termText().toLowerCase()));
       }
       // currentMatch = wls.getEntry(token.termText().toLowerCase());
       currentMatch = new WordListEntry(new LinkedList<String>());
       currentMatch.addWord(token.term().toLowerCase());
     } else {
       matches =
           new TreeSet<WordListEntry>(
               WordListSet.getMatchSet(wordListName, token.termText().toLowerCase()));
       // currentMatch =
       // WordListSet.getWordListSetByList(wordListName).getEntry(token.termText().toLowerCase());
       currentMatch = new WordListEntry(new LinkedList<String>());
       currentMatch.addWord(token.term().toLowerCase());
     }
   } else {
     currentMatch.addWord(token.termText().toLowerCase());
   }
   MatchFork mf = MatchFork.find(stack, no, this);
   if (mf != null && (mf.used == true || stack.peek() == mf)) {
     stack.peek().split(no, this);
     return this;
   }
   Iterator<WordListEntry> wleIter = matches.iterator();
   while (wleIter.hasNext()) {
     WordListEntry wle = wleIter.next();
     if (wle.equals(currentMatch)) {
       if (matches.size() > 1 && (stack.empty() || stack.peek().tokenNo < no))
         stack.push(new MatchFork(no, this));
       return next;
     }
     if (!wle.matchable(currentMatch)) wleIter.remove();
   }
   if (matches.isEmpty()) return null;
   else return this;
 }
示例#11
0
    public void resize(int columns) {
      if (columns > myWidth) {
        for (int i = myTabLength * (myWidth / myTabLength); i < columns; i += myTabLength) {
          if (i >= myWidth) {
            myTabStops.add(i);
          }
        }
      } else {
        Iterator<Integer> it = myTabStops.iterator();
        while (it.hasNext()) {
          int i = it.next();
          if (i > columns) {
            it.remove();
          }
        }
      }

      myWidth = columns;
    }
示例#12
0
 public static void main(String[] args) {
   SortedSet<String> sortedSet = new TreeSet<String>();
   Collections.addAll(sortedSet, "one two three four five six seven eight".split(" "));
   print(sortedSet);
   String low = sortedSet.first();
   String high = sortedSet.last();
   print(low);
   print(high);
   Iterator<String> it = sortedSet.iterator();
   for (int i = 0; i <= 6; i++) {
     if (i == 3) low = it.next();
     if (i == 6) high = it.next();
     else it.next();
   }
   print(low);
   print(high);
   print(sortedSet.subSet(low, high));
   print(sortedSet.headSet(high));
   print(sortedSet.tailSet(low));
 }
  public void createBulk(paloelements paloElements) throws paloexception {
    try {

      for (int x = iNbOfCols; x > 1; x--) {

        HashMap<String, HashSet<String>> al = new HashMap<String, HashSet<String>>();
        for (String[] strArr : lstTalendMainIn) {
          String strParent = strArr[x - 2];
          String strChild = strArr[x - 1];
          if (al.containsKey(strParent) == false) {
            al.put(strParent, new HashSet<String>());
          }
          al.get(strParent).add(strChild);
        }

        // System.out.println(al==null);
        Set<?> set = al.entrySet();
        Iterator<?> i = set.iterator();
        while (i.hasNext()) {
          Map.Entry me = (Map.Entry) i.next();

          paloelement plElm = paloElements.getElement((String) me.getKey());
          // System.out.println(null==plElm);
          if (null != plElm) {

            SortedSet<Integer> sorter = new TreeSet<Integer>();
            HashSet<?> hS = (HashSet<?>) me.getValue();
            Iterator<?> i2 = hS.iterator();
            while (i2.hasNext()) {
              String strEntry = (String) i2.next();
              paloelement plConsElm = paloElements.getElement(strEntry);
              if (plConsElm != null) sorter.add((int) plConsElm.getElementIdentifier());
            }

            int[] iArrplConsOld = null;
            if (plElm.hasChildren()) iArrplConsOld = plElm.getElementChildren();

            if (iArrplConsOld != null) {
              for (int oi = 0; oi < iArrplConsOld.length; oi++) {
                sorter.add(iArrplConsOld[oi]);
              }
            }

            Iterator<Integer> itSorted = sorter.iterator();
            StringBuilder sbValues2 = new StringBuilder();
            StringBuilder sbTypes2 = new StringBuilder();

            for (int zi = 0; itSorted.hasNext(); zi++) {
              if (zi > 0) {
                sbValues2.append(",");
                sbTypes2.append(",");
              }
              sbValues2.append(itSorted.next().intValue());
              sbTypes2.append("1");
              // merged[zi] =
              // ((Integer)itSorted.next()).intValue();
            }

            // System.out.println(sbValues2.toString() + " " +
            // sbTypes2.toString());

            // System.out.println("Jetzt");
            // try{
            if (hS != null)
              plElm.updateElementConsolidation(sbValues2.toString(), sbTypes2.toString(), false);
            // }catch(Exception e){
            // System.out.println("ddd");
            // }

            // paloCons.addElementToConsolidation(paloElements.getElement(tConsElement.getElementName()),tConsElement.getFactor());
            // System.out.println(me.getKey() + " : " +
            // me.getValue() );
          }
        }
      }
    } catch (Exception e) {
      System.out.println("Hier " + e.toString());
    }
  }
 Iterator<Long> getTimeMarkIterator() {
   return time_marks.iterator();
 }
示例#15
0
 public SortedMultiSet(SortedSet s) {
   Iterator it = s.iterator();
   while (it.hasNext()) {
     this.add(it.next());
   }
 }
示例#16
0
 public Iterator getIterator() {
   return UsuariosRegistrados.iterator();
 }
示例#17
0
 public Iterator iterator() {
   return m_Models.iterator();
 }