• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 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 ECMASCRIPT_MEM_C_CONTAINERS_H
17 #define ECMASCRIPT_MEM_C_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 "ecmascript/mem/caddress_allocator.h"
32 
33 namespace panda::ecmascript {
34 template<class T>
35 using CVector = std::vector<T, CAddressAllocator<T>>;
36 
37 template<class T>
38 using CList = std::list<T, CAddressAllocator<T>>;
39 
40 template<class Key, class T, class Compare = std::less<>>
41 using CMap = std::map<Key, T, Compare, CAddressAllocator<std::pair<const Key, T>>>;
42 
43 template<class Key, class T, class Compare = std::less<>>
44 using CMultiMap = std::multimap<Key, T, Compare, CAddressAllocator<std::pair<const Key, T>>>;
45 
46 template<class Key, class Value, class Hash = std::hash<Key>, class KeyEqual = std::equal_to<Key>>
47 using CUnorderedMultiMap =
48     std::unordered_multimap<Key, Value, Hash, KeyEqual, CAddressAllocator<std::pair<const Key, Value>>>;
49 
50 template<class T>
51 using CDeque = std::deque<T, CAddressAllocator<T>>;
52 
53 template<class T, class Container = CDeque<T>>
54 using CQueue = std::queue<T, Container>;
55 
56 template<class T, class Container = CDeque<T>>
57 using CStack = std::stack<T, Container>;
58 
59 template<class Key, class T, class Hash = std::hash<Key>, class KeyEqual = std::equal_to<Key>>
60 using CUnorderedMap = std::unordered_map<Key, T, Hash, KeyEqual, CAddressAllocator<std::pair<const Key, T>>>;
61 
62 template<class Key, class Hash = std::hash<Key>, class KeyEqual = std::equal_to<Key>>
63 using CUnorderedSet = std::unordered_set<Key, Hash, KeyEqual, CAddressAllocator<Key>>;
64 }  // namespace panda::ecmascript
65 
66 #endif  // ECMASCRIPT_MEM_C_CONTAINERS_H
67