anchor.diff:    {ok, #state{ limit = Limit }}.
   
   terminate(_, S) ->
  -  true = ets:delete(S#state.data),
     ok.
   
   %%------------------------------------------------------------------------------
  
positive.code: 	false ->
  	  {reply, {V, S0#state.ck}, S0}
        end;
      [{_, V}] ->
        {reply, {V, S0#state.ck}, S0};
      [_,_|_] ->
        io:format(user, "Multiple objects with the same key~n", []),
        {reply, hang, S0}
    end.
  
  add_update(X, K, D, W, _T, V1, S0) ->
    Ko = lists:keysort(1, K),
    Do = lists:keysort(1, D),
    case ets:lookup(S0#state.data, {X,Ko,Do}) of
      [] ->
        {reply, hang, S0};
      [{_, {calc, W}}] ->
        Ks = [{Key,Ord} || {{_,Key},Ord} <- Ko],
        Ds = [Key || {_,Key} <- Do],
        io:format(user, "Adding ~p ~p ~p = ~p~n", [X,Ks,Ds,V1]),
        ets:insert(S0#state.data, {{X,Ko,Do}, V1}),
        S1 = S0#state{ck = S0#state.ck + 1},
        {reply, {V1, S1#state.ck}, S1};
      [{_, {calc, _W1}}] ->
        {reply, hang, S0};
      [O1,_O2|_Os] ->
        io:format(user, "Multiple objects with the same key ~p ~p~n", [W, O1]),
        {reply, hang, S0};
      Other ->
        [{{_X1,_K1,_D1},V1}] = Other,
        io:format(user, "Other = ~p, W = ~p~n", [Other, W]),
        {reply, hang, S0}
    end.
  
  %%------------------------------------------------------------------------------
  
negative.code: -record(state, { 
  	  ck    = 0,
  	  age   = 2,
  	  data  = tdtree:new(),
  	  limit = undefined
  	 }).
  
  