Package generic

Interface Span.SpanMap<N,S extends Span<N,S>,V>

Type Parameters:
N - the type of endpoints
S - the type of spans
V - the type of values
All Known Subinterfaces:
Span.MutableSpanMap<N,S,V>, ULongSpan.MutableULongSpanMap<V>, ULongSpan.ULongSpanMap<V>
All Known Implementing Classes:
Span.DefaultSpanMap, ULongSpan.DefaultULongSpanMap
Enclosing interface:
Span<N,S extends Span<N,S>>

public static interface Span.SpanMap<N,S extends Span<N,S>,V>
An abstract interface for an immutable map of spans to values

Spans are not allowed to overlap, and connected spans are automatically coalesced when mapped to the same value. For example, the entries [1..5]='A' and [6..10]='A' become one entry [1..10]='A'. When an entry is added that overlaps other entries, the existing entries are truncated or deleted (or coalesced if they share the same value as the new entry) so that the new entry can fit.

  • Method Details

    • isEmpty

      boolean isEmpty()
      Check if this map has any entries
      Returns:
      true if empty
    • spans

      Set<S> spans()
      Get the spans in this map

      Note that the behavior regarding a copy versus a view is not specified. Clients should not rely on one or the other.

      Returns:
      the set of spans
    • values

      Collection<V> values()
      Get the values in this map

      Note that the behavior regarding a copy versus a view is not specified. Clients should not rely on one of the other.

      Returns:
      the collection of values
    • bound

      S bound()
      Get a span which encloses all spans in the map
      Returns:
      the bounding span
    • entries

      Set<Map.Entry<S,V>> entries()
      Get the entries in this map

      Note that the behavior regarding a copy versus a view is not specified. Clients should not rely on one or the other.

      Returns:
      the set of entries
    • getEntry

      Map.Entry<S,V> getEntry(N n)
      Get the entry whose span contains the given key
      Parameters:
      n - the key
      Returns:
      the entry, or null
    • get

      V get(N n)
      Get the value of the given key

      Note that a null return could indicate either that no entry has a span containing the given key, or that the entry whose span contains it has the null value. To distinguish the two, consider using getEntry(Object).

      Parameters:
      n - the key
      Returns:
      the value, or null
    • intersectingEntries

      Iterable<Map.Entry<S,V>> intersectingEntries(S s)
      Iterate over all entries whose spans intersect the given span
      Parameters:
      s - the span
      Returns:
      an iterable of entries
    • intersectingSpans

      Iterable<S> intersectingSpans(S s)
      Iterate over all spans in the map that intersect the given span
      Parameters:
      s - the span
      Returns:
      an iterable of spans
    • intersects

      boolean intersects(S s)
      Check if any span in the map intersects the given span
      Parameters:
      s - the span
      Returns:
      true if any span in the map intersects it