summaryrefslogtreecommitdiffstats
path: root/src/include/util/impl/stlmap.H
diff options
context:
space:
mode:
Diffstat (limited to 'src/include/util/impl/stlmap.H')
-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