summaryrefslogtreecommitdiffstats
path: root/src/include/util
diff options
context:
space:
mode:
authorStephen Cprek <smcprek@us.ibm.com>2017-04-06 17:08:15 -0500
committerDaniel M. Crowell <dcrowell@us.ibm.com>2017-04-10 17:57:10 -0400
commit5afa41551b3d8e0a84cf21cebfc89a194d326e76 (patch)
tree27018d5dc7aa801fee3e77af6be9c7693a178aa3 /src/include/util
parentdee1ed49ad08fdb4b91775f50f65e69ad5bbfafa (diff)
downloadtalos-hostboot-5afa41551b3d8e0a84cf21cebfc89a194d326e76.tar.gz
talos-hostboot-5afa41551b3d8e0a84cf21cebfc89a194d326e76.zip
Add map list initialization and at() methods
Also add ErrnoToString() as a test which is a functionality ported from p8 Change-Id: Ia6dd9b37638af2634267e224d9b97133bf984fb4 Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/38956 Tested-by: Jenkins Server <pfd-jenkins+hostboot@us.ibm.com> Reviewed-by: Nicholas E. Bofferding <bofferdn@us.ibm.com> Reviewed-by: Martin Gloff <mgloff@us.ibm.com> Tested-by: Jenkins OP Build CI <op-jenkins+hostboot@us.ibm.com> Tested-by: FSP CI Jenkins <fsp-CI-jenkins+hostboot@us.ibm.com> Reviewed-by: Daniel M. Crowell <dcrowell@us.ibm.com>
Diffstat (limited to 'src/include/util')
-rw-r--r--src/include/util/impl/stlmap.H32
1 files changed, 30 insertions, 2 deletions
diff --git a/src/include/util/impl/stlmap.H b/src/include/util/impl/stlmap.H
index cdf5824e4..c451a0fa2 100644
--- a/src/include/util/impl/stlmap.H
+++ b/src/include/util/impl/stlmap.H
@@ -5,7 +5,7 @@
/* */
/* OpenPOWER HostBoot Project */
/* */
-/* Contributors Listed Below - COPYRIGHT 2012,2016 */
+/* Contributors Listed Below - COPYRIGHT 2012,2017 */
/* [+] International Business Machines Corp. */
/* */
/* */
@@ -39,6 +39,8 @@
#include <utility>
#include <util/traits/remove_const.H>
#include <algorithm>
+#include <initializer_list>
+#include <assert.h>
#ifndef __UTIL_SPLAYTREE_NS
@@ -65,6 +67,7 @@ namespace Util
typedef ptrdiff_t difference_type;
typedef T* pointer;
typedef T& reference;
+ typedef const T& const_reference;
// Allow Map and other GenericIterators to be friends.
template <typename S, typename Itr2>
@@ -111,13 +114,19 @@ namespace Util
return t;
}
- /** Dereference Operator */
+ /** Dereference Operators */
reference operator*()
{
return reinterpret_cast<__UTIL_SPLAYTREE_NS::Node<T>*>(
const_cast<__UTIL_SPLAYTREE_NS::Node<const void*>*>(
(Itr::getNode())))->data_T();
}
+ const_reference operator*() const
+ {
+ return reinterpret_cast<__UTIL_SPLAYTREE_NS::Node<T>*>(
+ const_cast<__UTIL_SPLAYTREE_NS::Node<const void*>*>(
+ (Itr::getNode())))->data_T();
+ }
/** Pointer Operator */
pointer operator->()
{
@@ -332,6 +341,20 @@ namespace Util
return (result.first)->second;
}
+ T& at(const key_type& k)
+ {
+ auto result = lower_bound(k);
+ crit_assert(result != end());
+ return (*result).second;
+ }
+
+ const T& at(const key_type& k) const
+ {
+ const auto result = lower_bound(k);
+ crit_assert(result != end());
+ return (*result).second;
+ }
+
template <class... Args>
std::pair <iterator,bool> emplace ( Args&&... args )
{
@@ -364,6 +387,11 @@ namespace Util
}
+ void insert(std::initializer_list<value_type> list)
+ {
+ insert(list.begin(), list.end());
+ }
+
iterator insert(iterator hint, const value_type& x)
{
// I don't anticipate much performance improvement with
OpenPOWER on IntegriCloud