当前位置: 首页>>代码示例>>Java>>正文


Java Iterate类代码示例

本文整理汇总了Java中org.eclipse.collections.impl.utility.Iterate的典型用法代码示例。如果您正苦于以下问题:Java Iterate类的具体用法?Java Iterate怎么用?Java Iterate使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Iterate类属于org.eclipse.collections.impl.utility包,在下文中一共展示了Iterate类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: assist

import org.eclipse.collections.impl.utility.Iterate; //导入依赖的package包/类
public List<Object> assist(String levelName, InvestigationLevel nextLevel, int drilldownLimit)
{
    Twin<VerifiableTable> queryResults = execute(nextLevel);
    VerifiableTable actualResults = new KeyedVerifiableTableAdapter(queryResults.getOne(), queryResults.getOne().getColumnCount() - 1);
    VerifiableTable expectedResults = new KeyedVerifiableTableAdapter(queryResults.getTwo(), queryResults.getTwo().getColumnCount() - 1);

    List<String> actualColumns = getColumns(actualResults);
    List<String> expectedColumns = getColumns(expectedResults);
    if (!Iterate.getLast(actualColumns).equals(Iterate.getLast(expectedColumns)))
    {
        throw new IllegalArgumentException(String.format("Key columns must match at each investigation level [actual: %s, expected: %s]", Iterate.getLast(actualColumns), Iterate.getLast(expectedColumns)));
    }
    Set<String> commonColumns = UnifiedSet.newSet(actualColumns);
    commonColumns.retainAll(expectedColumns);
    if (Math.min(actualColumns.size(), expectedColumns.size()) > 1 && commonColumns.size() < 2)
    {
        throw new IllegalArgumentException(String.format("There must be at least 2 matching columns at each investigation level [actual: %s, expected: %s]", Iterate.getLast(actualColumns), Iterate.getLast(expectedColumns)));
    }

    String levelDescription = nextLevel.getLevelDescription();
    ResultTable results = this.findBreaks(levelDescription, actualResults, expectedResults);
    HtmlFormatter htmlFormatter = new HtmlFormatter(outputFile, new HtmlOptions(false, HtmlFormatter.DEFAULT_ROW_LIMIT, false, true, false, Collections.<String>emptySet()));
    htmlFormatter.appendResults(levelName, Maps.fixedSize.of(levelDescription, results), Metadata.newEmpty());
    return getRowKeys(results, drilldownLimit);
}
 
开发者ID:goldmansachs,项目名称:tablasco,代码行数:26,代码来源:Watson.java

示例2: getRowKeys

import org.eclipse.collections.impl.utility.Iterate; //导入依赖的package包/类
private List<Object> getRowKeys(ResultTable results, int drilldownLimit)
{
    List<Object> rowKeys = FastList.newList();
    List<List<ResultCell>> table = results.getVerifiedRows();
    int rowIndex = 1;
    while (rowIndex < table.size() && rowKeys.size() < drilldownLimit)
    {
        List<ResultCell> values = table.get(rowIndex);
        int passedCount = Iterate.count(values, ResultCell.IS_PASSED_CELL);
        int failedCount = Iterate.count(values, ResultCell.IS_FAILED_CELL);
        if (passedCount == 0 || failedCount > 0)
        {
            ResultCell cell = Iterate.getLast(values);
            rowKeys.add(cell.getActual() == null ? cell.getExpected() : cell.getActual());
        }
        rowIndex++;
    }
    return rowKeys;
}
 
开发者ID:goldmansachs,项目名称:tablasco,代码行数:20,代码来源:Watson.java

示例3: handle

import org.eclipse.collections.impl.utility.Iterate; //导入依赖的package包/类
public void handle(Investigation investigation, File outputFile)
{
    Watson watson = new Watson(outputFile);
    InvestigationLevel currentLevel = investigation.getFirstLevel();
    List<Object> drilldownKeys = watson.assist("Initial Results", currentLevel, investigation.getRowKeyLimit());
    if (Iterate.isEmpty(drilldownKeys))
    {
        LOGGER.info("No breaks found :)");
        return;
    }

    LOGGER.info("Got " + drilldownKeys.size() + " broken drilldown keys - " + outputFile);
    int level = 1;
    while (!drilldownKeys.isEmpty() && (currentLevel = investigation.getNextLevel(drilldownKeys)) != null)
    {
        drilldownKeys = watson.assist("Investigation Level " + level + " (Top " + investigation.getRowKeyLimit() + ')', currentLevel, investigation.getRowKeyLimit());
        LOGGER.info("Got " + drilldownKeys.size() + " broken drilldown keys - " + outputFile);
        level++;
    }

    String message = "Some tests failed. Check test results file " + outputFile.getAbsolutePath() + " for more details.";
    throw new AssertionError(message);
}
 
开发者ID:goldmansachs,项目名称:tablasco,代码行数:24,代码来源:Sherlock.java

示例4: shuffleAndDealHands

import org.eclipse.collections.impl.utility.Iterate; //导入依赖的package包/类
@Test
public void shuffleAndDealHands()
{
    List<Set<Card>> jdkHands = this.jdkDeck.shuffleAndDeal(new Random(1), 5, 5);
    Assert.assertEquals(5, jdkHands.size());
    Assert.assertTrue(Iterate.allSatisfy(jdkHands, each -> each.size() == 5));
}
 
开发者ID:BNYMellon,项目名称:CodeKatas,代码行数:8,代码来源:JDKImperativeDeckOfCardsAsSortedSetTest.java

示例5: dealHands

import org.eclipse.collections.impl.utility.Iterate; //导入依赖的package包/类
@Test
public void dealHands()
{
    Deque<Card> jdkShuffled = this.jdkDeck.shuffle(new Random(1));
    List<Set<Card>> jdkHands = this.jdkDeck.dealHands(jdkShuffled, 5, 5);
    Assert.assertEquals(5, jdkHands.size());
    Assert.assertTrue(Iterate.allSatisfy(jdkHands, each -> each.size() == 5));
    Assert.assertEquals(27, jdkShuffled.size());
}
 
开发者ID:BNYMellon,项目名称:CodeKatas,代码行数:10,代码来源:JDKImperativeDeckOfCardsAsSortedSetTest.java

示例6: findBreaks

import org.eclipse.collections.impl.utility.Iterate; //导入依赖的package包/类
private ResultTable findBreaks(String tableName, VerifiableTable actual, VerifiableTable expected)
{
    Map<String, VerifiableTable> actualVerifiableTableResults = Maps.fixedSize.of(tableName, actual);
    Map<String, VerifiableTable> expectedVerifiableTableResults = Maps.fixedSize.of(tableName, expected);
    Map<String, ResultTable> verifyTables = this.multiTableVerifier.verifyTables(expectedVerifiableTableResults, actualVerifiableTableResults);
    return Iterate.getOnly(verifyTables.values());
}
 
开发者ID:goldmansachs,项目名称:tablasco,代码行数:8,代码来源:Watson.java

示例7: match

import org.eclipse.collections.impl.utility.Iterate; //导入依赖的package包/类
@Override
public void match(MutableList<UnmatchedIndexMap> allMissingRows, MutableList<UnmatchedIndexMap> allSurplusRows, MutableList<IndexMap> matchedColumns)
{
    List<IndexMap> keyColumnIndices = this.getKeyColumnIndexMaps(matchedColumns);
    if (keyColumnIndices.isEmpty())
    {
        LOGGER.warn("No key columns found!");
        return;
    }
    MutableMap<RowView, MutableList<UnmatchedIndexMap>> missingByKey = UnifiedMap.newMap(allMissingRows.size());
    for (UnmatchedIndexMap expected : allMissingRows)
    {
        ExpectedRowView expectedRowView = new ExpectedRowView(this.expectedData, keyColumnIndices, this.columnComparators, expected.getExpectedIndex());
        missingByKey.getIfAbsentPut(expectedRowView, NEW_LIST).add(expected);
    }
    MutableMap<RowView, MutableList<UnmatchedIndexMap>> surplusByKey = UnifiedMap.newMap(allSurplusRows.size());
    for (UnmatchedIndexMap actual : allSurplusRows)
    {
        ActualRowView actualRowView = new ActualRowView(this.actualData, keyColumnIndices, this.columnComparators, actual.getActualIndex());
        surplusByKey.getIfAbsentPut(actualRowView, NEW_LIST).add(actual);
    }
    for (RowView rowView : missingByKey.keysView())
    {
        MutableList<UnmatchedIndexMap> missing = missingByKey.get(rowView);
        MutableList<UnmatchedIndexMap> surplus = surplusByKey.get(rowView);
        if (Iterate.notEmpty(missing) && Iterate.notEmpty(surplus))
        {
            this.keyGroupPartialMatcher.match(missing, surplus, matchedColumns);
        }
    }
}
 
开发者ID:goldmansachs,项目名称:tablasco,代码行数:32,代码来源:KeyColumnPartialMatcher.java

示例8: appendTo

import org.eclipse.collections.impl.utility.Iterate; //导入依赖的package包/类
@Override
public void appendTo(final String testName, final String tableName, final Element table, final HtmlOptions htmlOptions)
{
    HtmlFormatter.appendHeaderRow(table, this, htmlOptions);
    Iterate.forEachWithIndex(this.getResultsByKey().keySet(), new ObjectIntProcedure<String>()
    {
        @Override
        public void value(String key, int index)
        {
            SummaryResult summaryResult = getResultsByKey().get(key);
            HtmlFormatter.appendSpanningRow(table, SummaryResultTable.this, "blank_row", null, null);

            for (List<ResultCell> resultCells : summaryResult.getFirstFewRows())
            {
                HtmlFormatter.appendDataRow(table, SummaryResultTable.this, null, null, resultCells, htmlOptions);
            }
            int remainingRows = summaryResult.getRemainingRowCount();
            if (remainingRows > 0)
            {
                String summaryRowId = HtmlFormatter.toHtmlId(testName, tableName) + ".summaryRow" + index;
                String summaryText;
                if ("0".equals(key))
                {
                    summaryText = ResultCell.adaptOnCount(remainingRows, " more matched row");
                }
                else
                {
                    summaryText = ResultCell.adaptOnCount(remainingRows, " more break") + " like this";
                }
                HtmlFormatter.appendSpanningRow(table, SummaryResultTable.this, "summary", NumberFormat.getInstance().format(remainingRows) + summaryText + "...", "toggleVisibility('" + summaryRowId + "')");
                HtmlFormatter.appendDataRow(table, SummaryResultTable.this, summaryRowId, "display:none", summaryResult.getSummaryCardinalityRow(), htmlOptions);
            }
        }
    });
}
 
开发者ID:goldmansachs,项目名称:tablasco,代码行数:36,代码来源:SummaryResultTable.java

示例9: parse

import org.eclipse.collections.impl.utility.Iterate; //导入依赖的package包/类
@Override
public ParserState parse(StreamTokenizer st) throws IOException, ParseException
{
    if (this.sectionName == null)
    {
        throw new ParseException("no section name found before line " + st.lineno(), st.lineno());
    }

    // parse the data
    int currentAttribute = 0;
    int token = st.ttype;

    boolean wantData = true;
    List<Object> rowValue = FastList.newList();
    while (token != StreamTokenizer.TT_EOL && token != StreamTokenizer.TT_EOF)
    {
        if (wantData)
        {
            this.getParser().getExpectedTable().parseData(st, currentAttribute, rowValue);
            currentAttribute++;
        }
        else
        {
            if (token != ',')
            {
                throw new ParseException("Expected a comma on line " + st.lineno(), st.lineno());
            }
        }
        wantData = !wantData;
        token = st.nextToken();
    }
    if (Iterate.notEmpty(rowValue))
    {
        this.getParser().getExpectedTable().addRowToList(rowValue);
    }
    return this.getParser().getBeginningOfLineState();
}
 
开发者ID:goldmansachs,项目名称:tablasco,代码行数:38,代码来源:DataReaderState.java

示例10: getValue

import org.eclipse.collections.impl.utility.Iterate; //导入依赖的package包/类
/**
 * Refactor to use {@link org.eclipse.collections.api.RichIterable#sumOfDouble(DoubleFunction)}.
 */
public double getValue()
{
    Collection<Double> itemValues = Iterate.collect(this.lineItems, LineItem::getValue);

    return CollectionAdapter.adapt(itemValues).injectInto(0.0, AddFunction.DOUBLE_TO_DOUBLE);
}
 
开发者ID:eclipse,项目名称:eclipse-collections-kata,代码行数:10,代码来源:Order.java

示例11: filterOrders

import org.eclipse.collections.impl.utility.Iterate; //导入依赖的package包/类
/**
 * Same exercise but don't use static utility - refactor the type of orders and {@link Customer#getOrders()}
 * instead.
 * Get the actual orders (not their double values) where those orders have a value greater than 2.0.
 */
@Test
public void filterOrders()
{
    List<Order> orders = this.company.getMostRecentCustomer().getOrders();
    MutableList<Order> filtered = null;

    Assert.assertEquals(Lists.mutable.with(Iterate.getFirst(this.company.getMostRecentCustomer().getOrders())), filtered);
    Verify.assertInstanceOf(MutableList.class, this.company.getMostRecentCustomer().getOrders());
    this.company.getMostRecentCustomer().getOrders().add(null);
    Verify.assertContains("Don't return a copy from Customer.getOrders(). The field should be a MutableList.", null, this.company.getMostRecentCustomer().getOrders());
}
 
开发者ID:eclipse,项目名称:eclipse-collections-kata,代码行数:17,代码来源:Exercise5Test.java

示例12: filterOrders

import org.eclipse.collections.impl.utility.Iterate; //导入依赖的package包/类
/**
 * Get the actual orders (not their double values) where those orders have a value greater than 2.0.
 */
@Test
public void filterOrders()
{
    List<Order> orders = this.company.getMostRecentCustomer().getOrders();
    MutableList<Order> filtered = null;
    Assert.assertEquals(Lists.mutable.with(Iterate.getFirst(this.company.getMostRecentCustomer().getOrders())), filtered);
}
 
开发者ID:eclipse,项目名称:eclipse-collections-kata,代码行数:11,代码来源:Exercise4Test.java

示例13: diamonds

import org.eclipse.collections.impl.utility.Iterate; //导入依赖的package包/类
@Test
public void diamonds()
{
    Assert.assertEquals(13, this.jdkDeck.diamonds().size());
    Assert.assertTrue(Iterate.allSatisfy(this.jdkDeck.diamonds(), Card::isDiamonds));
}
 
开发者ID:BNYMellon,项目名称:CodeKatas,代码行数:7,代码来源:JDKImperativeDeckOfCardsAsSortedSetTest.java

示例14: hearts

import org.eclipse.collections.impl.utility.Iterate; //导入依赖的package包/类
@Test
public void hearts()
{
    Assert.assertEquals(13, this.jdkDeck.hearts().size());
    Assert.assertTrue(Iterate.allSatisfy(this.jdkDeck.hearts(), Card::isHearts));
}
 
开发者ID:BNYMellon,项目名称:CodeKatas,代码行数:7,代码来源:JDKImperativeDeckOfCardsAsSortedSetTest.java

示例15: spades

import org.eclipse.collections.impl.utility.Iterate; //导入依赖的package包/类
@Test
public void spades()
{
    Assert.assertEquals(13, this.jdkDeck.spades().size());
    Assert.assertTrue(Iterate.allSatisfy(this.jdkDeck.spades(), Card::isSpades));
}
 
开发者ID:BNYMellon,项目名称:CodeKatas,代码行数:7,代码来源:JDKImperativeDeckOfCardsAsSortedSetTest.java


注:本文中的org.eclipse.collections.impl.utility.Iterate类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。