1/** 2 * Copyright (c) 2021-2022 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16#ifndef LIBPANDABASE_UTILS_ARENA_CONTAINERS_H 17#define LIBPANDABASE_UTILS_ARENA_CONTAINERS_H 18 19#include <deque> 20#include <list> 21#include <stack> 22#include <queue> 23#include <vector> 24#include <set> 25#include <string> 26#include <map> 27#include <unordered_map> 28#include <unordered_set> 29#include <functional> 30 31#include "mem/arena_allocator.h" 32#include "mem/arena_allocator_stl_adapter.h" 33 34namespace panda { 35 36template <class T, bool use_oom_handler = false> 37using ArenaVector = std::vector<T, ArenaAllocatorAdapter<T, use_oom_handler>>; 38template <class T, bool use_oom_handler = false> 39using ArenaDeque = std::deque<T, ArenaAllocatorAdapter<T, use_oom_handler>>; 40template <class T, bool use_oom_handler = false, class ArenaContainer = ArenaDeque<T, use_oom_handler>> 41using ArenaStack = std::stack<T, ArenaContainer>; 42template <class T, bool use_oom_handler = false, class ArenaContainer = ArenaDeque<T, use_oom_handler>> 43using ArenaQueue = std::queue<T, ArenaContainer>; 44template <class T, bool use_oom_handler = false> 45using ArenaList = std::list<T, ArenaAllocatorAdapter<T, use_oom_handler>>; 46template <class Key, class Compare = std::less<Key>, bool use_oom_handler = false> 47using ArenaSet = std::set<Key, Compare, ArenaAllocatorAdapter<Key, use_oom_handler>>; 48template <class Key, class T, class Compare = std::less<Key>, bool use_oom_handler = false> 49using ArenaMap = std::map<Key, T, Compare, ArenaAllocatorAdapter<std::pair<const Key, T>, use_oom_handler>>; 50template <class Key, class T, class Compare = std::less<Key>, bool use_oom_handler = false> 51using ArenaMultiMap = std::multimap<Key, T, Compare, ArenaAllocatorAdapter<std::pair<const Key, T>, use_oom_handler>>; 52template <class Key, class T, class Hash = std::hash<Key>, class KeyEqual = std::equal_to<Key>, 53 bool use_oom_handler = false> 54using ArenaUnorderedMultiMap = 55 std::unordered_multimap<Key, T, Hash, KeyEqual, ArenaAllocatorAdapter<std::pair<const Key, T>, use_oom_handler>>; 56template <class Key, class T, class Hash = std::hash<Key>, class KeyEqual = std::equal_to<Key>, 57 bool use_oom_handler = false> 58using ArenaUnorderedMap = 59 std::unordered_map<Key, T, Hash, KeyEqual, ArenaAllocatorAdapter<std::pair<const Key, T>, false>>; 60template <class Key1, class Key2, class T, bool use_oom_handler = false> 61using ArenaDoubleUnorderedMap = 62 ArenaUnorderedMap<Key1, ArenaUnorderedMap<Key2, T, std::hash<Key2>, std::equal_to<Key2>, use_oom_handler>, 63 std::hash<Key1>, std::equal_to<Key1>, use_oom_handler>; 64template <class Key, class Hash = std::hash<Key>, class KeyEqual = std::equal_to<Key>, bool use_oom_handler = false> 65using ArenaUnorderedSet = std::unordered_set<Key, Hash, KeyEqual, ArenaAllocatorAdapter<Key, use_oom_handler>>; 66template <bool use_oom_handler = false> 67using ArenaStringT = std::basic_string<char, std::char_traits<char>, ArenaAllocatorAdapter<char, use_oom_handler>>; 68using ArenaString = ArenaStringT<false>; 69 70} // namespace panda 71 72#endif // LIBPANDABASE_UTILS_ARENA_CONTAINERS_H 73