title: Splitting vectors into subvectors - Java
body: <p>I have a function that processes vectors. Size of input vector can be anything up to few millions. Problem is that function can only process vectors that are no bigger than 100k elements without problems.</p>
  
  <p>I would like to call function in smaller parts if vector has too many elements</p>
  
  <pre><code>Vector&lt;Stuff&gt; process(Vector&lt;Stuff&gt; input) {
      Vector&lt;Stuff&gt; output;
      while(1) {
          if(input.size() &gt; 50000) {
              output.addAll(doStuff(input.pop_front_50k_first_ones_as_subvector());
          }
          else {
              output.addAll(doStuff(input));
              break;
          }
      }
      return output;
  }
  </code></pre>
  
  <p>How should I do this?</p>