Interface LazyCollection<E>

Type Parameters:
E - the type of elements in this collection
All Superinterfaces:
Collection<E>, Iterable<E>
All Known Subinterfaces:
LazyList<E>, LazySet<E>
All Known Implementing Classes:
LazyArrayList

public interface LazyCollection<E>
extends Collection<E>
A Collection, which uses Lazy references internally, to enable automatic partial loading of the collection's content.
  • Method Details

    • iterateLazyReferences

      <P extends Consumer<Lazy<?>>> P iterateLazyReferences​(P procedure)
      Iterates over all internally used Lazy references.
      Type Parameters:
      P - the procedure type
      Parameters:
      procedure - the lazy reference consumer
      Returns:
      the given procedure
    • consolidate

      boolean consolidate()
      Optimizes the internal structure of this lazy collection. Closes possible gaps and cleans up unused storage space.
      Returns:
      true if the internal structure has changed, false otherwise
    • tryUnload

      void tryUnload​(boolean unloadAll)
      Tries to unload as much as possible elements from the collection. The amount of unloaded data depends on the collection's implementation details. E.g if the collection is configured to keep a minimum of data in memory that minimum will not be unloaded as long as the parameter unloadAll is not specified. If unloadAll is set it will try to to fall below that limit.
      Parameters:
      unloadAll - if true try to unload everything, try to fall below limit if possible.
    • stream

      default Stream<E> stream()
      Returns a sequential Stream with this collection as its source.

      This stream comes with a custom close handler, which clears all Lazy references of this collection, which were not loaded before. So if you want to close all Lazy references which were not loaded before the Stream was created, just call BaseStream.close() afterwards.

      Specified by:
      stream in interface Collection<E>
      Returns:
      a sequential Stream over the elements in this collection
    • parallelStream

      default Stream<E> parallelStream()
      Returns a parallel Stream with this collection as its source.

      This stream comes with a custom close handler, which clears all Lazy references of this collection, which were not loaded before. So if you want to close all Lazy references which were not loaded before the Stream was created, just call BaseStream.close() afterwards.

      Specified by:
      parallelStream in interface Collection<E>
      Returns:
      a parallel Stream over the elements in this collection