function i4vec_heap_d_extract_test ( )

%*****************************************************************************80
%
%% i4vec_heap_d_extract_test() tests i4vec_heap_d_extract().
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    14 April 2009
%
%  Author:
%
%    John Burkardt
%
  n_max = 10;

  fprintf ( 1, '\n' );
  fprintf ( 1, 'i4vec_heap_d_extract_test():\n' );
  fprintf ( 1, '  i4vec_heap_d_extract() extracts the maximum value;\n' );

  n = 0;
  a = [];

  for i = 1 : n_max

    b = 0;
    c = 10;

    val = randi ( [ b, c ], 1, 1 );

    [ n, a ] = i4vec_heap_d_insert ( n, a, val );

    fprintf ( 1, '\n' );
    fprintf ( 1, '  Inserting value %d\n', val );

    val = i4vec_heap_d_max ( n, a );

    fprintf ( 1, '  Current maximum value is %d\n', val );

  end

  i4vec_print ( n, a, '  Current heap as a vector:' );

  fprintf ( 1, '\n' );
  fprintf ( 1, '  Now extract the maximum several times.\n' );
  fprintf ( 1, '\n' );

  for i = 1 : 5
    [ val, n, a ] = i4vec_heap_d_extract ( n, a );
    fprintf ( 1, '  Extracting maximum element = %d\n', val );
  end

  i4vec_print ( n, a, '  Current heap as a vector:' );

  return
end
