@ -142,43 +142,42 @@ public class PackWriter implements AutoCloseable {
private static final Map < WeakReference < PackWriter > , Boolean > instances =
private static final Map < WeakReference < PackWriter > , Boolean > instances =
new ConcurrentHashMap < > ( ) ;
new ConcurrentHashMap < > ( ) ;
private static final Iterable < PackWriter > instancesIterable = new Iterable < PackWriter > ( ) {
private static final Iterable < PackWriter > instancesIterable = ( ) - > new Iterator < PackWriter > ( ) {
private final Iterator < WeakReference < PackWriter > > it = instances
. keySet ( ) . iterator ( ) ;
private PackWriter next ;
@Override
@Override
public Iterator < PackWriter > iterator ( ) {
public boolean hasNext ( ) {
return new Iterator < PackWriter > ( ) {
if ( next ! = null ) {
private final Iterator < WeakReference < PackWriter > > it =
return true ;
instances . keySet ( ) . iterator ( ) ;
}
private PackWriter next ;
while ( it . hasNext ( ) ) {
WeakReference < PackWriter > ref = it . next ( ) ;
@Override
next = ref . get ( ) ;
public boolean hasNext ( ) {
if ( next ! = null ) {
if ( next ! = null )
return true ;
return true ;
while ( it . hasNext ( ) ) {
WeakReference < PackWriter > ref = it . next ( ) ;
next = ref . get ( ) ;
if ( next ! = null )
return true ;
it . remove ( ) ;
}
return false ;
}
}
it . remove ( ) ;
}
return false ;
}
@Override
@Override
public PackWriter next ( ) {
public PackWriter next ( ) {
if ( hasNext ( ) ) {
if ( hasNext ( ) ) {
PackWriter result = next ;
PackWriter result = next ;
next = null ;
next = null ;
return result ;
return result ;
}
}
throw new NoSuchElementException ( ) ;
throw new NoSuchElementException ( ) ;
}
}
@Override
@Override
public void remove ( ) {
public void remove ( ) {
throw new UnsupportedOperationException ( ) ;
throw new UnsupportedOperationException ( ) ;
}
} ;
}
}
} ;
} ;