anchor.diff:  head({P,_}) ->
       P.
   
  -%% remove/4
  -
  -remove(Pred, Key, Values, Dict) ->
  -     case lists:filter(Pred, Values) of
  -         [] ->
  -             dict:erase(Key, Dict);
  -         Rest ->
  -             dict:store(Key, Rest, Dict)
  -     end.
  +%% reset/3
  +
  +reset(Key, Map, []) ->
  +    maps:remove(Key, Map);
  +
  +reset(Key, Map, List) ->
  +    maps:put(Key, List, Map).
  +
  +%% queue/3
  +
  +queue(Pat, Rcvr, #state{notify = Dict} = S) ->
  +    S#state{notify =  maps:put(Pat, [Rcvr | maps:get(Pat, Dict, [])], Dict)}.
   
   %% call/1
   
  
positive.code: %% flush/2
  
  %% Process has died and should no longer receive messages/replies.
  flush(Pid, #state{receivers = RD} = S)
    when is_pid(Pid) ->
      S#state{receivers = dict:fold(fun(Pt,Ps,D) -> flush(Pid, Pt, Ps, D) end,
                                    RD,
                                    RD)}.
  
  %% flush/4
  
  flush(Pid, Pat, Recvs, Dict) ->
      remove(fun(T) -> Pid /= head(T) end, Pat, Recvs, Dict).
  
  %% head/1
  
  
negative.code:     B = ets:insert_new(?TABLE, Rec),  %% entry inserted?
      {B, B}.
  
  %% add_monitor/2
  %%
  %% Only add a single monitor for any given process, since there's no
  %% use to more.
  
  add_monitor(Pid, #state{monitors = Ps} = S) ->
      case sets:is_element(Pid, Ps) of
          false ->
              monitor(process, Pid),
              S#state{monitors = sets:add_element(Pid, Ps)};
          true ->
              S
      end.
  
  %% notify/3
  
  notify(_, false, S) ->
      S;
  
  notify(Op, {_,_} = Rec, #state{notify = Dict} = S) ->
      S#state{notify = maps:fold(fun(P,Rs,D) -> notify(Op, Rec, P, Rs, D) end,
                                 Dict,
                                 Dict)}.
  
  %% notify/5
  
  notify(Op, {_, Pid} = Rec, Pat, Rcvrs, Dict) ->
      case lists:member(Rec, match(Pat, Pid)) of
          true ->
              reset(Pat, Dict, lists:foldr(fun(P,A) -> send(P, Op, Rec, A) end,
                                           [],
                                           Rcvrs));
          false ->
              Dict
      end.
  
  %% send/4
  
  send([Pid | T] = Rcvr, Op, Rec, Acc) ->
      Pid ! {T, Op, Rec},
      [Rcvr | Acc];
  
  %% No processes wait on remove: they receive notification immediately
  %% or at add, by construction.
  send({_,_} = From, add, Rec, Acc) ->
      gen_server:reply(From, [Rec]),
      Acc.
  
  %% down/2
  
  down(Pid, #state{monitors = Ps} = S) ->
      Recs = match('_', Pid),
      ets:match_delete(?TABLE, {'_', Pid}),
      lists:foldl(fun(R,NS) -> notify(remove, R, NS) end,
                  flush(Pid, S#state{monitors = sets:del_element(Pid, Ps)}),
                  Recs).
  
  %% flush/3
  
  