aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libstdc++-v3/ChangeLog8
-rw-r--r--libstdc++-v3/include/bits/stl_algo.h2
-rw-r--r--libstdc++-v3/include/parallel/multiway_merge.h45
3 files changed, 36 insertions, 19 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index d0683a1..466c8f1 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -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.
diff --git a/libstdc++-v3/include/bits/stl_algo.h b/libstdc++-v3/include/bits/stl_algo.h
index 154e225..3765dc0 100644
--- a/libstdc++-v3/include/bits/stl_algo.h
+++ b/libstdc++-v3/include/bits/stl_algo.h
@@ -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;
diff --git a/libstdc++-v3/include/parallel/multiway_merge.h b/libstdc++-v3/include/parallel/multiway_merge.h
index c7d317a..2e3be7c 100644
--- a/libstdc++-v3/include/parallel/multiway_merge.h
+++ b/libstdc++-v3/include/parallel/multiway_merge.h
@@ -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);