archiva-modules/archiva-base/archiva-storage-api/src/main/java/org/apache/archiva/repository/storage/util/AssetSpliterator.java
/**
     * Splits by moving every second asset to the new spliterator. This allows to start both at similar
     * tree depths. But it is not guaranteed that they start on the same depth.
     * The split happens only, if the number of elements in the worklist is greater than 2.
     *
     * @return the new spliterator if the work list size is greater than 2
     */
Splits by moving every second asset to the new spliterator. This allows to start both at similar
tree depths. But it is not guaranteed that they start on the same depth.
The split happens only, if the number of elements in the worklist is greater than 2.

@return the new spliterator if the work list size is greater than 2
Splits by moving every second asset to the new spliterator . This allows to start both at similar tree depths . But it is not guaranteed that they start on the same depth . The split happens only if the number of elements in the worklist is greater than 2 . @return the new spliterator if the work list size is greater than 2
@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) {
            }
             Swap the worklist
            this.workList = newWorkList;
            return newSpliterator;
        } else {
            return null;
        }
    }
@ 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 ; } }
Splits by moving every second asset to the new spliterator.
Splits by moving every second asset to the new spliterator .
// We use the elements alternately for the current and the new spliterator // For the parallel scenario we cannot guarantee that children are visited // before their parents //noinspection InfiniteLoopStatement // // Swap the worklist