anchor.diff:  %% lose(Buf) -> lose(os:timestamp(), 1, Buf).
   lose(Count, Buf) -> lose(os:timestamp(), Count, Buf).
   
  -lose(_Time, 0, Buf) -> Buf;
  -lose(Time, Count, Buf = #lpdb{loss_count=0})
  +-spec lose(erlang:timestamp(), non_neg_integer(), buf()) -> buf().
  +
  +lose(_Time, 0, Buf = #lpdb{}) -> Buf;
  +lose(Time = {_,_,_}, Count, Buf = #lpdb{loss_count=0})
     when Count > 0 ->
       Buf#lpdb{loss_count=Count,
                loss_start=Time};
   lose(_Time, NewCount, Buf = #lpdb{loss_count=OldCount})
  -  when NewCount > 0 ->
  +  when NewCount > 0, is_integer(OldCount) ->
       Buf#lpdb{loss_count=NewCount + OldCount}.
   
   -ifdef(TEST).
  
positive.code:          ,to_list/1
           ,from_list/1
           ,to_pkts/3
           ]).
  
  -ifdef(TEST).
  
negative.code:     Buf#lpdb{messages = queue:in(Msg, Q)}.
  
  displace(Msg, Buf = #lpdb{loss_count = 0}) ->
      insert(Msg, lose(1, drop(1, Buf))).
  
  -spec drop(Count::non_neg_integer(), buf()) -> buf().
  drop(0, Buf = #lpdb{}) -> Buf;
  drop(1, Buf = #lpdb{messages = OldQueue}) ->
      {_, NewQueue} = queue:out(OldQueue),
      Buf#lpdb{messages = NewQueue};
  drop(N, Buf = #lpdb{messages = Queue})
    when is_integer(N), N >= 0 ->
      NewQueue = case queue:len(Queue) >= N of
                     true ->
                         {_, Queue1} = queue:split(N, Queue),
                         Queue1;
                     false ->
                         %% Trying to drop all (or more) items in queue
                         queue:new()
                 end,
      Buf#lpdb{messages = NewQueue}.
  
  -ifdef(TEST).
  
  