title: Number items from list according to Set item
body: <p>I'm using a class to performs my questions...</p>
  
  <pre><code>public class Competitor {
    private final int type;
    private final String name;
    private final int power;
  
    public Competitor(int type, String name, int power) {
      this.type = type;
      this.name = name;
      this.power = power;
    }
  
    public int getType() {
      return type;
    }
  
    public String getName() {
      return name;
    }
  
    public int getPower() {
      return power;
    }
  
    @Override
    public String toString() {
      return "Competitor{" + "type=" + type + ", name=" + name + ", power=" + power + "} ";
    }
  }
  </code></pre>
  
  <p>Now I created a nestedList of my before class</p>
  
  <pre><code>List&lt;List&lt;Competitor&gt;&gt; nestedCompetitor = new ArrayList&lt;&gt;(); 
  
  List&lt;Competitor&gt; listCompetitors0 = new ArrayList&lt;&gt;();
  
  listCompetitors0.add(new Competitor(1, "Cat 00", 93));
  listCompetitors0.add(new Competitor(1, "Cat 10", 11));
  listCompetitors0.add(new Competitor(1, "Cat 23", 20));
  
  List&lt;Competitor&gt; listCompetitors1 = new ArrayList&lt;&gt;();
  listCompetitors1.add(new Competitor(2, "Dog 61", 54));
  listCompetitors1.add(new Competitor(2, "Dog 18", 40));
  listCompetitors1.add(new Competitor(2, "Dog 45", 71));
  listCompetitors1.add(new Competitor(2, "Dog 30", 68));
  
  List&lt;Competitor&gt; listCompetitors2 = new ArrayList&lt;&gt;();
  listCompetitors2.add(new Competitor(3, "Pig 90", 90));
  listCompetitors2.add(new Competitor(3, "Pig 78", 20));
  
  List&lt;Competitor&gt; listCompetitors3 = new ArrayList&lt;&gt;();
  listCompetitors3.add(new Competitor(4, "Cow 99", 90));
  
  nestedCompetitor.add(listCompetitors0);
  nestedCompetitor.add(listCompetitors1);
  nestedCompetitor.add(listCompetitors2);
  nestedCompetitor.add(listCompetitors3);
  </code></pre>
  
  <p>I got ordered <code>Set</code> classified by <code>Power</code></p>
  
  <pre><code>Set&lt;Integer&gt; setLastPower = nestedCompetitor.stream()
          .map(l -&gt; l.get(l.size() - 1).getPower())
          .sorted(Comparator.reverseOrder())
          .collect(Collectors.toCollection(LinkedHashSet::new));
  
  List&lt;Integer&gt; account = new ArrayList&lt;&gt;();
  Long iterations = 1L;
  for (Integer powerSet: setLastPower) {
      Integer powerCount =
      (int)nestedCompetitor.stream()
          .map(l -&gt; l.get(l.size() - 1).getPower())
              .filter(powerList -&gt; powerList.equals(powerSet)).count();
      account.add(powerCount);
      System.out.println("powerSet:" + powerSet + " -&gt; " + "number items:" + powerCount);
      iterations *=(long)powerCount;
  }
  System.out.println("iterations:" + iterations);
  </code></pre>
  
  <p><code>powerCount</code> is <em>number items</em>.</p>
  
  <p>Now, <strong>I want to obtain the number items from <code>List</code> according to each <code>Set</code> item</strong>.</p>
  
  <p>I know I can to use a create a filter taken from item Set, applied to List and make count.</p>
  
  <p><strong>But, is there optimized options?</strong></p>