anchor.diff:      if B =:= max -> delta(BPrev, BList,
                             A, ARest,
                             BAFull,
  -                          [{A, APrev, delta_next(BList, Before)} | Grows],
  +                          [{gm, A, APrev, delta_next(BList, Before)} | Grows],
                             Shrinks);
          A =:= max -> delta(B, BRest,
                             APrev, AList,
                             BAFull,
  -                          [{B, BPrev, delta_next(AList, After)} | Grows],
  -                          Shrinks);
  +                          [{sg,
  +                            delta_next(AList, After),
  +                            BPrev, B,
  +                            delta_next(BList, Before)} | Grows],
  +                          [{sm, A, APrev, B} | Shrinks]);
          B < A     -> delta(B, BRest,
                             APrev, AList,
                             BAFull,
  -                          [{B, BPrev, delta_next(AList, After)} | Grows],
  -                          Shrinks);
  +                          [{r, A, B, BPrev, B} | Grows],
  +                          [{x, B, undefined} | Shrinks]);
          true      -> delta(BPrev, BList,
                             A, ARest,
                             BAFull,
  -                          [{A, APrev, delta_next(BList, Before)} | Grows],
  -                          Shrinks)
  +                          [{g, A, {APrev, A}, delta_next(BList, Before)} | Grows],
  +                          [{s, B, A} | Shrinks])
       end.
   
  -delta_next([], [])      -> undefined;
  -delta_next([A | _], _)  -> A;
  -delta_next([], Restart) -> delta_next(Restart, []).
  +delta_next(_, [])          -> undefined;
  +delta_next([max], Restart) -> delta_next(Restart, []);
  +delta_next([A | _], _)     -> A;
  +delta_next([], Restart)    -> delta_next(Restart, []).
  
positive.code:       [Ha] = hash_addr(a, 1),
        [Hb] = hash_addr(b, 1),
        case Ha < Hb of
          true  -> ?assertEqual(a, H#cpoint.addr);
          false -> ?assertEqual(b, H#cpoint.addr)
        end,
        ok
       end)(),
  
negative.code: % Returns [{Addr, Data}*], where length of result might be <= N.
  
  search_by_point(#cring{ring = Ring, addr_num = AddrNum}, SearchPoint, N) ->
      carcs_addr_data(
        search_ring_by_point(Ring, SearchPoint, Ring, erlang:min(AddrNum, N))).
  
  %% Implementation
  
  carcs_addr_data(CArcs) ->
      lists:map(fun (#carc{addr = Addr, data = Data}) -> {Addr, Data} end,
                CArcs).
  
  make(_Hash, [], CArcs) ->
      % TODO: Consider secondary sort on hash_ord to reduce (but not
      % eliminate) unlucky case when there's a hash collision.
      lists:keysort(#carc.pt_end, CArcs);
  
  make({HashMod, HashCfg} = Hash, [{Addr, Data} | Rest], Acc) ->
      Points = HashMod:hash_addr(Addr, HashCfg),
      {_, _, Acc2} =
          lists:foldl(
            fun (Point, {N, PointPrev, AccMore}) ->
                {N + 1, Point, [#carc{pt_beg = PointPrev,
                                      pt_end = Point,
                                      hash_ord = N,
                                      addr = Addr,
                                      data = Data} | AccMore]}
            end,
            {1, min, Acc},
            Points),
      make(Hash, Rest, Acc2).
  
  % Returns [CArc*], where length might be <= TakeN.
  
  search_ring_by_point([], _SearchPoint, Ring, TakeN) ->
      util:take_ring_n(fun carc_not_member_by_addr/2,
                       Ring, TakeN, undefined);
  
  search_ring_by_point([#carc{pt_end = Point} | Rest] = CArcs,
                       SearchPoint, Ring, TakeN) ->
      % TODO: Do better than linear search.
      % For example, use erlang array instead of list.
      case SearchPoint =< Point of
          true  -> util:take_ring_n(fun carc_not_member_by_addr/2,
                                    CArcs, TakeN, Ring);
          false -> search_ring_by_point(Rest, SearchPoint, Ring, TakeN)
      end.
  
  carc_not_member_by_addr(#carc{addr = Addr}, CArcs) ->
      case lists:keysearch(Addr, #carc.addr, CArcs) of
          {value, _} -> false;
          false      -> true
      end.
  
  % Example hash_key/hash_addr functions.
  
  