65 typedef std::function<void()> EMProcedure;
69 std::recursive_mutex &getMutex() {
return mMutex; }
71 std::recursive_mutex mMutex;
74 inline void synchronize(
EMSTLBase &obj, EMProcedure procedure) {
75 std::lock_guard<std::recursive_mutex> lock(obj.getMutex());
80 #ifndef _LIBCPP_INLINE_VISIBILITY 81 #define _LIBCPP_INLINE_VISIBILITY __attribute__ ((__visibility__("hidden"), __always_inline__)) 84 #define _LIBCPP_INLINE_VISIBILITY 88 #define _lock_both(obj0, obj1) \ 89 assert(&obj0 != &obj1); \ 90 std::unique_lock<std::recursive_mutex> _lock0((obj0).getMutex(), std::defer_lock); \ 91 std::unique_lock<std::recursive_mutex> _lock1((obj1).getMutex(), std::defer_lock); \ 92 if (&(obj0) < &(obj1)) { \ 101 template <
typename T >
104 typedef typename std::vector<T>::iterator iterator;
105 typedef typename std::vector<T>::const_iterator const_iterator;
106 typedef typename std::vector<T>::reverse_iterator reverse_iterator;
107 typedef typename std::vector<T>::const_reverse_iterator const_reverse_iterator;
108 typedef typename std::vector<T>::size_type size_type;
109 typedef typename std::vector<T>::allocator_type allocator_type;
110 typedef typename std::vector<T>::value_type value_type;
111 typedef T & reference;
112 typedef const T & const_reference;
114 explicit EMVector (
const allocator_type& alloc = allocator_type()) {
115 std::vector<T> v = std::vector<T>(alloc);
119 explicit EMVector (size_type n,
const value_type& val = value_type(),
120 const allocator_type& alloc = allocator_type()) {
121 std::vector<T> v = std::vector<T>(n, val, alloc);
125 template <
class InputIterator>
126 EMVector (InputIterator first, InputIterator last,
127 const allocator_type& alloc = allocator_type()) {
128 std::vector<T> v = std::vector<T>(first, last, alloc);
140 std::lock_guard<std::recursive_mutex> lock(
const_cast<EMVector<T>&
>(v).getMutex());
144 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 146 _vector = std::move(v);
150 std::lock_guard<std::recursive_mutex> lock(v.getMutex());
151 _vector.swap(v._vector);
154 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES 161 _lock_both(*
this, *_v);
166 inline EMVector & operator=(
const std::vector<T> &v) {
167 std::lock_guard<std::recursive_mutex> lock(getMutex());
168 if (&_vector != &v) {
174 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 176 _lock_both(*
this, v);
177 _vector = std::move(v.get());
181 inline EMVector & operator=(std::vector<T> &&v) {
182 std::lock_guard<std::recursive_mutex> lock(getMutex());
183 _vector = std::move(v);
186 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES 188 inline const std::vector<T> &
get()
const {
192 inline std::vector<T> clone()
const {
194 std::lock_guard<std::recursive_mutex> lock(temp->getMutex());
198 #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS 199 _LIBCPP_INLINE_VISIBILITY
200 EMVector(std::initializer_list<value_type> __il) {
203 _LIBCPP_INLINE_VISIBILITY
204 EMVector(std::initializer_list<value_type> __il,
const allocator_type& __a) {
205 _vector = std::vector<value_type>(__il, __a);
207 _LIBCPP_INLINE_VISIBILITY
208 inline EMVector & operator=(std::initializer_list<value_type> &&__il) {
209 std::lock_guard<std::recursive_mutex> lock(getMutex());
210 _vector = std::vector<value_type>(std::forward(__il));
213 #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS 216 inline const T & operator[](size_type n)
const {
218 std::lock_guard<std::recursive_mutex> lock(temp->getMutex());
222 inline void assign(iterator first, iterator last) {
223 std::lock_guard<std::recursive_mutex> lock(getMutex());
224 _vector.assign(first, last);
227 inline void assign(size_type n,
const T &val) {
228 std::lock_guard<std::recursive_mutex> lock(getMutex());
229 _vector.assign(n, val);
232 inline void push_back(
const T &val) {
233 std::lock_guard<std::recursive_mutex> lock(getMutex());
234 _vector.push_back(val);
237 inline void pop_back(
const T &val) {
238 std::lock_guard<std::recursive_mutex> lock(getMutex());
239 _vector.pop_back(val);
242 inline void insert(iterator position, T &val) {
243 std::lock_guard<std::recursive_mutex> lock(getMutex());
244 _vector.insert(position, val);
247 inline void insert (iterator position, size_type n,
const value_type& val) {
248 std::lock_guard<std::recursive_mutex> lock(getMutex());
249 _vector.insert(position, n, val);
252 template <
class InputIterator>
253 inline void insert (iterator position, InputIterator first, InputIterator last) {
254 std::lock_guard<std::recursive_mutex> lock(getMutex());
255 _vector.insert(position, first, last);
258 inline iterator erase(iterator position) {
259 std::lock_guard<std::recursive_mutex> lock(getMutex());
260 return _vector.erase(position);
263 inline iterator erase (iterator first, iterator last) {
264 std::lock_guard<std::recursive_mutex> lock(getMutex());
265 return _vector.erase(first, last);
268 inline void swap(std::vector<T>& x) {
269 std::lock_guard<std::recursive_mutex> lock(getMutex());
274 _lock_both(*
this, x);
278 inline void clear() {
279 std::lock_guard<std::recursive_mutex> lock(getMutex());
284 inline size_type size()
const {
285 return _vector.size();
288 inline size_type max_size()
const {
289 return _vector.max_size();
292 inline void resize (size_type n, value_type val = value_type()) {
293 std::lock_guard<std::recursive_mutex> lock(getMutex());
294 return _vector.resize(n, val);
297 inline size_type capacity()
const {
298 return _vector.capacity();
301 inline bool empty()
const {
302 return _vector.empty();
305 inline void reserve (size_type n) {
306 std::lock_guard<std::recursive_mutex> lock(getMutex());
310 inline void shrink_to_fit() {
311 std::lock_guard<std::recursive_mutex> lock(getMutex());
312 _vector.shrink_to_fit();
316 inline T & operator[](size_type n) {
317 std::lock_guard<std::recursive_mutex> lock(getMutex());
321 inline reference at (size_type n) {
322 std::lock_guard<std::recursive_mutex> lock(getMutex());
326 inline const_reference at (size_type n)
const {
327 std::lock_guard<std::recursive_mutex> lock(getMutex());
331 inline reference front() {
332 std::lock_guard<std::recursive_mutex> lock(getMutex());
333 return _vector.front();
336 inline const_reference front()
const {
337 std::lock_guard<std::recursive_mutex> lock(getMutex());
338 return _vector.front();
341 inline reference back() {
342 std::lock_guard<std::recursive_mutex> lock(getMutex());
343 return _vector.back();
346 inline const_reference back()
const {
347 std::lock_guard<std::recursive_mutex> lock(getMutex());
348 return _vector.back();
356 inline iterator begin() {
357 return _vector.begin();
360 inline const_iterator begin()
const {
361 return _vector.begin();
363 inline iterator end() {
364 return _vector.end();
367 inline const_iterator end()
const {
368 return _vector.end();
371 inline reverse_iterator rbegin() {
372 return _vector.rbegin();
375 inline const_reverse_iterator rbegin()
const {
376 return _vector.rbegin();
379 inline reverse_iterator rend() {
380 return _vector.rend();
383 inline const_reverse_iterator rend()
const {
384 return _vector.rend();
387 inline const_iterator cbegin()
const {
388 return _vector.cbegin();
391 inline const_iterator cend()
const {
392 return _vector.cend();
395 inline const_reverse_iterator crbegin()
const {
396 return _vector.crbegin();
399 inline const_reverse_iterator crend()
const {
400 return _vector.crend();
404 std::vector<T> _vector;
407 template <
class _Key,
class _Tp,
class _Compare = std::less<_Key>,
408 class _Allocator = std::allocator<std::pair<const _Key, _Tp> > >
411 typedef _Key key_type;
412 typedef _Tp mapped_type;
413 typedef typename std::map<_Key, _Tp>::iterator iterator;
414 typedef typename std::map<_Key, _Tp>::const_iterator const_iterator;
415 typedef typename std::map<_Key, _Tp>::reverse_iterator reverse_iterator;
416 typedef typename std::map<_Key, _Tp>::const_reverse_iterator const_reverse_iterator;
417 typedef typename std::map<_Key, _Tp>::size_type size_type;
418 typedef typename std::pair<const _Key, _Tp> value_type;
419 typedef typename std::map<_Key, _Tp>::key_compare key_compare;
420 typedef typename std::map<_Key, _Tp>::allocator_type allocator_type;
422 explicit EMMap (
const key_compare& comp = key_compare(),
423 const allocator_type& alloc = allocator_type()) {
424 std::map<_Key, _Tp> m = std::map<_Key, _Tp>(comp, alloc);
428 template <
class InputIterator>
429 EMMap (InputIterator first, InputIterator last,
430 const key_compare& comp = key_compare(),
431 const allocator_type& alloc = allocator_type()) {
432 std::map<_Key, _Tp> m = std::map<_Key, _Tp>(first, last, comp, alloc);
436 inline EMMap(
const std::map<_Key, _Tp> &v_) {
453 _lock_both(*
this, *_v);
458 inline EMMap & operator=(
const std::map<key_type, mapped_type> &v) {
459 std::lock_guard<std::recursive_mutex> lock(getMutex());
466 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 467 EMMap(std::map<key_type, mapped_type> &&v) {
472 std::lock_guard<std::recursive_mutex> lock(v.getMutex());
473 std::swap(_map, v._map);
478 _lock_both(*
this, v);
479 std::swap(_map, v._map);
484 inline EMMap & operator=(std::map<key_type, mapped_type> &&v) {
485 std::lock_guard<std::recursive_mutex> lock(getMutex());
489 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES 491 inline const std::map<_Key, _Tp> &
get()
const {
495 inline std::map<_Key, _Tp> clone()
const {
497 std::lock_guard<std::recursive_mutex> lock(temp->getMutex());
501 #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS 502 _LIBCPP_INLINE_VISIBILITY
503 EMMap(std::initializer_list<value_type> __il,
const key_compare& __comp = key_compare())
505 _map = std::map<_Key, _Tp>(__comp);
506 _map.insert(__il.begin(), __il.end());
509 _LIBCPP_INLINE_VISIBILITY
510 EMMap(std::initializer_list<value_type> __il,
const key_compare& __comp,
const allocator_type& __a)
512 _map = std::map<_Key, _Tp>(__comp);
513 _map.insert(__il.begin(), __il.end());
516 #if _LIBCPP_STD_VER > 11 517 _LIBCPP_INLINE_VISIBILITY
518 EMMap(std::initializer_list<value_type> __il,
const allocator_type& __a)
519 : _map(__il, key_compare(), __a) {}
522 _LIBCPP_INLINE_VISIBILITY
523 inline EMMap& operator=(std::initializer_list<value_type> __il)
525 _map.insert(__il.begin(), __il.end());
528 #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS 532 inline std::pair<iterator,bool> insert (
const value_type& val) {
533 std::lock_guard<std::recursive_mutex> lock(getMutex());
534 return _map.insert(val);
537 inline iterator insert (iterator position,
const value_type& val) {
538 std::lock_guard<std::recursive_mutex> lock(getMutex());
539 return _map.insert(position, val);
542 inline void insert(const_iterator first, const_iterator last) {
543 std::lock_guard<std::recursive_mutex> lock(getMutex());
544 return _map.insert(first, last);
548 inline iterator erase (iterator position) {
549 std::lock_guard<std::recursive_mutex> lock(getMutex());
550 return _map.erase(position);
553 inline size_type erase(
const key_type& k) {
554 std::lock_guard<std::recursive_mutex> lock(getMutex());
555 return _map.erase(k);
558 inline iterator erase(iterator first, iterator last) {
559 std::lock_guard<std::recursive_mutex> lock(getMutex());
560 return _map.erase(first, last);
563 inline void swap (std::map<_Key, _Tp>& x) {
564 std::lock_guard<std::recursive_mutex> lock(getMutex());
569 _lock_both(*
this, x);
573 inline void clear() {
574 std::lock_guard<std::recursive_mutex> lock(getMutex());
584 inline iterator begin() {
588 inline const_iterator begin()
const {
592 inline iterator end() {
596 inline const_iterator end()
const {
600 inline reverse_iterator rbegin() {
601 return _map.rbegin();
604 inline const_reverse_iterator rbegin()
const {
605 return _map.rbegin();
608 inline reverse_iterator rend() {
612 inline const_reverse_iterator rend()
const {
616 inline const_iterator cbegin()
const {
617 return _map.cbegin();
620 inline const_iterator cend()
const {
624 inline const_reverse_iterator crbegin()
const {
625 return _map.crbegin();
628 inline const_reverse_iterator crend()
const {
633 inline bool empty()
const {
637 inline size_type size()
const {
641 inline size_type max_size()
const {
642 return _map.max_size();
646 inline _Tp & operator[](_Key k) {
650 inline mapped_type& at (
const key_type& k) {
654 inline const mapped_type& at (
const key_type& k)
const {
659 inline iterator find (
const key_type& k) {
660 std::lock_guard<std::recursive_mutex> lock(getMutex());
664 inline const_iterator find (
const key_type& k)
const {
669 inline size_type count (
const key_type& k)
const {
674 inline iterator lower_bound (
const key_type& k) {
675 std::lock_guard<std::recursive_mutex> lock(getMutex());
676 return _map.lower_bound(k);
679 inline const_iterator lower_bound (
const key_type& k)
const {
681 return _map.lower_bound(k);
684 inline iterator upper_bound (
const key_type& k) {
685 std::lock_guard<std::recursive_mutex> lock(getMutex());
686 return _map.upper_bound(k);
689 inline const_iterator upper_bound (
const key_type& k)
const {
691 return _map.upper_bound(k);
694 inline std::pair<const_iterator,const_iterator> equal_range (
const key_type& k)
const {
696 return _map.equal_range(k);
699 inline std::pair<iterator,iterator> equal_range (
const key_type& k) {
700 std::lock_guard<std::recursive_mutex> lock(getMutex());
701 return _map.equal_range(k);
705 std::map<_Key, _Tp> _map;
709 template <
class _Key,
class _Compare = std::less<_Key>,
710 class _Allocator = std::allocator<_Key> >
713 typedef _Key key_type;
714 typedef key_type value_type;
715 typedef typename std::set<_Key>::iterator iterator;
716 typedef typename std::set<_Key>::const_iterator const_iterator;
717 typedef typename std::set<_Key>::reverse_iterator reverse_iterator;
718 typedef typename std::set<_Key>::const_reverse_iterator const_reverse_iterator;
719 typedef _Compare key_compare;
720 typedef key_compare value_compare;
721 typedef _Allocator allocator_type;
722 typedef typename std::set<_Key>::size_type size_type;
724 explicit EMSet (
const key_compare& comp = key_compare(),
725 const allocator_type& alloc = allocator_type()) {
726 std::set<key_type, key_compare, allocator_type> s = std::set<key_type, key_compare, allocator_type>
730 template <
class InputIterator>
731 EMSet (InputIterator first, InputIterator last,
732 const key_compare& comp = key_compare(),
733 const allocator_type& alloc = allocator_type()) {
734 std::set<key_type, key_compare, allocator_type> s = std::set<key_type, key_compare, allocator_type>
735 (first, last, comp, alloc);
738 inline EMSet & operator=(std::set<key_type> &
set) {
746 EMSet(
const std::set<key_type> &v) {
751 std::lock_guard<std::recursive_mutex> lock(
const_cast<EMSet<key_type>&
>(v).getMutex());
758 _lock_both(*
this, *_v);
764 inline EMSet & operator=(
const std::set<key_type> &v) {
765 std::lock_guard<std::recursive_mutex> lock(getMutex());
772 EMSet(std::set<key_type> &v) {
780 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 781 EMSet(std::set<key_type> &&v) {
786 std::lock_guard<std::recursive_mutex> lock(v.getMutex());
787 std::swap(_set, v._set);
792 _lock_both(*
this, v);
793 std::swap(_set, v._set);
798 inline EMSet & operator=(std::set<key_type> &&v) {
799 std::lock_guard<std::recursive_mutex> lock(getMutex());
805 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES 807 inline const std::set<key_type> &
get()
const {
811 inline std::set<key_type> clone()
const {
813 std::lock_guard<std::recursive_mutex> lock(temp->getMutex());
817 #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS 818 _LIBCPP_INLINE_VISIBILITY
819 EMSet(std::initializer_list<value_type> __il,
const value_compare& __comp = value_compare())
821 _set = std::set<key_type>(__comp);
822 _set.insert(__il.begin(), __il.end());
825 _LIBCPP_INLINE_VISIBILITY
826 EMSet(std::initializer_list<value_type> __il,
const value_compare& __comp,
827 const allocator_type& __a)
829 _set = std::set<key_type>(__comp, __a);
830 _set.insert(__il.begin(), __il.end());
833 #if _LIBCPP_STD_VER > 11 834 _LIBCPP_INLINE_VISIBILITY
835 EMSet(std::initializer_list<value_type> __il,
const allocator_type& __a)
837 _set = std::set<key_type>(key_compare(), __a);
838 _set.insert(__il.begin(), __il.end());
842 _LIBCPP_INLINE_VISIBILITY
843 inline EMSet& operator=(std::initializer_list<value_type> __il)
845 _set = std::set<key_type>();
846 _set.insert(__il.begin(), __il.end());
849 #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS 852 inline std::pair<iterator,bool> insert (
const value_type& val) {
853 std::lock_guard<std::recursive_mutex> lock(getMutex());
854 return _set.insert(val);
857 inline iterator insert (iterator position,
const value_type& val) {
858 std::lock_guard<std::recursive_mutex> lock(getMutex());
859 return _set.insert(position, val);
862 template <
class InputIterator>
863 inline void insert (InputIterator first, InputIterator last) {
864 std::lock_guard<std::recursive_mutex> lock(getMutex());
865 return _set.insert(first, last);
869 inline iterator erase (iterator position) {
870 std::lock_guard<std::recursive_mutex> lock(getMutex());
871 return _set.erase(position);
874 inline size_type erase (
const value_type& val) {
875 std::lock_guard<std::recursive_mutex> lock(getMutex());
876 return _set.erase(val);
879 inline iterator erase (iterator first, iterator last) {
880 std::lock_guard<std::recursive_mutex> lock(getMutex());
881 return _set.erase(first, last);
884 inline void swap (std::set<key_type>& x) {
885 std::lock_guard<std::recursive_mutex> lock(getMutex());
890 _lock_both(*
this, x);
894 inline void clear() {
895 std::lock_guard<std::recursive_mutex> lock(getMutex());
900 inline iterator begin() {
904 inline const_iterator begin()
const {
908 inline iterator end() {
912 inline const_iterator end()
const {
916 inline reverse_iterator rbegin() {
917 return _set.rbegin();
920 inline const_reverse_iterator rbegin()
const {
921 return _set.rbegin();
924 inline reverse_iterator rend() {
928 inline const_reverse_iterator rend()
const {
932 inline const_iterator cbegin()
const {
933 return _set.cbegin();
936 inline const_iterator cend()
const {
940 inline const_reverse_iterator crbegin()
const {
941 return _set.crbegin();
944 inline const_reverse_iterator crend()
const {
949 inline bool empty()
const {
953 inline size_type size()
const {
957 inline size_type max_size()
const {
958 return _set.max_size();
962 inline iterator find (
const value_type& val)
const {
963 std::lock_guard<std::recursive_mutex> lock(getMutex());
964 return _set.find(val);
967 inline size_type count (
const value_type& val)
const {
968 std::lock_guard<std::recursive_mutex> lock(getMutex());
969 return _set.count(val);
972 inline iterator lower_bound (
const value_type& val)
const {
973 std::lock_guard<std::recursive_mutex> lock(getMutex());
974 return _set.lower_bound(val);
977 inline iterator upper_bound (
const value_type& val)
const {
978 std::lock_guard<std::recursive_mutex> lock(getMutex());
979 return _set.uppper_bound(val);
982 inline std::pair<iterator,iterator> equal_range (
const value_type& val)
const {
983 std::lock_guard<std::recursive_mutex> lock(getMutex());
984 return _set.equal_range(val);
Definition: emattributevalue.h:28