Package ste.lloop

Class MapSequence<K,V>

java.lang.Object
ste.lloop.AbstractSequence<MapSequence<K,V>>
ste.lloop.MapSequence<K,V>
Type Parameters:
K - the type of the keys in the map
V - the type of the values in the map

public class MapSequence<K,V> extends AbstractSequence<MapSequence<K,V>>
A sequence that loops over a map.
  • Constructor Details

    • MapSequence

      public MapSequence(Map<K,V> map)
      Creates a new sequence for the given map.
      Parameters:
      map - the map to loop over
  • Method Details

    • loop

      public <R> R loop(MapLoopConsumer<K,V> consumer)
      Executes the given consumer for each element in the loop.

      If the map provided to the constructor was null, this method will do nothing.

      Type Parameters:
      R - the type of the return value
      Parameters:
      consumer - the consumer to execute for each element
      Returns:
      the value passed to Loop.brk(Object), or null if the loop completes without a brk
    • loop

      public <R> R loop(BiConsumer<K,V> consumer)
      Executes the given consumer for each element in the loop.

      If the map provided to the constructor was null, this method will do nothing.

      Type Parameters:
      R - the type of the return value
      Parameters:
      consumer - the consumer to execute for each element
      Returns:
      the value passed to Loop.brk(Object), or null if the loop completes without a brk