Package generic

Class Span.DefaultSpanSet<N,S extends Span<N,S>>

java.lang.Object
generic.Span.DefaultSpanSet<N,S>
Type Parameters:
N - the type of endpoints
S - the type of values
All Implemented Interfaces:
Span.MutableSpanSet<N,S>, Span.SpanSet<N,S>
Direct Known Subclasses:
ULongSpan.DefaultULongSpanSet
Enclosing interface:
Span<N,S extends Span<N,S>>

public static class Span.DefaultSpanSet<N,S extends Span<N,S>> extends Object implements Span.MutableSpanSet<N,S>
The default implementation of Span.SpanSet and Span.MutableSpanSet using an interval tree
  • Constructor Details

    • DefaultSpanSet

      public DefaultSpanSet(Span.Domain<N,S> domain)
      Create a span set on the given domain

      Extensions should invoke this as a super constructor with a fixed domain. See ULongSpan.DefaultULongSpanSet for an example.

      Parameters:
      domain - the domain
  • Method Details

    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • newSpanMap

      protected Span.MutableSpanMap<N,S,Boolean> newSpanMap(Span.Domain<N,S> domain)
      Factory method for the span map backing this span set
      Parameters:
      domain - the domain
      Returns:
      the map
    • isEmpty

      public boolean isEmpty()
      Description copied from interface: Span.SpanSet
      Check if this set has any spans
      Specified by:
      isEmpty in interface Span.SpanSet<N,S extends Span<N,S>>
      Returns:
      true if empty
    • spans

      public Iterable<S> spans()
      Description copied from interface: Span.SpanSet
      Iterate the spans in this set
      Specified by:
      spans in interface Span.SpanSet<N,S extends Span<N,S>>
      Returns:
      the iterable
    • bound

      public S bound()
      Description copied from interface: Span.SpanSet
      Get a span which encloses all spans in the set
      Specified by:
      bound in interface Span.SpanSet<N,S extends Span<N,S>>
      Returns:
      the bounding span
    • contains

      public boolean contains(N n)
      Description copied from interface: Span.SpanSet
      Check if the set contains the given value
      Specified by:
      contains in interface Span.SpanSet<N,S extends Span<N,S>>
      Parameters:
      n - the value
      Returns:
      true if contained by any span in the set
    • spanContaining

      public S spanContaining(N n)
      Description copied from interface: Span.SpanSet
      Get the span containing the given value
      Specified by:
      spanContaining in interface Span.SpanSet<N,S extends Span<N,S>>
      Parameters:
      n - the value
      Returns:
      the span or null
    • intersecting

      public Iterable<S> intersecting(S s)
      Description copied from interface: Span.SpanSet
      Iterate over all spans in the set that intersect the given span
      Specified by:
      intersecting in interface Span.SpanSet<N,S extends Span<N,S>>
      Parameters:
      s - the span
      Returns:
      the iterable of spans
    • intersects

      public boolean intersects(S s)
      Description copied from interface: Span.SpanSet
      Check if any span in the set intersects the given span
      Specified by:
      intersects in interface Span.SpanSet<N,S extends Span<N,S>>
      Parameters:
      s - the span
      Returns:
      true if any span in the set intersects it
    • add

      public void add(S s)
      Description copied from interface: Span.MutableSpanSet
      Add a span to the set

      Any connected spans will be coalesced.

      Specified by:
      add in interface Span.MutableSpanSet<N,S extends Span<N,S>>
      Parameters:
      s - the span
    • addAll

      public void addAll(Span.SpanSet<N,S> set)
      Description copied from interface: Span.MutableSpanSet
      Add all spans from the given set into this one

      The spans from both maps amy be coalesced when entered into this one. (The given map remains unmodified.)

      Specified by:
      addAll in interface Span.MutableSpanSet<N,S extends Span<N,S>>
      Parameters:
      set - the other set
    • remove

      public void remove(S s)
      Description copied from interface: Span.MutableSpanSet
      Remove a span from the set

      Spans which intersect the given span are truncated. Spans which are enclosed are deleted, such that no value in the given span remains in the set.

      Specified by:
      remove in interface Span.MutableSpanSet<N,S extends Span<N,S>>
      Parameters:
      s - the span
    • clear

      public void clear()
      Description copied from interface: Span.MutableSpanSet
      Remove all spans from the set
      Specified by:
      clear in interface Span.MutableSpanSet<N,S extends Span<N,S>>