当前位置: 首页>>代码示例>>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;未经允许,请勿转载。