multiway_merge.h: More robust finding of an arbitrary existing element inside the input sequences.

2007-11-14  Johannes Singler  <singler@ira.uka.de>

      * include/parallel/multiway_merge.h: More robust finding of an
        arbitrary existing element inside the input sequences.
      * include/bits/stl_algo.h: Fix typo to actually call appropriate
        sequential version.

From-SVN: r130183
This commit is contained in:
Johannes Singler 2007-11-14 17:37:38 +00:00 committed by Johannes Singler
parent 6c74788ed7
commit d76575caa5
3 changed files with 36 additions and 19 deletions

View File

@ -1,3 +1,11 @@
2007-11-14 Johannes Singler <singler@ira.uka.de>
* include/parallel/multiway_merge.h: More robust finding of an
arbitrary existing element inside the input sequences.
* include/bits/stl_algo.h: Fix typo to actually call appropriate
sequential version.
2007-11-13 Benjamin Kosnik <bkoz@redhat.com>
* docs/html/documentation.html: First pass at unified table of contents.

View File

@ -2028,7 +2028,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
{
if (__depth_limit == 0)
{
_GLIBCXX_STD_P:partial_sort(__first, __last, __last);
_GLIBCXX_STD_P::partial_sort(__first, __last, __last);
return;
}
--__depth_limit;

View File

@ -900,25 +900,34 @@ namespace __gnu_parallel
difference_type total_length = 0;
// Default value for potentially non-default-constructible types.
value_type* defaultcons = NULL;
value_type* arbitrary_element = NULL;
for (int t = 0; t < k; t++)
{
if (stable)
{
if (seqs_begin[t].first == seqs_begin[t].second)
lt.insert_start_stable(*defaultcons, t, true);
else
lt.insert_start_stable(*seqs_begin[t].first, t, false);
}
else
{
if (seqs_begin[t].first == seqs_begin[t].second)
lt.insert_start(*defaultcons, t, true);
else
lt.insert_start(*seqs_begin[t].first, t, false);
}
if(arbitrary_element == NULL && LENGTH(seqs_begin[t]) > 0)
arbitrary_element = &(*seqs_begin[t].first);
total_length += LENGTH(seqs_begin[t]);
}
total_length += LENGTH(seqs_begin[t]);
if(total_length == 0)
return target;
for (int t = 0; t < k; t++)
{
if (stable)
{
if (seqs_begin[t].first == seqs_begin[t].second)
lt.insert_start_stable(*arbitrary_element, t, true);
else
lt.insert_start_stable(*seqs_begin[t].first, t, false);
}
else
{
if (seqs_begin[t].first == seqs_begin[t].second)
lt.insert_start(*arbitrary_element, t, true);
else
lt.insert_start(*seqs_begin[t].first, t, false);
}
}
if (stable)
@ -941,7 +950,7 @@ namespace __gnu_parallel
// Feed.
if (seqs_begin[source].first == seqs_begin[source].second)
lt.delete_min_insert_stable(*defaultcons, true);
lt.delete_min_insert_stable(*arbitrary_element, true);
else
// Replace from same source.
lt.delete_min_insert_stable(*seqs_begin[source].first, false);
@ -959,7 +968,7 @@ namespace __gnu_parallel
// Feed.
if (seqs_begin[source].first == seqs_begin[source].second)
lt.delete_min_insert(*defaultcons, true);
lt.delete_min_insert(*arbitrary_element, true);
else
// Replace from same source.
lt.delete_min_insert(*seqs_begin[source].first, false);