@Test void trySplit( ) { StorageAsset root = createTree( ); AssetSpliterator spliterator = new AssetSpliterator( root ); final ConsumeVisitStatus status1 = new ConsumeVisitStatus( ); final ConsumeVisitStatus status2 = new ConsumeVisitStatus( ); Spliterator<StorageAsset> newSpliterator = spliterator.trySplit( ); assertNotNull( newSpliterator ); newSpliterator.forEachRemaining( status1 ); spliterator.forEachRemaining( status2 ); int sum = LEVEL1 * LEVEL2 * LEVEL3 + LEVEL1 * LEVEL2 + LEVEL1 + 1; int expected1 = sum / 2; int expected2 = sum / 2 + 1 ; assertEquals( expected1, status1.size( ) ); assertEquals( expected2, status2.size( ) ); }
@Override public Spliterator<StorageAsset> trySplit( ) { if (workList.size()>splitThreshold) { final LinkedList<StorageAsset> newWorkList = new LinkedList<>( ); final AssetSpliterator newSpliterator = new AssetSpliterator( this.splitThreshold, visitedContainers ); try { while (true) { newWorkList.add( workList.removeFirst( ) ); newSpliterator.add( workList.removeFirst( ) ); } } catch (NoSuchElementException e) { } this.workList = newWorkList; return newSpliterator; } else { return null; } }
AssetSpliterator implements Spliterator<StorageAsset>, Closeable { @Override public Spliterator<StorageAsset> trySplit( ) { if (workList.size()>splitThreshold) { final LinkedList<StorageAsset> newWorkList = new LinkedList<>( ); final AssetSpliterator newSpliterator = new AssetSpliterator( this.splitThreshold, visitedContainers ); try { while (true) { newWorkList.add( workList.removeFirst( ) ); newSpliterator.add( workList.removeFirst( ) ); } } catch (NoSuchElementException e) { } this.workList = newWorkList; return newSpliterator; } else { return null; } } }
AssetSpliterator implements Spliterator<StorageAsset>, Closeable { @Override public Spliterator<StorageAsset> trySplit( ) { if (workList.size()>splitThreshold) { final LinkedList<StorageAsset> newWorkList = new LinkedList<>( ); final AssetSpliterator newSpliterator = new AssetSpliterator( this.splitThreshold, visitedContainers ); try { while (true) { newWorkList.add( workList.removeFirst( ) ); newSpliterator.add( workList.removeFirst( ) ); } } catch (NoSuchElementException e) { } this.workList = newWorkList; return newSpliterator; } else { return null; } } AssetSpliterator( int splitThreshold, StorageAsset... assets);  AssetSpliterator( StorageAsset... assets); protected  AssetSpliterator(); protected  AssetSpliterator( int splitThreshold); protected  AssetSpliterator( int splitThreshold, Set<StorageAsset> visitedContainers); protected  AssetSpliterator( List<StorageAsset> baseList, Set<StorageAsset> visitedContainers); }
AssetSpliterator implements Spliterator<StorageAsset>, Closeable { @Override public Spliterator<StorageAsset> trySplit( ) { if (workList.size()>splitThreshold) { final LinkedList<StorageAsset> newWorkList = new LinkedList<>( ); final AssetSpliterator newSpliterator = new AssetSpliterator( this.splitThreshold, visitedContainers ); try { while (true) { newWorkList.add( workList.removeFirst( ) ); newSpliterator.add( workList.removeFirst( ) ); } } catch (NoSuchElementException e) { } this.workList = newWorkList; return newSpliterator; } else { return null; } } AssetSpliterator( int splitThreshold, StorageAsset... assets);  AssetSpliterator( StorageAsset... assets); protected  AssetSpliterator(); protected  AssetSpliterator( int splitThreshold); protected  AssetSpliterator( int splitThreshold, Set<StorageAsset> visitedContainers); protected  AssetSpliterator( List<StorageAsset> baseList, Set<StorageAsset> visitedContainers); @Override void close( ); @Override boolean tryAdvance( Consumer<? super StorageAsset> action ); @Override void forEachRemaining( Consumer<? super StorageAsset> action ); @Override Spliterator<StorageAsset> trySplit( ); @Override long estimateSize( ); @Override int characteristics( ); }
AssetSpliterator implements Spliterator<StorageAsset>, Closeable { @Override public Spliterator<StorageAsset> trySplit( ) { if (workList.size()>splitThreshold) { final LinkedList<StorageAsset> newWorkList = new LinkedList<>( ); final AssetSpliterator newSpliterator = new AssetSpliterator( this.splitThreshold, visitedContainers ); try { while (true) { newWorkList.add( workList.removeFirst( ) ); newSpliterator.add( workList.removeFirst( ) ); } } catch (NoSuchElementException e) { } this.workList = newWorkList; return newSpliterator; } else { return null; } } AssetSpliterator( int splitThreshold, StorageAsset... assets);  AssetSpliterator( StorageAsset... assets); protected  AssetSpliterator(); protected  AssetSpliterator( int splitThreshold); protected  AssetSpliterator( int splitThreshold, Set<StorageAsset> visitedContainers); protected  AssetSpliterator( List<StorageAsset> baseList, Set<StorageAsset> visitedContainers); @Override void close( ); @Override boolean tryAdvance( Consumer<? super StorageAsset> action ); @Override void forEachRemaining( Consumer<? super StorageAsset> action ); @Override Spliterator<StorageAsset> trySplit( ); @Override long estimateSize( ); @Override int characteristics( ); static final int DEFAULT_SPLIT_THRESHOLD; }