From d7328b4a31cba1f7c99366e7f8ad1f0ee709d048 Mon Sep 17 00:00:00 2001 From: Henning Baldersheim Date: Thu, 15 Dec 2016 12:47:01 +0100 Subject: Complete the split also for tests. --- vespalib/src/vespa/vespalib/stllike/hash_map.h | 12 +++++----- vespalib/src/vespa/vespalib/stllike/hash_map.hpp | 12 +--------- .../src/vespa/vespalib/stllike/hash_map_insert.hpp | 18 +++++++++++++++ vespalib/src/vespa/vespalib/stllike/hash_set.hpp | 20 +--------------- .../src/vespa/vespalib/stllike/hash_set_insert.hpp | 27 ++++++++++++++++++++++ .../vespalib/tensor/dense/dense_tensor_builder.cpp | 2 -- .../tensor/sparse/sparse_tensor_builder.cpp | 2 -- .../vespalib/tensor/sparse/sparse_tensor_match.cpp | 2 -- .../src/vespa/vespalib/tensor/tensor_apply.cpp | 1 - .../src/vespa/vespalib/tensor/tensor_mapper.cpp | 1 - 10 files changed, 53 insertions(+), 44 deletions(-) create mode 100644 vespalib/src/vespa/vespalib/stllike/hash_map_insert.hpp create mode 100644 vespalib/src/vespa/vespalib/stllike/hash_set_insert.hpp (limited to 'vespalib') 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 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 { @@ -26,16 +26,6 @@ hash_map::erase(const K & key) { return _ht.erase(key); } -template -template -void -hash_map::insert(InputIt first, InputIt last) { - while (first != last) { - _ht.insert(*first); - ++first; - } -} - template void hash_map::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 +template +void +hash_map::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 { @@ -16,14 +16,6 @@ hash_set::hash_set(size_t reserveSize, const H &hasher, const EQ &e : _ht(reserveSize, hasher, equal) { } -template -template -hash_set::hash_set(InputIterator first, InputIterator last) - : _ht(0) -{ - insert(first, last); -} - template hash_set::hash_set(std::initializer_list input) : _ht(0) @@ -70,16 +62,6 @@ hash_set::getMemoryConsumption() const { return _ht.getMemoryConsumption(); } -template -template -void -hash_set::insert(InputIt first, InputIt last) { - _ht.resize(last - first + capacity()); - for (; first < last; first++) { - _ht.insert(*first); - } -} - template void hash_set::erase(const K &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 +template +hash_set::hash_set(InputIterator first, InputIterator last) + : _ht(0) +{ + insert(first, last); +} + +template +template +void +hash_set::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 -#include -#include 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 -#include 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 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 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 #include "tensor_address_element_iterator.h" #include "default_tensor.h" -#include using vespalib::eval::ValueType; -- cgit v1.2.3