本文整理汇总了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);
}
}
示例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);
}
}
示例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]));
}
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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;
}
示例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]));
}
}
示例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]);
}
}
示例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();
}
示例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();
}
}
示例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);
}
示例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;
}
示例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");
}
}