anchor.diff:      end.
   
   
  +%% @doc
  +%%
  +%% @end
  +-spec assert_positive(pos_integer()) -> ok.
  +assert_positive(Integer) ->
  +    case Integer < 0 of
  +        false ->
  +            ok;
  +        true ->
  +            error(badarg)
  +    end.
  +
  +
   -ifdef(TEST).
   -define(mod, ?MODULE).
   
  
positive.code:     ?assertEqual([1,2,0], ?mod:to_list(S4)).
  
  decrement_test() ->
      S0 = ?mod:from_list([{0,0}, {1,1}, {2,2}]),
      S1 = ?mod:decrement(2, S0),
      S2 = ?mod:decrement(2, S1),
      S3 = ?mod:decrement(2, S2),
  
negative.code:     
  
  %% @doc
  %% Return an indexed scarcity list based on the input. The input
  %% must be list of piece indexes paired with the numberof peers
  %% currently provide a valid copy of the piece.
  %% @end
  -spec from_list(list({pos_integer(), pos_integer()})) -> scarcity().
  from_list(ScarcityList) ->
      [error(badarg) || {I,S} <- ScarcityList, (I < 0) or (S < 0)],
      InitCounters = array:from_orddict(ScarcityList),
      InitOrdering = gb_sets:from_list([{S,I} || {I,S} <- ScarcityList]),
      #scarcity{counters=InitCounters, ordering=InitOrdering}.
  
  
  %% @doc
  %% Returned a list of piece indexes ordered by how many peers are
  %% currently provide a valid copy of the piece. The returned list
  %% is sorted in increasing order.
  %% @end
  -spec to_list(#scarcity{}) -> list(pos_integer()).
  to_list(Scarcity) ->
  