Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
FORMUS3IC_LAS3
/
embb
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
5d1a3416
authored
Mar 02, 2015
by
Tobias Fuchs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
algorithms_cpp: added guard definition for QuickSort, MergeSort restricting to RAI
parent
c85e738a
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
12 deletions
+33
-12
algorithms_cpp/include/embb/algorithms/internal/merge_sort-inl.h
+16
-6
algorithms_cpp/include/embb/algorithms/internal/quick_sort-inl.h
+17
-6
No files found.
algorithms_cpp/include/embb/algorithms/internal/merge_sort-inl.h
View file @
5d1a3416
...
@@ -213,19 +213,18 @@ class MergeSortFunctor {
...
@@ -213,19 +213,18 @@ class MergeSortFunctor {
}
}
};
};
}
// namespace internal
template
<
typename
RAI
,
typename
RAITemp
,
typename
ComparisonFunction
>
template
<
typename
RAI
,
typename
RAITemp
,
typename
ComparisonFunction
>
void
MergeSort
(
void
MergeSort
IteratorCheck
(
RAI
first
,
RAI
first
,
RAI
last
,
RAI
last
,
RAITemp
temporary_first
,
RAITemp
temporary_first
,
ComparisonFunction
comparison
,
ComparisonFunction
comparison
,
const
embb
::
mtapi
::
ExecutionPolicy
&
policy
,
const
embb
::
mtapi
::
ExecutionPolicy
&
policy
,
size_t
block_size
size_t
block_size
,
std
::
random_access_iterator_tag
)
{
)
{
typedef
typename
std
::
iterator_traits
<
RAI
>::
difference_type
difference_type
;
typedef
typename
std
::
iterator_traits
<
RAI
>::
difference_type
difference_type
;
typedef
internal
::
MergeSortFunctor
<
RAI
,
RAITemp
,
ComparisonFunction
>
typedef
MergeSortFunctor
<
RAI
,
RAITemp
,
ComparisonFunction
>
functor_t
;
functor_t
;
difference_type
distance
=
std
::
distance
(
first
,
last
);
difference_type
distance
=
std
::
distance
(
first
,
last
);
if
(
distance
==
0
)
{
if
(
distance
==
0
)
{
...
@@ -249,7 +248,7 @@ void MergeSort(
...
@@ -249,7 +248,7 @@ void MergeSort(
"Not enough MTAPI tasks available to perform merge sort"
);
"Not enough MTAPI tasks available to perform merge sort"
);
}
}
internal
::
BlockSizePartitioner
<
RAI
>
partitioner
(
first
,
last
,
block_size
);
BlockSizePartitioner
<
RAI
>
partitioner
(
first
,
last
,
block_size
);
functor_t
functor
(
0
,
functor_t
functor
(
0
,
partitioner
.
Size
()
-
1
,
partitioner
.
Size
()
-
1
,
temporary_first
,
temporary_first
,
...
@@ -266,6 +265,17 @@ void MergeSort(
...
@@ -266,6 +265,17 @@ void MergeSort(
task
.
Wait
(
MTAPI_INFINITE
);
task
.
Wait
(
MTAPI_INFINITE
);
}
}
}
// namespace internal
template
<
typename
RAI
,
typename
RAITemp
,
typename
ComparisonFunction
>
void
MergeSort
(
RAI
first
,
RAI
last
,
RAITemp
temporary_first
,
ComparisonFunction
comparison
,
const
embb
::
mtapi
::
ExecutionPolicy
&
policy
,
size_t
block_size
)
{
typedef
typename
std
::
iterator_traits
<
RAI
>::
iterator_category
category
;
internal
::
MergeSortIteratorCheck
(
first
,
last
,
temporary_first
,
comparison
,
policy
,
block_size
,
category
());
}
}
// namespace algorithms
}
// namespace algorithms
}
// namespace embb
}
// namespace embb
...
...
algorithms_cpp/include/embb/algorithms/internal/quick_sort-inl.h
View file @
5d1a3416
...
@@ -186,11 +186,12 @@ class QuickSortFunctor {
...
@@ -186,11 +186,12 @@ class QuickSortFunctor {
QuickSortFunctor
(
const
QuickSortFunctor
&
);
QuickSortFunctor
(
const
QuickSortFunctor
&
);
};
};
}
// namespace internal
template
<
typename
RAI
,
typename
ComparisonFunction
>
template
<
typename
RAI
,
typename
ComparisonFunction
>
void
QuickSort
(
RAI
first
,
RAI
last
,
ComparisonFunction
comparison
,
void
QuickSortIteratorCheck
(
RAI
first
,
RAI
last
,
const
embb
::
mtapi
::
ExecutionPolicy
&
policy
,
size_t
block_size
)
{
ComparisonFunction
comparison
,
const
embb
::
mtapi
::
ExecutionPolicy
&
policy
,
size_t
block_size
,
std
::
random_access_iterator_tag
)
{
embb
::
mtapi
::
Node
&
node
=
embb
::
mtapi
::
Node
::
GetInstance
();
embb
::
mtapi
::
Node
&
node
=
embb
::
mtapi
::
Node
::
GetInstance
();
typedef
typename
std
::
iterator_traits
<
RAI
>::
difference_type
difference_type
;
typedef
typename
std
::
iterator_traits
<
RAI
>::
difference_type
difference_type
;
difference_type
distance
=
std
::
distance
(
first
,
last
);
difference_type
distance
=
std
::
distance
(
first
,
last
);
...
@@ -212,13 +213,23 @@ void QuickSort(RAI first, RAI last, ComparisonFunction comparison,
...
@@ -212,13 +213,23 @@ void QuickSort(RAI first, RAI last, ComparisonFunction comparison,
EMBB_THROW
(
embb
::
base
::
ErrorException
,
EMBB_THROW
(
embb
::
base
::
ErrorException
,
"Not enough MTAPI tasks available for performing quick sort"
);
"Not enough MTAPI tasks available for performing quick sort"
);
}
}
internal
::
QuickSortFunctor
<
RAI
,
ComparisonFunction
>
functor
(
QuickSortFunctor
<
RAI
,
ComparisonFunction
>
functor
(
first
,
last
,
comparison
,
policy
,
block_size
);
first
,
last
,
comparison
,
policy
,
block_size
);
mtapi
::
Task
task
=
node
.
Spawn
(
mtapi
::
Action
(
base
::
MakeFunction
(
mtapi
::
Task
task
=
node
.
Spawn
(
mtapi
::
Action
(
base
::
MakeFunction
(
functor
,
&
internal
::
QuickSortFunctor
<
RAI
,
ComparisonFunction
>::
Action
)));
functor
,
&
QuickSortFunctor
<
RAI
,
ComparisonFunction
>::
Action
)));
task
.
Wait
(
MTAPI_INFINITE
);
task
.
Wait
(
MTAPI_INFINITE
);
}
}
}
// namespace internal
template
<
typename
RAI
,
typename
ComparisonFunction
>
void
QuickSort
(
RAI
first
,
RAI
last
,
ComparisonFunction
comparison
,
const
embb
::
mtapi
::
ExecutionPolicy
&
policy
,
size_t
block_size
)
{
typedef
typename
std
::
iterator_traits
<
RAI
>::
iterator_category
category
;
internal
::
QuickSortIteratorCheck
(
first
,
last
,
comparison
,
policy
,
block_size
,
category
());
}
}
// namespace algorithms
}
// namespace algorithms
}
// namespace embb
}
// namespace embb
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment