コード例 #1
0
  public void ImprimirColeccion() {
    int i;
    Usuario registro;

    /*
     * Se define un arreglo de tipo Object (la clase genérica Java)
     */
    Object[] arreglo;

    /*
     * Se convierte la colección pasada como parámetro a un array, que
     * es asignado al arreglo de tipo Object
     */
    arreglo = UsuariosRegistrados.toArray();

    System.out.println("DATOS");

    /*
     * Se hace un recorrido del arreglo de tipo Object y se imprime
     * la información de la casilla i
     */
    for (i = 0; i < arreglo.length; i++) {
      registro = (Usuario) arreglo[i];
      System.out.println("Nick: " + registro.getNickname());
      System.out.println("Clave: " + registro.getClave());
      System.out.println("Nombre" + registro.getNombre());
      System.out.println();
    }

    System.out.println("\n\n");
  }
コード例 #2
0
ファイル: DeviceProfile.java プロジェクト: pedrokiefer/ols
  /**
   * Returns all supported sample rates.
   *
   * @return an array of sample rates, in Hertz, never <code>null</code>.
   */
  public Integer[] getSampleRates() {
    final String rawValue = this.properties.get(DEVICE_SAMPLERATES);
    final String[] values = rawValue.split(",\\s*");
    final SortedSet<Integer> result =
        new TreeSet<Integer>(
            NumberUtils.<Integer>createNumberComparator(false /* aSortAscending */));
    for (String value : values) {
      result.add(Integer.valueOf(value.trim()));
    }

    return result.toArray(new Integer[result.size()]);
  }
コード例 #3
0
  @Test
  public void canGetAllKeysAsSortedSet() {
    Map<String, String> map = new HashMap<>();

    map.put("key2", "value2");
    map.put("key1", "value1");
    map.put("key3", "value3");

    SortedSet<String> keys = new TreeSet<String>(map.keySet());

    String[] keysa = new String[keys.size()];
    keys.toArray(keysa);

    assertEquals("key1", keysa[0]);
    assertEquals("key2", keysa[1]);
    assertEquals("key3", keysa[2]);
  }
コード例 #4
0
 static {
   SortedSet<Locale> languages =
       new TreeSet<Locale>(
           new Comparator<Locale>() {
             @Override
             public int compare(Locale o1, Locale o2) {
               if (o1.getDisplayLanguage().trim().compareTo(o2.getDisplayLanguage().trim()) == 0) {
                 return o1.getDisplayCountry().trim().compareTo(o2.getDisplayCountry().trim());
               } else {
                 return o1.getDisplayLanguage().trim().compareTo(o2.getDisplayLanguage().trim());
               }
             }
           });
   Collections.addAll(
       languages,
       new Locale("en", "US"),
       new Locale("de", "DE"),
       new Locale("zh", "CN"),
       new Locale("zh", "TW"),
       new Locale("cs", "CZ"),
       new Locale("nl", "BE"),
       new Locale("nl", "NL"),
       new Locale("en", "AU"),
       new Locale("en", "GB"),
       new Locale("en", "CA"),
       new Locale("en", "NZ"),
       new Locale("en", "SG"),
       new Locale("fr", "BE"),
       new Locale("fr", "CA"),
       new Locale("fr", "FR"),
       new Locale("fr", "CH"),
       new Locale("de", "AT"),
       new Locale("de", "LI"),
       new Locale("de", "CH"),
       new Locale("it", "IT"),
       new Locale("it", "CH"),
       new Locale("ja", "JP"),
       new Locale("ko", "KR"),
       new Locale("pl", "PL"),
       new Locale("ru", "RU"),
       new Locale("es", "ES"),
       new Locale("ar", "EG"),
       new Locale("ar", "IL"),
       new Locale("bg", "BG"),
       new Locale("ca", "ES"),
       new Locale("hr", "HR"),
       new Locale("da", "DK"),
       new Locale("en", "IN"),
       new Locale("en", "IE"),
       new Locale("en", "ZA"),
       new Locale("fi", "FI"),
       new Locale("el", "GR"),
       new Locale("iw", "IL"),
       new Locale("hi", "IN"),
       new Locale("hu", "HU"),
       new Locale("in", "ID"),
       new Locale("lv", "LV"),
       new Locale("lt", "LT"),
       new Locale("nb", "NO"),
       new Locale("pt", "BR"),
       new Locale("pt", "PT"),
       new Locale("ro", "RO"),
       new Locale("sr", "RS"),
       new Locale("sk", "SK"),
       new Locale("sl", "SI"),
       new Locale("es", "US"),
       new Locale("sv", "SE"),
       new Locale("tl", "PH"),
       new Locale("th", "TH"),
       new Locale("tr", "TR"),
       new Locale("uk", "UA"),
       new Locale("vi", "VN"));
   LOCALES = new Locale[languages.size()];
   languages.toArray(LOCALES);
 }
コード例 #5
0
ファイル: ModelList.java プロジェクト: alishakiba/jDenetX
 public Object getElementAt(int index) {
   // Return the appropriate element
   return m_Models.toArray()[index];
 }
コード例 #6
0
  /**
   * Collects the differentially expressed segments (segment pairs with the same start and end, but
   * one member of the pair has the LINE type while the other does not) from a given segmentation.
   *
   * @param seg
   * @param c1
   * @param c2
   * @return
   */
  private Collection<DifferentialKey> differentialRegions(InputSegmentation seg, int c1, int c2) {
    ArrayList<DifferentialKey> keys = new ArrayList<DifferentialKey>();

    // Get the ground-truth data, so we can assemble the region identifiers when
    // we've found the differentially expressed segments.
    InputData data = seg.input;
    Integer[] locations = data.locations();
    String strand = data.strand();
    String chrom = data.chrom();

    // Most of the setup of this method is filtering and sorting the Segment objects,
    // so that we *only* consider the segments from the two given channels (c1, and c2)
    // and so that we consider them in order, so that we're not comparing segments
    // different parts of the input chunk.
    SortedSet<Segment> c1Segs = new TreeSet<Segment>();
    SortedSet<Segment> c2Segs = new TreeSet<Segment>();

    for (Segment s : seg.segments) {
      if (s.channel == c1) {
        c1Segs.add(s);
      } else if (s.channel == c2) {
        c2Segs.add(s);
      }
    }

    // These should now be in sorted order, given that we built them using the
    // SortedSet objects.
    Segment[] c1array = c1Segs.toArray(new Segment[0]);
    Segment[] c2array = c2Segs.toArray(new Segment[0]);

    // sanity check.
    if (c1array.length != c2array.length) {
      throw new IllegalArgumentException();
    }

    for (int i = 0; i < c1array.length; i++) {
      Segment s1 = c1array[i], s2 = c2array[i];

      // sanity check.
      if (!s1.start.equals(s2.start) || !s1.end.equals(s2.end)) {
        throw new IllegalArgumentException(
            String.format("%d,%d doesn't match %d,%d", s1.start, s1.end, s2.start, s2.end));
      }

      // There are three conditions here:
      // (1) Neither of the segments is 'shared'
      // (2) The segments don't have the same type
      // (3) At least one of them is a line.
      if (!s1.shared && !s2.shared) {
        if (s1.segmentType.equals(Segment.LINE) || s2.segmentType.equals(Segment.LINE)) {

          boolean differential = false;

          // Remember: for any segment 's', s.start and s.end are *indices*
          // into the 'locations' array of the corresponding data chunk.
          DifferentialKey key =
              new DifferentialKey(
                  new RegionKey(chrom, locations[s1.start], locations[s1.end], strand), s1, s2);

          if (s1.segmentType.equals(Segment.FLAT)) {
            differential = key.s2Expr() > key.s1Expr();
          } else if (s2.segmentType.equals(Segment.FLAT)) {
            differential = key.s1Expr() > key.s2Expr();
          } else {
            differential = Math.abs(key.diffExpr()) >= 0.5;
          }

          if (differential) {
            // If all conditions have been satisfied, then we build
            // the region identifier and save it in the list to be returned.
            keys.add(key);
          }
        }
      }
    }

    return keys;
  }