當前位置: 首頁>>代碼示例>>Java>>正文


Java List.get方法代碼示例

本文整理匯總了Java中java.util.List.get方法的典型用法代碼示例。如果您正苦於以下問題:Java List.get方法的具體用法?Java List.get怎麽用?Java List.get使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.util.List的用法示例。


在下文中一共展示了List.get方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: clickCountry

import java.util.List; //導入方法依賴的package包/類
private void clickCountry(List<String> countryNames,int i){
    String northName = countryNames.get(i);

    for (int j = 0; j < mOpenCountries.size(); j++) {
        ChooseCountryBean countryBean = mOpenCountries.get(j);
        String name = countryBean.getName();
        String country_id = countryBean.getCountry_id();
        if(northName.equals(name)){
            isContains = true;
            Intent north = new Intent();
            north.putExtra("countryName",northName);
            north.putExtra("countryId",country_id);
            getActivity().setResult(Activity.RESULT_OK,north);
            getActivity().finish();
        }
    }

    if (!isContains){
        Toast.makeText(getContext(),"該國家暫時沒有開放",Toast.LENGTH_SHORT).show();
    }
}
 
開發者ID:funnyzhaov,項目名稱:Tribe,代碼行數:22,代碼來源:ChooseCountryFragment.java

示例2: applyAndUpdate

import java.util.List; //導入方法依賴的package包/類
/**
 * Creates a new FilteredBlock from the given Block, using this filter to select transactions. Matches can cause the
 * filter to be updated with the matched element, this ensures that when a filter is applied to a block, spends of
 * matched transactions are also matched. However it means this filter can be mutated by the operation. The returned
 * filtered block already has the matched transactions associated with it.
 */
public synchronized FilteredBlock applyAndUpdate(Block block) {
    List<Transaction> txns = block.getTransactions();
    List<Sha256Hash> txHashes = new ArrayList<>(txns.size());
    List<Transaction> matched = Lists.newArrayList();
    byte[] bits = new byte[(int) Math.ceil(txns.size() / 8.0)];
    for (int i = 0; i < txns.size(); i++) {
        Transaction tx = txns.get(i);
        txHashes.add(tx.getHash());
        if (applyAndUpdate(tx)) {
            Utils.setBitLE(bits, i);
            matched.add(tx);
        }
    }
    PartialMerkleTree pmt = PartialMerkleTree.buildFromLeaves(block.getParams(), bits, txHashes);
    FilteredBlock filteredBlock = new FilteredBlock(block.getParams(), block.cloneAsHeader(), pmt);
    for (Transaction transaction : matched)
        filteredBlock.provideTransaction(transaction);
    return filteredBlock;
}
 
開發者ID:guodroid,項目名稱:okwallet,代碼行數:26,代碼來源:BloomFilter.java

示例3: queryLatestEventBefore

import java.util.List; //導入方法依賴的package包/類
/**
 * This is used to query a single Event ({@link VaultEntry} before a given point in time.
 * This is useful to determine why certain events might have happened (correlation of events).
 *
 * @param timestamp The point in time to get the preceding event from.
 * @param type The Type of {@link VaultEntry} to query for.
 * @return The event of the {@link VaultEntryType} preceding the specified point in time.
 */
public VaultEntry queryLatestEventBefore(final Date timestamp, final VaultEntryType type) {
    VaultEntry returnValue = null;
    try {

        PreparedQuery<VaultEntry> query
                = vaultDao.queryBuilder().orderBy("timestamp", false)
                .limit(1L)
                .where()
                .eq(VaultEntry.TYPE_FIELD_NAME, type)
                .and()
                .le(VaultEntry.TIMESTAMP_FIELD_NAME, timestamp)
                .prepare();
        List<VaultEntry> tmpList = vaultDao.query(query);
        if (tmpList.size() > 0) {
            returnValue = tmpList.get(0);
        }
    } catch (SQLException exception) {
        LOG.log(Level.SEVERE, "Error while db query", exception);
    }
    return returnValue;
}
 
開發者ID:lucasbuschlinger,項目名稱:BachelorPraktikum,代碼行數:30,代碼來源:VaultDao.java

示例4: dispatchBackPress

import java.util.List; //導入方法依賴的package包/類
/**
 * 處理fragment回退鍵
 * <p>如果fragment實現了OnBackClickListener接口,返回{@code true}: 表示已消費回退鍵事件,反之則沒消費</p>
 * <p>具體示例見FragmentActivity</p>
 *
 * @param fragmentManager fragment管理器
 * @return 是否消費回退事件
 */
public static boolean dispatchBackPress(@NonNull FragmentManager fragmentManager) {
    List<Fragment> fragments = fragmentManager.getFragments();
    if (fragments == null || fragments.isEmpty()) return false;
    for (int i = fragments.size() - 1; i >= 0; --i) {
        Fragment fragment = fragments.get(i);
        if (fragment != null
                && fragment.isResumed()
                && fragment.isVisible()
                && fragment.getUserVisibleHint()
                && fragment instanceof OnBackClickListener
                && ((OnBackClickListener) fragment).onBackClick()) {
            return true;
        }
    }
    return false;
}
 
開發者ID:hoangkien0705,項目名稱:Android-UtilCode,代碼行數:25,代碼來源:FragmentUtils.java

示例5: splitProperties

import java.util.List; //導入方法依賴的package包/類
public static String[][] splitProperties(String str) {
	Pattern p = Pattern.compile("(,|:)\\s*(([A-Z]|-|_)*)\\s*=");
	Matcher matcher = p.matcher(str);
	List<String[]> list = new ArrayList<String[]>();
	int endIndex = 0;
	while (matcher.find()) {
		if (list.size() > 0) {
			list.get(list.size() - 1)[1] = str.substring(endIndex,
					matcher.start()).trim();
		}
		list.add(new String[2]);
		list.get(list.size() - 1)[0] = str.substring(matcher.start() + 1,
				matcher.end() - 1).trim();
		endIndex = matcher.end();
	}
	if (list.size() > 0) {
		list.get(list.size() - 1)[1] = str.substring(endIndex).trim();
	}
	return (String[][]) list.toArray(new String[0][2]);
}
 
開發者ID:alibaba,項目名稱:QLExpress,代碼行數:21,代碼來源:NodeType.java

示例6: testCreateEnrolmentFutureReservationExists

import java.util.List; //導入方法依賴的package包/類
@Test
@RunAsStudent
public void testCreateEnrolmentFutureReservationExists() throws Exception {
    // Setup
    reservation.setMachine(room.getExamMachines().get(0));
    reservation.setStartAt(DateTime.now().plusDays(1));
    reservation.setEndAt(DateTime.now().plusDays(2));
    reservation.save();

    DateTime enrolledOn = DateTime.now();
    enrolment.setEnrolledOn(enrolledOn);
    enrolment.setReservation(reservation);
    enrolment.save();

    // Execute
    Result result = request(Helpers.POST,
            String.format("/app/enroll/%s/exam/%d", exam.getCourse().getCode(), exam.getId()), null);
    assertThat(result.status()).isEqualTo(200);

    // Verify
    List<ExamEnrolment> enrolments = Ebean.find(ExamEnrolment.class).findList();
    assertThat(enrolments).hasSize(1);
    ExamEnrolment e = enrolments.get(0);
    assertThat(e.getEnrolledOn().isAfter(enrolledOn));
    assertThat(e.getReservation()).isNull();
}
 
開發者ID:CSCfi,項目名稱:exam,代碼行數:27,代碼來源:EnrolmentControllerTest.java

示例7: checkSubmittedBean

import java.util.List; //導入方法依賴的package包/類
public void checkSubmittedBean(boolean allowEmpty) throws Exception {

		List<StatusBean> statusSet = consumer.getStatusSet();
		if (allowEmpty && statusSet.isEmpty()) return;

		assertThat(statusSet.get(0), is(instanceOf(DummyOperationBean.class)));
		DummyOperationBean operationBean = (DummyOperationBean) statusSet.get(0);

		assertThat(operationBean.getDataKey(), is(equalTo(DEFAULT_ENTRY_PATH + GROUP_NAME_SOLSTICE_SCAN)));
		assertTrue(operationBean.getFilePath().contains("test_nexus"));
		assertTrue(operationBean.getFilePath().endsWith(NEXUS_FILE_EXTENSION));
		assertTrue(operationBean.getOutputFilePath().contains("processed"));
		assertTrue(operationBean.getOutputFilePath(),
				   operationBean.getOutputFilePath().endsWith("-"+processingName+NEXUS_FILE_EXTENSION));
		assertThat(operationBean.getDatasetPath(), is(equalTo(DEFAULT_ENTRY_PATH + detectorName)));
		assertThat(operationBean.getSlicing(), is(nullValue()));
		assertThat(operationBean.getProcessingPath(), is(equalTo("/tmp/sum.nxs")));
		assertThat(operationBean.isDeleteProcessingFile(), is(false));
		assertThat(operationBean.getAxesNames(), is(nullValue()));
		assertThat(operationBean.getXmx(), is(equalTo("1024m")));
		assertThat(operationBean.getDataDimensions(), is(nullValue()));
		assertThat(operationBean.getScanRank(), is(2));
		assertThat(operationBean.isReadable(), is(true));

		assertThat(System.getProperty("java.io.tmpdir"), startsWith(operationBean.getRunDirectory()));
		assertThat(operationBean.getNumberOfCores(), is(1));
	}
 
開發者ID:eclipse,項目名稱:scanning,代碼行數:28,代碼來源:ScanClusterProcessingChecker.java

示例8: next

import java.util.List; //導入方法依賴的package包/類
@Override
public Object[] next() {
    Object tuple[] = new Object[columnsNum];
    List<String[]> tuples;
    
    if (countryCnt < countrySize) {
        tuples = tr_country_file.getTuplesByIndex(countryCnt);
    }
    else {
        tuples = tr_div_file.getTuplesByIndex(divCnt);
    }
    
    String[] tr_record = tuples.get(tuplesCnt++);
    int col = 0;

    tuple[col++] = tr_record[0]; // tr_id
    tuple[col++] = tr_record[1]; // tr_name
    tuple[col++] = Double.valueOf(tr_record[2]); // tr_rate
    
    if (tuplesCnt == tuples.size()) {
        tuplesCnt = 0;
        if (countryCnt < countrySize) {
            countryCnt++;
        }
        else {
            divCnt++;
        }
    }
    
    return tuple;
}
 
開發者ID:s-store,項目名稱:s-store,代碼行數:32,代碼來源:TaxRateGenerator.java

示例9: presentParams

import java.util.List; //導入方法依賴的package包/類
/**
 * @return a readable String of the parameters and their names
 */
String presentParams() {
  StringBuilder sb = new StringBuilder("(");
  List<TableParamDef> params = params();
  for (int i = 0; i < params.size(); i++) {
    TableParamDef paramDef = params.get(i);
    if (i != 0) {
      sb.append(", ");
    }
    sb.append(paramDef.getName()).append(": ").append(paramDef.getType().getSimpleName());
  }
  sb.append(")");
  return sb.toString();
}
 
開發者ID:dremio,項目名稱:dremio-oss,代碼行數:17,代碼來源:FormatPluginOptionsDescriptor.java

示例10: getByUID

import java.util.List; //導入方法依賴的package包/類
@Override
   public ChatMessage getByUID(Long uid) {
// TODO Auto-generated method stub
List list = doFind(ChatMessageDAO.SQL_QUERY_FIND_MESSAGE_BY_UID, new Object[] { uid });

if ((list != null) && (list.size() > 0)) {
    return (ChatMessage) list.get(0);
} else {
    return null;
}

   }
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:13,代碼來源:ChatMessageDAO.java

示例11: createRainflowCounts

import java.util.List; //導入方法依賴的package包/類
private double[][] createRainflowCounts(List<String> values, Map<String, Integer> indexMap) {
	double[][] counts = new double[indexMap.size()][indexMap.size()];

	int currentIndex = 4;
	while (currentIndex < values.size()) {
		String value1 = values.get(currentIndex - 4);
		String value2 = values.get(currentIndex - 3);
		String value3 = values.get(currentIndex - 2);
		String value4 = values.get(currentIndex - 1);

		boolean betweenIncreasing = value2.compareTo(value1) >= 0 && value2.compareTo(value4) <= 0
				&& value3.compareTo(value1) >= 0 && value3.compareTo(value4) <= 0;
				boolean betweenDecreasing = value2.compareTo(value1) <= 0 && value2.compareTo(value4) >= 0
						&& value3.compareTo(value1) <= 0 && value3.compareTo(value4) >= 0;
						if (betweenIncreasing || betweenDecreasing) {
							int fromIndex = indexMap.get(value2);
							int toIndex = indexMap.get(value3);
							counts[fromIndex][toIndex] = counts[fromIndex][toIndex] + 1;
							values.remove(currentIndex - 2);
							values.remove(currentIndex - 3);
							currentIndex = 4;
						} else { // nothing found
							currentIndex++;
						}
	}

	return counts;
}
 
開發者ID:transwarpio,項目名稱:rapidminer,代碼行數:29,代碼來源:RainflowMatrixOperator.java

示例12: test_getExistingBuildConfigs

import java.util.List; //導入方法依賴的package包/類
/**
 * Makes test that configuration configuations are not null
 */
public void test_getExistingBuildConfigs() throws Exception {
  final List configurations = configManager.getExistingBuildConfigs();
  assertNotNull(configurations);
  assertTrue(!configurations.isEmpty()); // this relays on test data populated by DBUnit
  final BuildConfig config = (BuildConfig) configurations.get(0);
  assertTrue(config.getBuildID() != BuildConfig.UNSAVED_ID);
  assertNotNull(config.getBuildName());
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:12,代碼來源:SSTestConfigurationManager.java

示例13: getDatasetBuilder

import java.util.List; //導入方法依賴的package包/類
/**
 * @return null if datasetPath is not canonical and couldn't find a corresponding table in the source
 */
static DatasetBuilder getDatasetBuilder(
    HiveClient client,
    String user,
    NamespaceKey datasetPath,
    boolean isCanonicalDatasetPath,
    boolean ignoreAuthzErrors,
    HiveConf hiveConf,
    DatasetConfig oldConfig) throws TException {
  final List<String> noSourceSchemaPath =
    datasetPath.getPathComponents().subList(1, datasetPath.getPathComponents().size());

  // extract database and table names from dataset path
  final String dbName;
  final String tableName;
  switch (noSourceSchemaPath.size()) {
  case 1:
    dbName = "default";
    tableName = noSourceSchemaPath.get(0);
    break;
  case 2:
    dbName = noSourceSchemaPath.get(0);
    tableName = noSourceSchemaPath.get(1);
    break;
  default:
    //invalid.
    return null;
  }

  // if the dataset path is not canonized we need to get it from the source
  final Table table;
  final String canonicalTableName;
  final String canonicalDbName;
  if (isCanonicalDatasetPath) {
    canonicalDbName = dbName;
    canonicalTableName = tableName;
    table = null;
  } else {
    // passed datasetPath is not canonical, we need to get it from the source
    table = client.getTable(dbName, tableName, ignoreAuthzErrors);
    if(table == null){
      return null;
    }
    canonicalTableName = table.getTableName();
    canonicalDbName = table.getDbName();
  }

  final List<String> canonicalDatasetPath = Lists.newArrayList(datasetPath.getRoot(), canonicalDbName, canonicalTableName);
  return new DatasetBuilder(client, user, new NamespaceKey(canonicalDatasetPath), ignoreAuthzErrors, hiveConf, canonicalDbName, canonicalTableName, table, oldConfig);
}
 
開發者ID:dremio,項目名稱:dremio-oss,代碼行數:53,代碼來源:DatasetBuilder.java

示例14: applyProjection

import java.util.List; //導入方法依賴的package包/類
void applyProjection(List projAttrib, ExecutionContext context, Collection result,
    Object iterValue, SelectResults intermediateResults, boolean isIntersection)
    throws FunctionDomainException, TypeMismatchException, NameResolutionException,
    QueryInvocationTargetException {
  if (projAttrib == null) {
    iterValue = deserializePdxForLocalDistinctQuery(context, iterValue);
    this.addToResultsWithUnionOrIntersection(result, intermediateResults, isIntersection,
        iterValue);
  } else {
    // TODO : Asif : Optimize this . This condition looks ugly.
    /*
     * if (result instanceof StructBag || result instanceof LinkedStructSet || result instanceof
     * LinkedStructBag) {
     */
    boolean isStruct = result instanceof SelectResults
        && ((SelectResults) result).getCollectionType().getElementType() != null
        && ((SelectResults) result).getCollectionType().getElementType().isStructType();
    if (isStruct) {
      int projCount = projAttrib.size();
      Object[] values = new Object[projCount];
      Iterator projIter = projAttrib.iterator();
      int i = 0;
      while (projIter.hasNext()) {
        Object projDef[] = (Object[]) projIter.next();
        values[i] = deserializePdxForLocalDistinctQuery(context,
            ((CompiledValue) projDef[1]).evaluate(context));
        i++;
      }
      this.addToStructsWithUnionOrIntersection(result, intermediateResults, isIntersection,
          values);
    } else {
      Object[] temp = (Object[]) projAttrib.get(0);
      Object val = deserializePdxForLocalDistinctQuery(context,
          ((CompiledValue) temp[1]).evaluate(context));
      this.addToResultsWithUnionOrIntersection(result, intermediateResults, isIntersection, val);
    }
  }
}
 
開發者ID:ampool,項目名稱:monarch,代碼行數:39,代碼來源:AbstractIndex.java

示例15: testDelete

import java.util.List; //導入方法依賴的package包/類
@Test
public void testDelete() {
    saveBean("kk");

    List<Bean> beanRS = finalDb.findAll(Bean.class);
    Bean       b      = beanRS.get(0);

    finalDb.delete(b);

    Assert.assertEquals(0, finalDb.findAll(Bean.class).size());
}
 
開發者ID:kkmike999,項目名稱:YuiHatano,代碼行數:12,代碼來源:AfinalTest.java


注:本文中的java.util.List.get方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。