Package ghidra.util
Class StreamUtils
java.lang.Object
ghidra.util.StreamUtils
Some utilities for streams
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> Iterable<T> Adapt a stream into an iterablestatic <T> Stream<T> Wrap the given stream into a synchronized stream on the given lockstatic <T> Stream<T> merge(Collection<? extends Stream<? extends T>> streams, Comparator<? super T> comparator) Union two sorted streams into a single sorted streamstatic <T> Stream<T> Wrap the given stream into a synchronized stream on the given object's intrinsic lock
-
Method Details
-
merge
public static <T> Stream<T> merge(Collection<? extends Stream<? extends T>> streams, Comparator<? super T> comparator) Union two sorted streams into a single sorted stream- Type Parameters:
T- the type of elements- Parameters:
streams- the streams to be mergedcomparator- the comparator that orders each stream and that will order the resulting stream- Returns:
- the sorted stream
-
iter
Adapt a stream into an iterable- Type Parameters:
T- the type of elements- Parameters:
stream- the stream- Returns:
- an iterable over the same elements in the stream in the same order
-
sync
Wrap the given stream into a synchronized stream on the given object's intrinsic lockNOTE: This makes no guarantees regarding the consistency or visit order if the underlying resource is modified between elements being visited. It merely prevents the stream client from accessing the underlying resource concurrently. For such guarantees, the client may need to acquire the lock for its whole use of the stream.
- Type Parameters:
T- the type of elements- Parameters:
lock- the object on which to synchronizestream- the (un)synchronized stream- Returns:
- the synchronized stream
-
lock
Wrap the given stream into a synchronized stream on the given lockNOTE: This makes no guarantees regarding the consistency or visit order if the underlying resource is modified between elements being visited. It merely prevents the stream client from accessing the underlying resource concurrently. For such guarantees, the client may need to acquire the lock for its whole use of the stream.
- Type Parameters:
T- the type of elements- Parameters:
lock- the lockstream- the (un)synchronized stream- Returns:
- the synchronized stream
-