anchor.diff:          else
               Range (minValue, maxValue)
               |> AvlTree.singleton
  +
  +    /// Returns the number of elements in the set.
  +    let count (measurer : IMeasurer<_>) (t : Diet<'T>) =
  +        let rec cardinal_aux acc = function
  +            | [] -> acc
  +            | AvlTree.Empty :: ts ->
  +                cardinal_aux acc ts
  +            | AvlTree.Node (range : Range<_>, left, right, _) :: ts ->
  +                let dist = measurer.Distance (range.MinValue, range.MaxValue)
  +                cardinal_aux (acc + dist + 1) (left :: right :: ts)
  +        
  +        cardinal_aux 0 [t]
   
       //
       let rec private addRec (measurer : IMeasurer<_>) p (tree : Diet<'T>) cont : Diet<_> =
  
positive.code:         if AvlTree.isEmpty stream then
              input
          else
              let head, stream = AvlTree.extractMin measurer stream
              let result, _, _ = diff' input (Some head) stream
              result
  
      /// Comparison function for DIETs.
  
negative.code:                         let (right, head, stream) = diff' right head stream
                          (AvlTree.join rangeAB left right, head, stream)
                      elif measurer.Compare (rangeAB.MinValue, rangeXY.MinValue) < 0 then
                          let rangeXB = Range (rangeXY.MinValue, rangeAB.MaxValue)
                          diff_helper rangeXB right ((addRange measurer (Range (rangeAB.MinValue, measurer.Previous rangeXY.MinValue)) left)) head stream
                      elif measurer.Compare (rangeXY.MaxValue, rangeAB.MaxValue) < 0 then
                          let (head, stream) = AvlTree.tryExtractMin measurer stream
                          diff_helper (Range (measurer.Next rangeXY.MaxValue, rangeAB.MaxValue)) right left head stream
  