diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2016-12-15 12:47:01 +0100 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2016-12-15 13:12:37 +0100 |
commit | d7328b4a31cba1f7c99366e7f8ad1f0ee709d048 (patch) | |
tree | 59c801c5a5184b785794b36be5ef74ea94256f36 /vespalib | |
parent | 6409f3bcc0ae7fafa057fdd94a5025d25a69769c (diff) |
Complete the split also for tests.
Diffstat (limited to 'vespalib')
10 files changed, 53 insertions, 44 deletions
diff --git a/vespalib/src/vespa/vespalib/stllike/hash_map.h b/vespalib/src/vespa/vespalib/stllike/hash_map.h index 12c6d3574e4..51a8151e91a 100644 --- a/vespalib/src/vespa/vespalib/stllike/hash_map.h +++ b/vespalib/src/vespa/vespalib/stllike/hash_map.h @@ -37,13 +37,13 @@ public: insert_result insert(const value_type & value); template <typename InputIt> void insert(InputIt first, InputIt last); - const V & operator [] (const K & key) const { return _ht.find(key)->second; } - V & operator [] (const K & key) { return _ht.insert(value_type(key, V())).first->second; } + const V & operator [] (const K & key) const { return _ht.find(key)->second; } + V & operator [] (const K & key) { return _ht.insert(value_type(key, V())).first->second; } void erase(const K & key); - void erase(iterator it) { return erase(it->first); } - void erase(const_iterator it) { return erase(it->first); } - iterator find(const K & key) { return _ht.find(key); } - const_iterator find(const K & key) const { return _ht.find(key); } + void erase(iterator it) { return erase(it->first); } + void erase(const_iterator it) { return erase(it->first); } + iterator find(const K & key) { return _ht.find(key); } + const_iterator find(const K & key) const { return _ht.find(key); } void clear(); void resize(size_t newSize); void swap(hash_map & rhs); diff --git a/vespalib/src/vespa/vespalib/stllike/hash_map.hpp b/vespalib/src/vespa/vespalib/stllike/hash_map.hpp index 77ecefef845..74d39e58c6b 100644 --- a/vespalib/src/vespa/vespalib/stllike/hash_map.hpp +++ b/vespalib/src/vespa/vespalib/stllike/hash_map.hpp @@ -1,7 +1,7 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #pragma once -#include "hash_map.h" +#include "hash_map_insert.hpp" #include "hashtable.hpp" namespace vespalib { @@ -27,16 +27,6 @@ hash_map<K, V, H, EQ, M>::erase(const K & key) { } template <typename K, typename V, typename H, typename EQ, typename M> -template <typename InputIt> -void -hash_map<K, V, H, EQ, M>::insert(InputIt first, InputIt last) { - while (first != last) { - _ht.insert(*first); - ++first; - } -} - -template <typename K, typename V, typename H, typename EQ, typename M> void hash_map<K, V, H, EQ, M>::clear() { _ht.clear(); diff --git a/vespalib/src/vespa/vespalib/stllike/hash_map_insert.hpp b/vespalib/src/vespa/vespalib/stllike/hash_map_insert.hpp new file mode 100644 index 00000000000..30d07163ce1 --- /dev/null +++ b/vespalib/src/vespa/vespalib/stllike/hash_map_insert.hpp @@ -0,0 +1,18 @@ +// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +#pragma once + +#include "hash_map.h" + +namespace vespalib { + +template <typename K, typename V, typename H, typename EQ, typename M> +template <typename InputIt> +void +hash_map<K, V, H, EQ, M>::insert(InputIt first, InputIt last) { + while (first != last) { + insert(*first); + ++first; + } +} + +} diff --git a/vespalib/src/vespa/vespalib/stllike/hash_set.hpp b/vespalib/src/vespa/vespalib/stllike/hash_set.hpp index 98c57a76358..8be7d982e80 100644 --- a/vespalib/src/vespa/vespalib/stllike/hash_set.hpp +++ b/vespalib/src/vespa/vespalib/stllike/hash_set.hpp @@ -1,7 +1,7 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #pragma once -#include "hash_set.h" +#include "hash_set_insert.hpp" #include "hashtable.hpp" namespace vespalib { @@ -17,14 +17,6 @@ hash_set<K, H, EQ, M>::hash_set(size_t reserveSize, const H &hasher, const EQ &e { } template<typename K, typename H, typename EQ, typename M> -template<typename InputIterator> -hash_set<K, H, EQ, M>::hash_set(InputIterator first, InputIterator last) - : _ht(0) -{ - insert(first, last); -} - -template<typename K, typename H, typename EQ, typename M> hash_set<K, H, EQ, M>::hash_set(std::initializer_list<K> input) : _ht(0) { @@ -71,16 +63,6 @@ hash_set<K, H, EQ, M>::getMemoryConsumption() const { } template<typename K, typename H, typename EQ, typename M> -template<typename InputIt> -void -hash_set<K, H, EQ, M>::insert(InputIt first, InputIt last) { - _ht.resize(last - first + capacity()); - for (; first < last; first++) { - _ht.insert(*first); - } -} - -template<typename K, typename H, typename EQ, typename M> void hash_set<K, H, EQ, M>::erase(const K &key) { return _ht.erase(key); diff --git a/vespalib/src/vespa/vespalib/stllike/hash_set_insert.hpp b/vespalib/src/vespa/vespalib/stllike/hash_set_insert.hpp new file mode 100644 index 00000000000..a0bd94bafaa --- /dev/null +++ b/vespalib/src/vespa/vespalib/stllike/hash_set_insert.hpp @@ -0,0 +1,27 @@ +// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. + +#pragma once + +#include "hash_set.h" + +namespace vespalib { + +template<typename K, typename H, typename EQ, typename M> +template<typename InputIterator> +hash_set<K, H, EQ, M>::hash_set(InputIterator first, InputIterator last) + : _ht(0) +{ + insert(first, last); +} + +template<typename K, typename H, typename EQ, typename M> +template<typename InputIt> +void +hash_set<K, H, EQ, M>::insert(InputIt first, InputIt last) { + _ht.resize(last - first + capacity()); + for (; first < last; first++) { + insert(*first); + } +} + +} diff --git a/vespalib/src/vespa/vespalib/tensor/dense/dense_tensor_builder.cpp b/vespalib/src/vespa/vespalib/tensor/dense/dense_tensor_builder.cpp index 8b41d349d43..db2a4ffaac8 100644 --- a/vespalib/src/vespa/vespalib/tensor/dense/dense_tensor_builder.cpp +++ b/vespalib/src/vespa/vespalib/tensor/dense/dense_tensor_builder.cpp @@ -2,8 +2,6 @@ #include "dense_tensor_builder.h" #include <vespa/vespalib/util/exceptions.h> -#include <vespa/vespalib/util/stringfmt.h> -#include <vespa/vespalib/stllike/hash_map.hpp> using vespalib::IllegalArgumentException; using vespalib::make_string; diff --git a/vespalib/src/vespa/vespalib/tensor/sparse/sparse_tensor_builder.cpp b/vespalib/src/vespa/vespalib/tensor/sparse/sparse_tensor_builder.cpp index 4092499bf44..beddc79cc9a 100644 --- a/vespalib/src/vespa/vespalib/tensor/sparse/sparse_tensor_builder.cpp +++ b/vespalib/src/vespa/vespalib/tensor/sparse/sparse_tensor_builder.cpp @@ -1,8 +1,6 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include "sparse_tensor_builder.h" -#include <vespa/vespalib/tensor/tensor.h> -#include <vespa/vespalib/stllike/hash_map.hpp> namespace vespalib { namespace tensor { diff --git a/vespalib/src/vespa/vespalib/tensor/sparse/sparse_tensor_match.cpp b/vespalib/src/vespa/vespalib/tensor/sparse/sparse_tensor_match.cpp index 4b4378796d0..4add729d290 100644 --- a/vespalib/src/vespa/vespalib/tensor/sparse/sparse_tensor_match.cpp +++ b/vespalib/src/vespa/vespalib/tensor/sparse/sparse_tensor_match.cpp @@ -1,8 +1,6 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include "sparse_tensor_match.h" -#include "sparse_tensor_address_decoder.h" -#include <vespa/vespalib/stllike/hash_map.hpp> namespace vespalib { namespace tensor { diff --git a/vespalib/src/vespa/vespalib/tensor/tensor_apply.cpp b/vespalib/src/vespa/vespalib/tensor/tensor_apply.cpp index ab8c1534a39..8384d997122 100644 --- a/vespalib/src/vespa/vespalib/tensor/tensor_apply.cpp +++ b/vespalib/src/vespa/vespalib/tensor/tensor_apply.cpp @@ -1,7 +1,6 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include "tensor_apply.h" -#include <vespa/vespalib/stllike/hash_map.hpp> namespace vespalib { namespace tensor { diff --git a/vespalib/src/vespa/vespalib/tensor/tensor_mapper.cpp b/vespalib/src/vespa/vespalib/tensor/tensor_mapper.cpp index 646377c1d1a..f8a1f99cb5b 100644 --- a/vespalib/src/vespa/vespalib/tensor/tensor_mapper.cpp +++ b/vespalib/src/vespa/vespalib/tensor/tensor_mapper.cpp @@ -7,7 +7,6 @@ #include <vespa/vespalib/tensor/dense/dense_tensor.h> #include "tensor_address_element_iterator.h" #include "default_tensor.h" -#include <vespa/vespalib/stllike/hash_map.hpp> using vespalib::eval::ValueType; |