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


Java List.clear方法代碼示例

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


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

示例1: call

import java.util.List; //導入方法依賴的package包/類
/**
 * Method perform a HBase batch operation.
 */
public void call() throws Exception {
    List<Row> rowList = new ArrayList<>(batchSize);
    final Object[] results = new Object[batchSize];
    for ( T object : objectCollection ) {
        final Row row = objectMapper.apply(object);
        rowList.add(row);
        //reach batch limit size, flush index data to HBase
        if ( rowList.size() >= batchSize ) {
            table.batch(rowList, results);
            throwIfBatchFailed(results);
            rowList.clear();
        }
    }
    //save remaining index data
    if ( !rowList.isEmpty() ) {
        final Object[] errors = new Object[rowList.size()];
        table.batch(rowList, errors);
        throwIfBatchFailed(errors);
    }
}
 
開發者ID:i-knowledge,項目名稱:hbase-client,代碼行數:24,代碼來源:Batch.java

示例2: totalDefinitionsCountsPerRoute

import java.util.List; //導入方法依賴的package包/類
/**
 * Used to write definitions counts per route.
 *
 * @param writer
 * @throws IOException
 */
private void totalDefinitionsCountsPerRoute(final FileWriter writer) throws IOException {
	CSVUtils.writeLine(writer, Arrays.asList("")); // empty line
	writeHeader(writer, "Definitions per route");
	final int[] overallCounts = this.currentStore.getDefinitionCountsPerRoute();
	final List<String> stringWrite = new ArrayList<String>();
	for (int i = 0; i < overallCounts.length; i++) {
		stringWrite.clear();
		// final index needs to have different name: e.g. 10 or more
		if (i == overallCounts.length - 1) {
			stringWrite.add("Definitions per Route: " + i + " or more");
		} else {
			stringWrite.add("Definitions per Route: " + i);
		}

		stringWrite.add(overallCounts[i] + "");
		for (final RLCDataStore store : this.dataStoreMap.values()) {
			stringWrite.add(String.valueOf(store.getDefinitionCountsPerRoute()[i]));
		}
		CSVUtils.writeLine(writer, stringWrite);
	}
}
 
開發者ID:orionhealth,項目名稱:rlc-analyser,代碼行數:28,代碼來源:RLCDataExporter.java

示例3: Mat_to_vector_KeyPoint

import java.util.List; //導入方法依賴的package包/類
public static void Mat_to_vector_KeyPoint(Mat m, List<KeyPoint> kps) {
    if (kps == null)
        throw new java.lang.IllegalArgumentException("Output List can't be null");
    int count = m.rows();
    if (CvType.CV_64FC(7) != m.type() || m.cols() != 1)
        throw new java.lang.IllegalArgumentException(
                "CvType.CV_64FC(7) != m.type() ||  m.cols()!=1\n" + m);

    kps.clear();
    double[] buff = new double[7 * count];
    m.get(0, 0, buff);
    for (int i = 0; i < count; i++) {
        kps.add(new KeyPoint((float) buff[7 * i], (float) buff[7 * i + 1], (float) buff[7 * i + 2], (float) buff[7 * i + 3],
                (float) buff[7 * i + 4], (int) buff[7 * i + 5], (int) buff[7 * i + 6]));
    }
}
 
開發者ID:johnhany,項目名稱:MOAAP,代碼行數:17,代碼來源:Converters.java

示例4: Mat_to_vector_vector_KeyPoint

import java.util.List; //導入方法依賴的package包/類
public static void Mat_to_vector_vector_KeyPoint(Mat m, List<MatOfKeyPoint> kps) {
    if (kps == null)
        throw new java.lang.IllegalArgumentException("Output List can't be null");

    if (m == null)
        throw new java.lang.IllegalArgumentException("Input Mat can't be null");

    List<Mat> mats = new ArrayList<Mat>(m.rows());
    Mat_to_vector_Mat(m, mats);
    for (Mat mi : mats) {
        MatOfKeyPoint vkp = new MatOfKeyPoint(mi);
        kps.add(vkp);
        mi.release();
    }
    mats.clear();
}
 
開發者ID:johnhany,項目名稱:MOAAP,代碼行數:17,代碼來源:Converters.java

示例5: Mat_to_vector_vector_Point3f

import java.util.List; //導入方法依賴的package包/類
public static void Mat_to_vector_vector_Point3f(Mat m, List<MatOfPoint3f> pts) {
    if (pts == null)
        throw new java.lang.IllegalArgumentException("Output List can't be null");

    if (m == null)
        throw new java.lang.IllegalArgumentException("Input Mat can't be null");

    List<Mat> mats = new ArrayList<Mat>(m.rows());
    Mat_to_vector_Mat(m, mats);
    for (Mat mi : mats) {
        MatOfPoint3f pt = new MatOfPoint3f(mi);
        pts.add(pt);
        mi.release();
    }
    mats.clear();
}
 
開發者ID:spacejake,項目名稱:android-age-estimator,代碼行數:17,代碼來源:Converters.java

示例6: Mat_to_vector_vector_DMatch

import java.util.List; //導入方法依賴的package包/類
public static void Mat_to_vector_vector_DMatch(Mat m, List<MatOfDMatch> lvdm) {
    if (lvdm == null)
        throw new java.lang.IllegalArgumentException("Output List can't be null");

    if (m == null)
        throw new java.lang.IllegalArgumentException("Input Mat can't be null");

    List<Mat> mats = new ArrayList<Mat>(m.rows());
    Mat_to_vector_Mat(m, mats);
    lvdm.clear();
    for (Mat mi : mats) {
        MatOfDMatch vdm = new MatOfDMatch(mi);
        lvdm.add(vdm);
        mi.release();
    }
    mats.clear();
}
 
開發者ID:KAlO2,項目名稱:OpenCV,代碼行數:18,代碼來源:Converters.java

示例7: testRepack

import java.util.List; //導入方法依賴的package包/類
static void testRepack() throws IOException {

        // make a copy of the test specimen to local directory
        File testFile = new File("src_tools.jar");
        Utils.copyFile(Utils.getGoldenJar(), testFile);
        List<String> cmdsList = new ArrayList<>();

        // case 1:
        cmdsList.add(Utils.getPack200Cmd());
        cmdsList.add("--repack");
        cmdsList.add(testFile.getName());
        Utils.runExec(cmdsList);

        // case 2:
        File dstFile = new File("dst_tools.jar");
        cmdsList.clear();
        cmdsList.add(Utils.getPack200Cmd());
        cmdsList.add("--repack");
        cmdsList.add(dstFile.getName());
        cmdsList.add(testFile.getName());
        Utils.runExec(cmdsList);

        // tidy up
        testFile.delete();
        dstFile.delete();
    }
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:27,代碼來源:RepackTest.java

示例8: tableView_acceptDrop_row_dropOperation

import java.util.List; //導入方法依賴的package包/類
/**
 * Invoked by tableView when the mouse button is released over a table view that previously decided to allow a drop.
 *
 * @param draggingInfo contains details on this dragging operation.
 * @param row          The proposed location is row and action is operation.
 */
@Override
public boolean tableView_acceptDrop_row_dropOperation(final NSTableView view, final NSDraggingInfo draggingInfo,
                                                      final NSInteger row, final NSUInteger operation) {
    if(draggingInfo.draggingPasteboard().availableTypeFromArray(NSArray.arrayWithObject(NSPasteboard.StringPboardType)) != null) {
        String droppedText = draggingInfo.draggingPasteboard().stringForType(NSPasteboard.StringPboardType);// get the data from paste board
        if(StringUtils.isNotBlank(droppedText)) {
            log.info("NSPasteboard.StringPboardType:" + droppedText);
            final DownloadController c = new DownloadController(droppedText);
            c.beginSheet(TransferControllerFactory.get());
            return true;
        }
        return false;
    }
    final List<PathPasteboard> pasteboards = PathPasteboardFactory.allPasteboards();
    if(pasteboards.isEmpty()) {
        return false;
    }
    for(PathPasteboard pasteboard : pasteboards) {
        if(pasteboard.isEmpty()) {
            continue;
        }
        final Host host = pasteboard.getBookmark();
        final List<TransferItem> downloads = new ArrayList<TransferItem>();
        for(Path download : pasteboard) {
            downloads.add(new TransferItem(
                    download, LocalFactory.get(new DownloadDirectoryFinder().find(host), download.getName())));
        }
        collection.add(row.intValue(), new DownloadTransfer(host, downloads));
        view.reloadData();
        view.selectRowIndexes(NSIndexSet.indexSetWithIndex(row), false);
        view.scrollRowToVisible(row);
    }
    pasteboards.clear();
    return true;
}
 
開發者ID:iterate-ch,項目名稱:cyberduck,代碼行數:42,代碼來源:TransferTableDataSource.java

示例9: Mat_to_vector_Rect2d

import java.util.List; //導入方法依賴的package包/類
public static void Mat_to_vector_Rect2d(Mat m, List<Rect2d> rs) {
    if (rs == null)
        throw new java.lang.IllegalArgumentException("rs == null");
    int count = m.rows();
    if (CvType.CV_64FC4 != m.type() || m.cols() != 1)
        throw new java.lang.IllegalArgumentException(
                                                     "CvType.CV_64FC4 != m.type() ||  m.rows()!=1\n" + m);

    rs.clear();
    double[] buff = new double[4 * count];
    m.get(0, 0, buff);
    for (int i = 0; i < count; i++) {
        rs.add(new Rect2d(buff[4 * i], buff[4 * i + 1], buff[4 * i + 2], buff[4 * i + 3]));
    }
}
 
開發者ID:typer9527,項目名稱:FaceDetectDemo,代碼行數:16,代碼來源:Converters.java

示例10: Mat_to_vector_char

import java.util.List; //導入方法依賴的package包/類
public static void Mat_to_vector_char(Mat m, List<Byte> bs) {
    if (bs == null)
        throw new java.lang.IllegalArgumentException("Output List can't be null");
    int count = m.rows();
    if (CvType.CV_8SC1 != m.type() || m.cols() != 1)
        throw new java.lang.IllegalArgumentException(
                "CvType.CV_8SC1 != m.type() ||  m.cols()!=1\n" + m);

    bs.clear();
    byte[] buff = new byte[count];
    m.get(0, 0, buff);
    for (int i = 0; i < count; i++) {
        bs.add(buff[i]);
    }
}
 
開發者ID:beast,項目名稱:react-native-scan-doc,代碼行數:16,代碼來源:Converters.java

示例11: assertMatchAttempts

import java.util.List; //導入方法依賴的package包/類
private void assertMatchAttempts(
        Matcher<?> matcher,
        Object matchedObject,
        List<Class<?>> matchAttempts,
        Class<?>... expectedMatchAttempts
) {
    matcher.match(matchedObject);
    assertEquals(asList(expectedMatchAttempts), matchAttempts);
    matchAttempts.clear();
}
 
開發者ID:matchmaker,項目名稱:matchmaker,代碼行數:11,代碼來源:MatcherTest.java

示例12: putVariationsInIndex

import java.util.List; //導入方法依賴的package包/類
private void putVariationsInIndex(List<VcfIndexEntry> allEntries, String currentKey, VcfFile vcfFile,
                                  List<GeneFile> geneFiles, Map<String, Chromosome> chromosomeMap,
                                  VcfFileReader vcfFileReader, VCFHeader vcfHeader)
    throws GeneReadingException, IOException {
    if (currentKey != null && Utils.chromosomeMapContains(chromosomeMap, currentKey)) {
        List<VcfIndexEntry> processedEntries = postProcessIndexEntries(allEntries, geneFiles,
                                   Utils.getFromChromosomeMap(chromosomeMap, currentKey), vcfHeader, vcfFileReader);
        featureIndexDao.writeLuceneIndexForFile(vcfFile, processedEntries);
        LOGGER.info(MessageHelper.getMessage(MessagesConstants
                                                 .INFO_FEATURE_INDEX_CHROMOSOME_WROTE, currentKey));
        allEntries.clear();
    }
}
 
開發者ID:react-dev26,項目名稱:NGB-master,代碼行數:14,代碼來源:FeatureIndexManager.java

示例13: testInvokerDestoryAndReList

import java.util.List; //導入方法依賴的package包/類
/**
   * 測試在調用重試過程中,directory列表變更,invoke重試時重新進行list選擇 
   */
  @Test
  public void testInvokerDestoryAndReList(){
  	final URL url = URL.valueOf("test://localhost/"+ Demo.class.getName() + "?loadbalance=roundrobin&retries="+retries);
  	RpcException exception = new RpcException(RpcException.TIMEOUT_EXCEPTION);
  	MockInvoker<Demo> invoker1 = new MockInvoker<Demo>(Demo.class, url);
  	invoker1.setException(exception);
  	
  	MockInvoker<Demo> invoker2 = new MockInvoker<Demo>(Demo.class, url);
  	invoker2.setException(exception);
  	
      final List<Invoker<Demo>> invokers = new ArrayList<Invoker<Demo>>();
      invokers.add(invoker1);
      invokers.add(invoker2);
      
      Callable<Object> callable = new Callable<Object>() {
	public Object call() throws Exception {
		//模擬invoker全部被destroy掉
		for (Invoker<Demo> invoker:invokers){
			invoker.destroy();
		}
		invokers.clear();
		MockInvoker<Demo> invoker3  = new MockInvoker<Demo>(Demo.class, url);
		invokers.add(invoker3);
		return null;
	}
};
invoker1.setCallable(callable);
      invoker2.setCallable(callable);
      
      RpcInvocation inv = new RpcInvocation();
      inv.setMethodName("test");
      
      Directory<Demo> dic = new MockDirectory<Demo>(url, invokers);
      
      FailoverClusterInvoker<Demo> clusterinvoker = new FailoverClusterInvoker<Demo>(dic);
      clusterinvoker.invoke(inv);
  }
 
開發者ID:yunhaibin,項目名稱:dubbox-hystrix,代碼行數:41,代碼來源:FailoverClusterInvokerTest.java

示例14: savePaginationForFull

import java.util.List; //導入方法依賴的package包/類
private PaginationMarketApp savePaginationForFull() throws Exception {
    // saveOrUpdate to table MarketApp
    PaginationMarketApp marketPagination = null;
    Session session = sessions.openSession();
    session.setDefaultReadOnly(false);
    Transaction tx = null;
    try {
        Market market = getMarket(session);
        marketPagination = getMarketAppForFull(market);
        if (marketPagination != null && marketPagination.getTotalPages() >= marketPagination.getCurrentPage()) {
            List<MarketApp> marketApps = marketPagination.getData();
            List<MarketApp> offMarketApps = new ArrayList<MarketApp>();
            if (marketApps != null && !marketApps.isEmpty()) {
                Object[] infos = new Object[] { market.getMarketName(), marketPagination.getTotalPages(),
                        marketPagination.getCurrentPage(), marketApps.size() };
                accessMarketDao.getMarketlogger().info(
                        "Begin to import {} on one page. totalPages: {} currentPage : {} , size: {}", infos);
                tx = session.beginTransaction();
                savePaginationMarketApp(session, market, marketApps, offMarketApps);
                market.setFullLastReqCurrentPage(marketPagination.getCurrentPage());
                market.setFullTotalPages(marketPagination.getTotalPages());
                market.setFullLastTime(new Date());
                session.merge(market);
                tx.commit();
                tx = null;
                session.clear();
                session.close();
                deleteMarketAppsTransaction(offMarketApps);
                marketApps.clear();
                offMarketApps.clear();
            }
        }
    } catch (Exception e) {
        if (tx != null) {
            tx.rollback();
        }
        logger.error("Exception", e);
        throw e;
    } finally {
        if (session.isOpen()) {
            session.close();
        }
    }
    return marketPagination;
}
 
開發者ID:zhaoxi1988,項目名稱:sjk,代碼行數:46,代碼來源:ApiImporterMarketServiceImpl.java

示例15: clearAllUsages

import java.util.List; //導入方法依賴的package包/類
/**
 * Clear content usage for all users that have a usage.
 */
private void clearAllUsages()
{
    if (logger.isInfoEnabled()) 
    {
        logger.info("Disabled - clear non-missing user usages ...");
    }
    
    final Map<String, NodeRef> users = new HashMap<String, NodeRef>();
    
    RetryingTransactionCallback<Object> getUsersWithUsage = new RetryingTransactionCallback<Object>()
    {
        public Object execute() throws Throwable
        {
            // get people (users) with calculated usage
            MapHandler userHandler = new MapHandler()
            {
                public void handle(Map<String, Object> result)
                {
                    String username = (String)result.get("username");
                    String uuid = (String)result.get("uuid");
                    
                    if (! username.equalsIgnoreCase(AuthenticationUtil.getSystemUserName()))
                    {
                        users.put(username, new NodeRef(personStoreRef, uuid));
                    }
                }
            };
            usageDAO.getUsersWithUsage(tenantService.getName(personStoreRef), userHandler);
            
            return null;
        }
    };
    
    // execute in READ-ONLY txn
    transactionService.getRetryingTransactionHelper().doInTransaction(getUsersWithUsage, true);
    
    if (logger.isInfoEnabled()) 
    {
        logger.info("Found " + users.size() + " users to clear");
    }
    
    int clearCount = 0;
    int batchCount = 0;
    int totalCount = 0;
    
    List<NodeRef> batchPersonRefs = new ArrayList<NodeRef>(clearBatchSize);
    for (NodeRef personNodeRef : users.values())
    {
        batchPersonRefs.add(personNodeRef);
        batchCount++;
        totalCount++;
        
        if ((batchCount == clearBatchSize) || (totalCount == users.size()))
        {
            int cleared = clearUsages(batchPersonRefs);
            clearCount = clearCount + cleared;
            
            batchPersonRefs.clear();
            batchCount = 0;
        }
    }
    
    if (logger.isInfoEnabled()) 
    {
        logger.info("... cleared non-missing usages for " + clearCount + " users");
    }
}
 
開發者ID:Alfresco,項目名稱:alfresco-repository,代碼行數:71,代碼來源:UserUsageTrackingComponent.java


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