TimeChain

public class TimeChain<T extends Comparable<T>, V> implements Iterable<T>

A segment chain is similar to a LinkedList, providing some specific features for Samples, like checking temporal integrity constraints, a custom iterator etc.

Let old and new denote the state of this before and after some mutating operations. Two data integrity constraints must hold on the data structure:

  • Monotonicity invariant: forall element: current.getStart() < next.getStart() && current.getStart() > prev.getStart()
  • Ending condition invariant: end > getLast().getStart() && old.end <= new.end

TODO: they should be enforced by mutators and trivially satisfied at the beginning, i.e. with no segments

See also

Constructors

Link copied to clipboard
public void TimeChain(@NotNull() @NotNull() T end)
It defines a chain of time segments that ends at some time instant
public void TimeChain(@NotNull() @NotNull() Sample<T, V> element, @NotNull() @NotNull() T end)
It defines a chain of time segments that ends at some time instant
public void TimeChain(@NotNull() @NotNull() List<Sample<T, V>> segments, @NotNull() @NotNull() T end)
WARNING: this interface assumes the programmer is taking responsibility about the Monotonicity of the ordered list of segments.

Properties

Link copied to clipboard
public final T end
Last time instant of definition of the chain

Functions

Link copied to clipboard
public boolean add(Sample<T, V> e)
Adds a segment to the TimeChain.
Link copied to clipboard
Link copied to clipboard
public void clear()
Link copied to clipboard
public TimeChain<T, V> copy()
Shallow copy of the chain
Link copied to clipboard
public boolean equals(Object o)
Link copied to clipboard
public void forEach(Consumer<? super Sample<T, V>> action)
Link copied to clipboard
public Sample<T, V> get(int index)
Link copied to clipboard
public T getEnd()
Link copied to clipboard
public Sample<T, V> getFirst()
Link copied to clipboard
public Sample<T, V> getLast()
Returns the last element of the chain
Link copied to clipboard
public T getStart()
Link copied to clipboard
public int hashCode()
Link copied to clipboard
public boolean isEmpty()
Link copied to clipboard
@NotNull()
public @NotNull() Iterator<Sample<T, V>> iterator()
Link copied to clipboard
public int size()
Link copied to clipboard
Link copied to clipboard
public Stream<Sample<T, V>> stream()
Link copied to clipboard
public TimeChain<T, V> subChain(int from, int to, T end)
Generates a sub-chain of the current chain.
Link copied to clipboard
public List<Sample<T, V>> toList()
Link copied to clipboard
public String toString()
Link copied to clipboard
public List<Update<T, V>> toUpdates()