anchor.diff:           intersection/2,
            difference/2,
            size/1,
  +         first/2,
            min/1]).
   
   -record(pieceset, {
  
positive.code:      ?_assertEqual(1, ?set:min(?set:from_list([1,7], 8))),
       ?_assertEqual(15, ?set:min(?set:from_list([15], 16)))].
  
  %%
  %% Modifying the contents of a pieceset
  %%
  
negative.code: size(<<>>, Acc) ->
      Acc.
  
  %% @doc Return the first member of the list that is a member of the set
  %% If no element of the list is a member of the set the function exits
  %% with reason badarg. This function assumes that all pieces in the lists
  %% are valid.
  %% @end
  -spec first([non_neg_integer()], pieceset()) -> non_neg_integer().
  first(Pieces, Pieceset) ->
      #pieceset{elements=Elements} = Pieceset,
      first_(Pieces, Elements).
  
  first_([], _) ->
      error(badarg);
  first_([H|T], Elements) ->
      <<_:H/bitstring, Status:1, _/bitstring>> = Elements,
      case Status of
          1 -> H;
          0 -> first_(T, Elements)
      end.
  
  %% @doc
  %% Return the lowest piece index that is a member of this set.
  %% If the piece set is empty, exit with reason badarg
  