From 2956ad6dfa3ca9a2cbcb71640169704a8a2f1fb7 Mon Sep 17 00:00:00 2001 From: MHaselmaier Date: Fri, 14 May 2021 13:16:39 +0200 Subject: [PATCH] Removed core::collection::ListMap --- src/CMakeLists.txt | 2 +- src/oatpp/core/collection/ListMap.hpp | 277 ------------------ src/oatpp/network/Url.hpp | 1 - src/oatpp/web/protocol/http/Http.hpp | 1 - src/oatpp/web/protocol/http/outgoing/Body.hpp | 1 - 5 files changed, 1 insertion(+), 281 deletions(-) delete mode 100644 src/oatpp/core/collection/ListMap.hpp diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 00cedd8f..b31d48dd 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -65,7 +65,7 @@ add_library(oatpp oatpp/core/base/memory/ObjectPool.hpp oatpp/core/collection/FastQueue.hpp oatpp/core/collection/LinkedList.hpp - oatpp/core/collection/ListMap.hpp + oatpp/core/concurrency/SpinLock.cpp oatpp/core/concurrency/SpinLock.hpp oatpp/core/concurrency/Thread.cpp diff --git a/src/oatpp/core/collection/ListMap.hpp b/src/oatpp/core/collection/ListMap.hpp deleted file mode 100644 index d6149bdd..00000000 --- a/src/oatpp/core/collection/ListMap.hpp +++ /dev/null @@ -1,277 +0,0 @@ -/*************************************************************************** - * - * Project _____ __ ____ _ _ - * ( _ ) /__\ (_ _)_| |_ _| |_ - * )(_)( /(__)\ )( (_ _)(_ _) - * (_____)(__)(__)(__) |_| |_| - * - * - * Copyright 2018-present, Leonid Stryzhevskyi - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - ***************************************************************************/ - -#ifndef oatpp_collection_ListMap_hpp -#define oatpp_collection_ListMap_hpp - -#include "oatpp/core/base/memory/ObjectPool.hpp" -#include "oatpp/core/base/Countable.hpp" - -namespace oatpp { namespace collection { - -template -class ListMap : public oatpp::base::Countable { -public: - OBJECT_POOL(ListMap_Pool, ListMap, 32) - SHARED_OBJECT_POOL(Shared_ListMap_Pool, ListMap, 32) -public: - - //-------------------------------------------------------------------------------------- - // Entry - - class Entry{ - friend ListMap; - public: - OBJECT_POOL_THREAD_LOCAL(ListMap_Entry_Pool, Entry, 64) - private: - K key; - V value; - Entry* next; - protected: - Entry(const K& pKey, const V& pValue, Entry* pNext) - : key(pKey) - , value(pValue) - , next(pNext) - {} - - ~Entry(){ - } - public: - - const K& getKey() const{ - return key; - } - - const V& getValue() const{ - return value; - } - - Entry* getNext() const{ - return next; - } - - }; - -private: - - Entry* m_first; - Entry* m_last; - v_int32 m_count; - - oatpp::base::memory::MemoryPool& m_itemMemoryPool; - -private: - - Entry* createEntry(const K& pKey, const V& pValue, Entry* pNext){ - return new (m_itemMemoryPool.obtain()) Entry(pKey, pValue, pNext); - } - - void destroyEntry(Entry* entry){ - entry->~Entry(); - oatpp::base::memory::MemoryPool::free(entry); - } - -private: - - template - Entry* getEntryByKey(const Key& key) const{ - - Entry* curr = m_first; - - while(curr != nullptr){ - if(key == curr->key){ - return curr; - } - curr = curr->next; - } - - return nullptr; - - } - - void addOneEntry(Entry* entry){ - - if(m_last == nullptr){ - m_first = entry; - m_last = entry; - }else{ - m_last->next = entry; - m_last = entry; - } - - m_count++; - } - -public: - ListMap() - : m_first(nullptr) - , m_last(nullptr) - , m_count(0) - , m_itemMemoryPool(Entry::ListMap_Entry_Pool::getPool()) - {} -public: - - static std::shared_ptr createShared(){ - return Shared_ListMap_Pool::allocateShared(); - } - - ~ListMap() override { - clear(); - } - - Entry* put(const K& key, const V& value){ - Entry* entry = getEntryByKey(key); - if(entry != nullptr){ - if(entry->value != value){ - entry->value = value; - } - }else{ - entry = createEntry(key, value, nullptr); - addOneEntry(entry); - } - return entry; - } - - bool putIfNotExists(const K& key, const V& value){ - Entry* entry = getEntryByKey(key); - if(entry == nullptr){ - entry = createEntry(key, value, nullptr); - addOneEntry(entry); - return true; - } - return false; - } - - const Entry* find(const K& key) const{ - Entry* entry = getEntryByKey(key); - if(entry != nullptr){ - return entry; - } - return nullptr; - } - - const V& get(const K& key, const V& defaultValue) const { - Entry* entry = getEntryByKey(key); - if(entry != nullptr){ - return entry->getValue(); - } - return defaultValue; - } - - /* - template - const Entry* getByKeyTemplate(const Key& key) const{ - - Entry* entry = getEntryByKey(key); - if(entry != nullptr){ - return entry; - } - - return nullptr; - - } - */ - - V remove(const K& key){ - - if(m_first != nullptr){ - - if(m_first->key->equals(key)){ - Entry* next = m_first->next; - V result = m_first->value; - destroyEntry(m_first); - m_first = next; - return result; - } - - Entry* curr = m_first; - Entry* next = m_first->next; - - while(next != nullptr){ - if(next->key->equals(key)){ - V result = next->value; - curr->next = next->next; - destroyEntry(next); - return result; - } - curr = next; - next = curr->next; - } - - } - - return V::empty(); - } - - Entry* getEntryByIndex(v_int32 index) const{ - - if(index >= m_count){ - return nullptr; - } - - v_int32 i = 0; - Entry* curr = m_first; - - while(curr != nullptr){ - - if(i == index){ - return curr; - } - - curr = curr->next; - i++; - } - - return nullptr; - - } - - Entry* getFirstEntry() const { - return m_first; - } - - v_int32 count() const{ - return m_count; - } - - void clear(){ - - Entry* curr = m_first; - while(curr != nullptr){ - Entry* next = curr->next; - destroyEntry(curr); - curr = next; - } - - m_first = nullptr; - m_last = nullptr; - m_count = 0; - - } - -}; - -}} - -#endif /* oatpp_collection_ListMap_hpp */ diff --git a/src/oatpp/network/Url.hpp b/src/oatpp/network/Url.hpp index 5eaafeb2..147c32f3 100644 --- a/src/oatpp/network/Url.hpp +++ b/src/oatpp/network/Url.hpp @@ -27,7 +27,6 @@ #include "oatpp/core/data/share/LazyStringMap.hpp" #include "oatpp/core/parser/Caret.hpp" -#include "oatpp/core/collection/ListMap.hpp" #include "oatpp/core/Types.hpp" namespace oatpp { namespace network { diff --git a/src/oatpp/web/protocol/http/Http.hpp b/src/oatpp/web/protocol/http/Http.hpp index e5c956ee..430c6bce 100644 --- a/src/oatpp/web/protocol/http/Http.hpp +++ b/src/oatpp/web/protocol/http/Http.hpp @@ -31,7 +31,6 @@ #include "oatpp/core/parser/Caret.hpp" #include "oatpp/core/data/share/LazyStringMap.hpp" -#include "oatpp/core/collection/ListMap.hpp" #include "oatpp/core/Types.hpp" #include diff --git a/src/oatpp/web/protocol/http/outgoing/Body.hpp b/src/oatpp/web/protocol/http/outgoing/Body.hpp index ca3599d4..b0e737f7 100644 --- a/src/oatpp/web/protocol/http/outgoing/Body.hpp +++ b/src/oatpp/web/protocol/http/outgoing/Body.hpp @@ -28,7 +28,6 @@ #include "oatpp/web/protocol/http/Http.hpp" #include "oatpp/core/data/stream/Stream.hpp" -#include "oatpp/core/collection/ListMap.hpp" #include "oatpp/core/async/Coroutine.hpp" namespace oatpp { namespace web { namespace protocol { namespace http { namespace outgoing {