anchor.diff:  -author("Kalin").
   
   %% API
  --export([new/1, pushr/2, remove/2, add/2, add/3, move/3, whereis/2, min_seq/1, max_seq/1, read/3]).
  +-export([new/1, pushr/2, remove/2, add/2, add/3, forward/3, whereis/2, min_seq/1, max_seq/1, read/3]).
   
   -define(SEQ_MONOID,sequence_monoid).
   
  
positive.code:     Seq1 = Seq+1,
      SQ#shared_q{cur_seq = Seq1,queue = sequence_monoid:pushr_w_seq(Seq1,El,Q)}.
  
  move(ClientId,ToSeq,SQ = #shared_q{client_seqs = Offsets}) ->
      Offsets1 = min_val_tree:store(ClientId,ToSeq,Offsets),
      maybe_truncate(Offsets1,SQ).
  
  whereis(ClientId,SQ = #shared_q{client_seqs = Offsets}) ->
      min_val_tree:get_val(ClientId,Offsets).
  
  remove(ClientId,SQ = #shared_q{client_seqs = Offsets}) ->
  
negative.code:     {Interval,_} =  sequence_monoid:split_by_seq(fun(Seq) -> Seq =< MaxSeq end, Rest),
      sequence_monoid:to_list(Interval).
  
  
  