summaryrefslogtreecommitdiffstats
path: root/src/include/algorithm
diff options
context:
space:
mode:
authorPatrick Williams <iawillia@us.ibm.com>2012-02-14 08:37:48 -0600
committerA. Patrick Williams III <iawillia@us.ibm.com>2012-02-22 16:10:34 -0600
commitc232f7a5a8b38321edae7a02c3148e67b5b4c3c7 (patch)
tree5674989a37b2cd578f54977198e6517f5f8e5fe4 /src/include/algorithm
parentb455fb2ff154b9ff42598d96240123804659fc25 (diff)
downloadtalos-hostboot-c232f7a5a8b38321edae7a02c3148e67b5b4c3c7.tar.gz
talos-hostboot-c232f7a5a8b38321edae7a02c3148e67b5b4c3c7.zip
ThreadPool
Change-Id: I09bf867a2dbb45e063e4785f5b2b1f705fae72c8 Reviewed-on: http://gfw160.austin.ibm.com:8080/gerrit/680 Tested-by: Jenkins Server Reviewed-by: Douglas R. Gilbert <dgilbert@us.ibm.com> Reviewed-by: Bradley W. Bishop <bradleyb@us.ibm.com> Reviewed-by: Terry J. Opie <opiet@us.ibm.com> Reviewed-by: MIKE J. JONES <mjjones@us.ibm.com> Reviewed-by: A. Patrick Williams III <iawillia@us.ibm.com>
Diffstat (limited to 'src/include/algorithm')
-rw-r--r--src/include/algorithm62
1 files changed, 62 insertions, 0 deletions
diff --git a/src/include/algorithm b/src/include/algorithm
index 2537a3b53..0c94c82ae 100644
--- a/src/include/algorithm
+++ b/src/include/algorithm
@@ -176,6 +176,68 @@ namespace std
return last;
}
+
+
+ /**
+ * Find the minimum element within a range.
+ * @param[in] first - FwdIterator to the first position in the range.
+ * @param[in] last - FwdIterator to the last position in the range.
+ *
+ * Returns the first element (i) such that (*j) < (*i) is false for all
+ * other iterators.
+ *
+ * The iterator last is returned only when the range contains no elements.
+ *
+ * @return An iterator in [first, last) containing the minimum element.
+ *
+ */
+ template <typename FwdIterator>
+ inline FwdIterator min_element(FwdIterator first, FwdIterator last)
+ {
+ if (first == last) return last;
+ FwdIterator e = first++;
+ while(first != last)
+ {
+ if ((*first) < (*e))
+ {
+ e = first;
+ }
+ first++;
+ }
+ return e;
+ }
+
+ /**
+ * Find the minimum element within a range.
+ * @param[in] first - FwdIterator to the first position in the range.
+ * @param[in] last - FwdIterator to the last position in the range.
+ * @param[in] comp - BinaryPredicate used to perform comparison.
+ *
+ * Returns the first element (i) such that comp(*j,*i) is false for all
+ * other iterators.
+ *
+ * The iterator last is returned only when the range contains no elements.
+ *
+ * @return An iterator in [first, last) containing the minimum element.
+ *
+ */
+ template <typename FwdIterator, typename BinaryPredicate>
+ inline FwdIterator min_element(FwdIterator first, FwdIterator last,
+ BinaryPredicate comp)
+ {
+ if (first == last) return last;
+ FwdIterator e = first++;
+ while(first != last)
+ {
+ if (comp((*first),(*e)))
+ {
+ e = first;
+ }
+ first++;
+ }
+ return e;
+ }
+
};
#endif
OpenPOWER on IntegriCloud