Package ghidra.trace.model

# 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 `Long`s, 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.

- ## Nested Class Summary

  Nested Classes
  Modifier and Type
  Interface
  Description
  `static class`
  `Lifespan.DefaultLifeSet`
  An interval tree implementing `Lifespan.MutableLifeSet`
  `static enum`
  `Lifespan.Domain`
  The domain of snapshot keys
  `static final class`
  `Lifespan.Empty`
  The singleton empty lifespan of snapshot keys
  `static final record`
  `Lifespan.Impl`
  A non-empty lifespan of snapshot keys
  `static interface`
  `Lifespan.LifeSet`
  A set of lifespans
  `static interface`
  `Lifespan.MutableLifeSet`
  A mutable set of lifespans

  ## Nested classes/interfaces inherited from interface generic.Span

  `Span.DefaultSpanMap<N,S extends Span<N,S>,V>, Span.DefaultSpanSet<N,S extends Span<N,S>>, Span.MutableSpanMap<N,S extends Span<N,S>,V>, Span.MutableSpanSet<N,S extends Span<N,S>>, Span.SpanMap<N,S extends Span<N,S>,V>, Span.SpanMapSetter<E,N,S extends Span<N,S>,V>, Span.SpanSet<N,S extends Span<N,S>>`

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final Lifespan.Impl`
  `ALL`
  `static final Lifespan.Domain`
  `DOMAIN`
  `static final Lifespan.Empty`
  `EMPTY`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static Lifespan`
  `at(long snap)`
  Get the lifespan for only the given snap.
  `static Lifespan`
  `before(long snap)`
  Get the lifespan that excludes the given and all future snaps
  `boolean`
  `contains(long n)`
  `default Lifespan.Domain`
  `domain()`
  Get the domain of this span's endpoints
  `static boolean`
  `isScratch(long snap)`
  Check if a given snapshot key is designated as scratch space
  `long`
  `lmax()`
  `long`
  `lmin()`
  `static Lifespan`
  `nowOn(long snap)`
  Get the lifespan from the given snap into the indefinite future
  `static Lifespan`
  `nowOnMaybeScratch(long snap)`
  Get the lifespan from the given snap into the indefinite future, considering scratch space
  `static Lifespan`
  `since(long snap)`
  Get the lifespan from 0 to the given snap.
  `static Lifespan`
  `span(long minSnap, long maxSnap)`
  Get the lifespan for the given snap bounds
  `static Lifespan`
  `toNow(long snap)`
  Get the lifespan from the given snap into the indefinite past, including scratch
  `default Lifespan`
  `withMax(long max)`
  `default Lifespan`
  `withMin(long min)`

  ### Methods inherited from interface java.lang.Iterable

  `forEach, iterator, spliterator`

  ### Methods inherited from interface generic.Span

  `bound, compareTo, contains, encloses, intersect, intersects, isEmpty, max, maxIsFinite, min, minIsFinite, subtract, toString`

- ## Field Details

  - ### DOMAIN

    static final Lifespan.Domain DOMAIN

  - ### EMPTY

    static final Lifespan.Empty EMPTY

  - ### ALL

    static final Lifespan.Impl ALL

- ## 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)