Interface Lifespan

All Superinterfaces:
Comparable<Lifespan>, Iterable<Long>, Span<Long,Lifespan>
All Known Implementing Classes:
Lifespan.Empty, Lifespan.Impl

public sealed interface Lifespan extends Span<Long,Lifespan>, Iterable<Long> permits Lifespan.Empty, Lifespan.Impl
A closed range on snapshot keys, indicating a duration of time

To attempt to avoid overuse of boxed Longs, we add primitive getters for the endpoints and re-define many of the interfaces' methods to work on those primitives directly. However, we've not done any performance testing to know whether the juice is worth the squeeze.

  • Field Details

  • Method Details

    • span

      static Lifespan span(long minSnap, long maxSnap)
      Get the lifespan for the given snap bounds
      Parameters:
      minSnap - the minimum snap
      maxSnap - the maximum snap
      Returns:
      the lifespan
    • at

      static Lifespan at(long snap)
      Get the lifespan for only the given snap.
      Parameters:
      snap - the snapshot key
      Returns:
      the lifespan
    • since

      static Lifespan since(long snap)
      Get the lifespan from 0 to the given snap.

      The lower bound is 0 to exclude scratch space.

      Parameters:
      snap - the snapshot key
      Returns:
      the lifespan
    • nowOn

      static Lifespan nowOn(long snap)
      Get the lifespan from the given snap into the indefinite future
      Parameters:
      snap - the snapshot key
      Returns:
      the lifespan
    • nowOnMaybeScratch

      static Lifespan nowOnMaybeScratch(long snap)
      Get the lifespan from the given snap into the indefinite future, considering scratch space

      If the snapshot is in scratch space, then the span will have an upper endpoint of -1, the last scratch snapshot. Otherwise, this is the same as nowOn(long).

      Parameters:
      snap -
      Returns:
      the lifespan
    • isScratch

      static boolean isScratch(long snap)
      Check if a given snapshot key is designated as scratch space

      Conventionally, negative snaps are scratch space.

      Parameters:
      snap - the snap
      Returns:
      true if scratch space
    • toNow

      static Lifespan toNow(long snap)
      Get the lifespan from the given snap into the indefinite past, including scratch
      Parameters:
      snap - the snapshot key
      Returns:
      the lifespan
    • before

      static Lifespan before(long snap)
      Get the lifespan that excludes the given and all future snaps
      Parameters:
      snap - the snap
      Returns:
      the lifespan
    • domain

      default Lifespan.Domain domain()
      Description copied from interface: Span
      Get the domain of this span's endpoints
      Specified by:
      domain in interface Span<Long,Lifespan>
      Returns:
      the domain
    • lmin

      long lmin()
    • lmax

      long lmax()
    • contains

      boolean contains(long n)
    • withMin

      default Lifespan withMin(long min)
    • withMax

      default Lifespan withMax(long max)