anchor.diff:  dump(DB) ->
       dump_with(DB, fun(_DB, From, To, X) -> {From, To, X} end).
   
  --spec dump_with(rrd(), fun((rrd(), From::time(), To::time(), Value::term()) -> T)) -> [T].
  -dump_with(DB, F) ->
  +-type dump_fun_existing(T) :: fun((rrd(), From::time(), To::time(), Value::term()) -> T).
  +-type dump_fun_nonexisting(T) :: fun((rrd(), From::time(), To::time()) -> ignore | {keep, T}).
  +
  +-spec dump_with(rrd(), dump_fun_existing(T)) -> [T].
  +dump_with(DB, FunExist) ->
  +    dump_with(DB, FunExist, fun(_DB, _From, _To) -> ignore end).
  +
  +-spec dump_with(rrd(), dump_fun_existing(T), dump_fun_nonexisting(U)) -> [T | U].
  +dump_with(DB, FunExist, FunNotExist) ->
       SlotLength = DB#rrd.slot_length,
       CurrentIndex = DB#rrd.current_index,
       Count = DB#rrd.count,
       dump_internal(DB, (CurrentIndex + 1) rem Count, CurrentIndex,
  -                  DB#rrd.current_time - (Count - 1) * SlotLength, [], F).
  +                  DB#rrd.current_time - (Count - 1) * SlotLength, [], FunExist, FunNotExist).
   
   %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   %
  
positive.code: 
  -spec dump_internal(rrd(), CurrentIdx::non_neg_integer(), EndIdx::non_neg_integer(),
                      CurrentTime::internal_time(), Rest::[T],
                      fun((rrd(), From::time(), To::time(), Value::term()) -> T)) -> [T].
  dump_internal(DB, EndIndex, EndIndex, CurrentTime, Rest, F) ->
      dump_internal2(DB, EndIndex, CurrentTime, Rest, F);
  dump_internal(DB, IndexToFetch, EndIndex, CurrentTime, Rest, F) ->
      NewRest = dump_internal2(DB, IndexToFetch, CurrentTime, Rest, F),
      Count = DB#rrd.count,
      dump_internal(DB, (IndexToFetch + 1) rem Count, EndIndex,
                    CurrentTime + DB#rrd.slot_length, NewRest, F).
  
  dump_internal2(DB, CurrentIndex, CurrentTime, Rest, F) ->
      Data = DB#rrd.data,
      case array:get(CurrentIndex, Data) of
          undefined -> Rest;
          Value     -> [F(DB, us2timestamp(CurrentTime),
                          us2timestamp(CurrentTime + DB#rrd.slot_length), Value) | Rest]
      end.
  
  -spec copy_data(rrd(), IndexToWrite::non_neg_integer(), Start::non_neg_integer(), End::non_neg_integer(), Acc::rrd()) -> rrd().
  
negative.code: -endif.
  
  % external API with transparent time handling
  -export([create/3, add_now/2, dump/1, dump_with/2, dump_with/3]).
  
  % external API without transparent time handling
  -export([create/4, add/3]).
  