anchor.diff:  -module(intervals).
   -author('schuett@zib.de').
   -vsn('$Id$').
  +
  +-compile({inline, [in_simple/2, in/2, is_between/5, interval_sort/2, merge_adjacent/2]}).
  +-compile({inline, [normalize_internal/1, normalize_simple/1, wraps_around/4]}).
  +-compile({inline, [intersection_simple/2, intersection_simple_element/2]}).
  +-compile({inline, [union_simple/2, union/2]}).
  +-compile({inline, [minus_simple/2, minus_simple2/2]}).
  +-compile({inline, [split2/8]}).
   
   -include("scalaris.hrl").
   
  
positive.code: 
  -spec normalize_internal([simple_interval()]) -> interval(). % for dialyzer
  normalize_internal(List) ->
      NormalizedList1 = lists:flatmap(fun(I) -> normalize_simple(I) end, List),
      merge_adjacent(lists:usort(fun interval_sort/2, NormalizedList1), []).
  
  %% @doc Normalizes simple intervals (see normalize_internal/1).
  
negative.code: minus(_A, [all]) -> empty();
  minus(A, [])     -> A;
  minus(A, A)      -> empty();
  minus(A, [HB | TB]) ->
      % from every simple interval in A, remove all simple intervals in B
      % note: we cannot use minus_simple in foldl since the result may be a list again
      normalize_internal(lists:flatten([minus(minus_simple(IA, HB), TB) || IA <- A])).
  
  %% @private
  %% @doc Determines whether an interval with the given borders wraps around,
  