diff options
Diffstat (limited to 'libstdc++-v3/include/profile')
-rw-r--r-- | libstdc++-v3/include/profile/base.h | 68 | ||||
-rw-r--r-- | libstdc++-v3/include/profile/bitset | 124 | ||||
-rw-r--r-- | libstdc++-v3/include/profile/deque | 171 | ||||
-rw-r--r-- | libstdc++-v3/include/profile/hashtable.h | 1135 | ||||
-rw-r--r-- | libstdc++-v3/include/profile/list | 189 | ||||
-rw-r--r-- | libstdc++-v3/include/profile/map | 42 | ||||
-rw-r--r-- | libstdc++-v3/include/profile/map.h | 178 | ||||
-rw-r--r-- | libstdc++-v3/include/profile/multimap.h | 177 | ||||
-rw-r--r-- | libstdc++-v3/include/profile/multiset.h | 168 | ||||
-rw-r--r-- | libstdc++-v3/include/profile/set | 42 | ||||
-rw-r--r-- | libstdc++-v3/include/profile/set.h | 156 | ||||
-rw-r--r-- | libstdc++-v3/include/profile/unordered_map | 416 | ||||
-rw-r--r-- | libstdc++-v3/include/profile/unordered_set | 374 | ||||
-rw-r--r-- | libstdc++-v3/include/profile/vector | 339 |
14 files changed, 3579 insertions, 0 deletions
diff --git a/libstdc++-v3/include/profile/base.h b/libstdc++-v3/include/profile/base.h new file mode 100644 index 00000000000..7c1f66a8db7 --- /dev/null +++ b/libstdc++-v3/include/profile/base.h @@ -0,0 +1,68 @@ +// -*- C++ -*- + +// Copyright (C) 2007, 2008 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the terms +// of the GNU General Public License as published by the Free Software +// Foundation; either version 2, or (at your option) any later +// version. + +// This library is distributed in the hope that it will be useful, but +// WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this library; see the file COPYING. If not, write to +// the Free Software Foundation, 59 Temple Place - Suite 330, Boston, +// MA 02111-1307, USA. + +// As a special exception, you may use this file as part of a free +// software library without restriction. Specifically, if other files +// instantiate templates or use macros or inline functions from this +// file, or you compile this file and link it with other files to +// produce an executable, this file does not by itself cause the +// resulting executable to be covered by the GNU General Public +// License. This exception does not however invalidate any other +// reasons why the executable file might be covered by the GNU General +// Public License. + +/** @file profile/base.h + * @brief Sequential helper functions. + * This file is a GNU profile extension to the Standard C++ Library. + */ + +// Written by Johannes Singler. + +#ifndef _GLIBCXX_PROFILE_BASE_H +#define _GLIBCXX_PROFILE_BASE_H 1 + +#include <cstdio> +#include <functional> +#include <bits/c++config.h> +#include <profiler.h> + +// Profiling mode namespaces. + +/** + * @namespace std::__profile + * @brief GNU profile code, replaces standard behavior with profile behavior. + */ +namespace std +{ + namespace __profile { } +} + +/** + * @namespace __gnu_profile + * @brief GNU profile code for public use. + */ +namespace __gnu_profile +{ + // Import all the profile versions of components in namespace std. + using namespace std::__profile; +} + + +#endif /* _GLIBCXX_PROFILE_BASE_H */ diff --git a/libstdc++-v3/include/profile/bitset b/libstdc++-v3/include/profile/bitset new file mode 100644 index 00000000000..66c611c1df7 --- /dev/null +++ b/libstdc++-v3/include/profile/bitset @@ -0,0 +1,124 @@ +// Profiling bitset implementation -*- C++ -*- + +// Copyright (C) 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +/** @file profile/bitset + * This file is a GNU profile extension to the Standard C++ Library. + */ + +#ifndef _GLIBCXX_PROFILE_BITSET +#define _GLIBCXX_PROFILE_BITSET + +#include <bitset> + +namespace std +{ +namespace __profile +{ + template<size_t _Nb> + class bitset + : public _GLIBCXX_STD_PR::bitset<_Nb> + { + typedef _GLIBCXX_STD_PR::bitset<_Nb> _Base; + + public: + bitset() : _Base() { } + + bitset(unsigned long __val) : _Base(__val) { } + + template<typename _CharT, typename _Traits, typename _Allocator> + explicit + bitset(const std::basic_string<_CharT,_Traits,_Allocator>& __str, + typename std::basic_string<_CharT,_Traits,_Allocator>::size_type + __pos = 0, + typename std::basic_string<_CharT,_Traits,_Allocator>::size_type + __n = (std::basic_string<_CharT,_Traits,_Allocator>::npos)) + : _Base(__str, __pos, __n) { } + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 778. std::bitset does not have any constructor taking a string literal + explicit + bitset(const char* __s) + : _Base(__s) { } + + bitset(const _Base& __x) : _Base(__x) { } + + bool + operator==(const bitset<_Nb>& __rhs) const + { return _M_base() == __rhs; } + + bool + operator!=(const bitset<_Nb>& __rhs) const + { return _M_base() != __rhs; } + + bitset<_Nb> + operator<<(size_t __pos) const + { return bitset<_Nb>(_M_base() << __pos); } + + bitset<_Nb> + operator>>(size_t __pos) const + { return bitset<_Nb>(_M_base() >> __pos); } + + _Base& + _M_base() { return *this; } + + const _Base& + _M_base() const { return *this; } + + }; + + template<size_t _Nb> + bitset<_Nb> + operator&(const bitset<_Nb>& __x, const bitset<_Nb>& __y) + { return bitset<_Nb>(__x) &= __y; } + + template<size_t _Nb> + bitset<_Nb> + operator|(const bitset<_Nb>& __x, const bitset<_Nb>& __y) + { return bitset<_Nb>(__x) |= __y; } + + template<size_t _Nb> + bitset<_Nb> + operator^(const bitset<_Nb>& __x, const bitset<_Nb>& __y) + { return bitset<_Nb>(__x) ^= __y; } + + template<typename _CharT, typename _Traits, size_t _Nb> + std::basic_istream<_CharT, _Traits>& + operator>>(std::basic_istream<_CharT, _Traits>& __is, bitset<_Nb>& __x) + { return __is >> __x._M_base(); } + + template<typename _CharT, typename _Traits, size_t _Nb> + std::basic_ostream<_CharT, _Traits>& + operator<<(std::basic_ostream<_CharT, _Traits>& __os, + const bitset<_Nb>& __x) + { return __os << __x._M_base(); } + +} // namespace __profile +} // namespace std + +#endif diff --git a/libstdc++-v3/include/profile/deque b/libstdc++-v3/include/profile/deque new file mode 100644 index 00000000000..4b0c3b4bfb3 --- /dev/null +++ b/libstdc++-v3/include/profile/deque @@ -0,0 +1,171 @@ +// Profiling deque implementation -*- C++ -*- + +// Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 +// Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +/** @file profile/deque + * This file is a GNU profile extension to the Standard C++ Library. + */ + +#ifndef _GLIBCXX_PROFILE_DEQUE +#define _GLIBCXX_PROFILE_DEQUE 1 + +#include <deque> + +namespace std +{ +namespace __profile +{ + template<typename _Tp, typename _Allocator = std::allocator<_Tp> > + class deque + : public _GLIBCXX_STD_PR::deque<_Tp, _Allocator> + { + typedef _GLIBCXX_STD_D::deque<_Tp, _Allocator> _Base; + + public: + typedef typename _Base::size_type size_type; + // 23.2.1.1 construct/copy/destroy: + explicit deque(const _Allocator& __a = _Allocator()) + : _Base(__a) { } + + explicit deque(size_type __n, const _Tp& __value = _Tp(), + const _Allocator& __a = _Allocator()) + : _Base(__n, __value, __a) { } + + template<class _InputIterator> + deque(_InputIterator __first, _InputIterator __last, + const _Allocator& __a = _Allocator()) + : _Base(__first, __last, __a) + { } + + deque(const deque& __x) + : _Base(__x) { } + + deque(const _Base& __x) + : _Base(__x) { } + +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + deque(deque&& __x) + : _Base(std::forward<deque>(__x)) + { } +#endif + + ~deque() { } + + void +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + swap(deque&& __x) +#else + swap(deque& __x) +#endif + { + _Base::swap(__x); + } + + deque& + operator=(const deque& __x) + { + *static_cast<_Base*>(this) = __x; + return *this; + } + +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + deque& + operator=(deque&& __x) + { + _Base::clear(); + swap(__x); + return *this; + } +#endif + + _Base& + _M_base() { return *this; } + + const _Base& + _M_base() const { return *this; } + + }; + + template<typename _Tp, typename _Alloc> + inline bool + operator==(const deque<_Tp, _Alloc>& __lhs, + const deque<_Tp, _Alloc>& __rhs) + { return __lhs._M_base() == __rhs._M_base(); } + + template<typename _Tp, typename _Alloc> + inline bool + operator!=(const deque<_Tp, _Alloc>& __lhs, + const deque<_Tp, _Alloc>& __rhs) + { return __lhs._M_base() != __rhs._M_base(); } + + template<typename _Tp, typename _Alloc> + inline bool + operator<(const deque<_Tp, _Alloc>& __lhs, + const deque<_Tp, _Alloc>& __rhs) + { return __lhs._M_base() < __rhs._M_base(); } + + template<typename _Tp, typename _Alloc> + inline bool + operator<=(const deque<_Tp, _Alloc>& __lhs, + const deque<_Tp, _Alloc>& __rhs) + { return __lhs._M_base() <= __rhs._M_base(); } + + template<typename _Tp, typename _Alloc> + inline bool + operator>=(const deque<_Tp, _Alloc>& __lhs, + const deque<_Tp, _Alloc>& __rhs) + { return __lhs._M_base() >= __rhs._M_base(); } + + template<typename _Tp, typename _Alloc> + inline bool + operator>(const deque<_Tp, _Alloc>& __lhs, + const deque<_Tp, _Alloc>& __rhs) + { return __lhs._M_base() > __rhs._M_base(); } + + template<typename _Tp, typename _Alloc> + inline void + swap(deque<_Tp, _Alloc>& __lhs, deque<_Tp, _Alloc>& __rhs) + { __lhs.swap(__rhs); } + +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + template<typename _Tp, typename _Alloc> + inline void + swap(deque<_Tp, _Alloc>&& __lhs, deque<_Tp, _Alloc>& __rhs) + { __lhs.swap(__rhs); } + + template<typename _Tp, typename _Alloc> + inline void + swap(deque<_Tp, _Alloc>& __lhs, deque<_Tp, _Alloc>&& __rhs) + { __lhs.swap(__rhs); } +#endif + +} // namespace __profile +} // namespace std + +#endif diff --git a/libstdc++-v3/include/profile/hashtable.h b/libstdc++-v3/include/profile/hashtable.h new file mode 100644 index 00000000000..35e4d06dc22 --- /dev/null +++ b/libstdc++-v3/include/profile/hashtable.h @@ -0,0 +1,1135 @@ +// Hashtable implementation used by containers -*- C++ -*- + +// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007 +// Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +/* + * Copyright (c) 1996,1997 + * Silicon Graphics Computer Systems, Inc. + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Silicon Graphics makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Hewlett-Packard Company makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + */ + +/** @file profile/hashtable.h copied from backward/hashtable.h + * This file is a GNU extension to the Standard C++ Library (possibly + * containing extensions from the HP/SGI STL subset). + */ + +#ifndef _HASHTABLE_H +#define _HASHTABLE_H 1 + +// Hashtable class, used to implement the hashed associative containers +// hash_set, hash_map, hash_multiset, and hash_multimap. +// Skip instrumentation on vector. +#include <vector> +#include <iterator> +#include <algorithm> +#include <bits/stl_function.h> +#include <backward/hash_fun.h> +#include <profiler.h> + +_GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx) + + using std::size_t; + using std::ptrdiff_t; + using std::forward_iterator_tag; + using std::input_iterator_tag; + using std::_Construct; + using std::_Destroy; + using std::distance; + using std::_GLIBCXX_STD_D::vector; + using std::pair; + using std::__iterator_category; + + template<class _Val> + struct _Hashtable_node + { + _Hashtable_node* _M_next; + _Val _M_val; + }; + + template<class _Val, class _Key, class _HashFcn, class _ExtractKey, + class _EqualKey, class _Alloc = std::allocator<_Val> > + class hashtable; + + template<class _Val, class _Key, class _HashFcn, + class _ExtractKey, class _EqualKey, class _Alloc> + struct _Hashtable_iterator; + + template<class _Val, class _Key, class _HashFcn, + class _ExtractKey, class _EqualKey, class _Alloc> + struct _Hashtable_const_iterator; + + template<class _Val, class _Key, class _HashFcn, + class _ExtractKey, class _EqualKey, class _Alloc> + struct _Hashtable_iterator + { + typedef hashtable<_Val, _Key, _HashFcn, _ExtractKey, _EqualKey, _Alloc> + _Hashtable; + typedef _Hashtable_iterator<_Val, _Key, _HashFcn, + _ExtractKey, _EqualKey, _Alloc> + iterator; + typedef _Hashtable_const_iterator<_Val, _Key, _HashFcn, + _ExtractKey, _EqualKey, _Alloc> + const_iterator; + typedef _Hashtable_node<_Val> _Node; + typedef forward_iterator_tag iterator_category; + typedef _Val value_type; + typedef ptrdiff_t difference_type; + typedef size_t size_type; + typedef _Val& reference; + typedef _Val* pointer; + + _Node* _M_cur; + _Hashtable* _M_ht; + + _Hashtable_iterator(_Node* __n, _Hashtable* __tab) + : _M_cur(__n), _M_ht(__tab) { } + + _Hashtable_iterator() { } + + reference + operator*() const + { return _M_cur->_M_val; } + + pointer + operator->() const + { return &(operator*()); } + + iterator& + operator++(); + + iterator + operator++(int); + + bool + operator==(const iterator& __it) const + { return _M_cur == __it._M_cur; } + + bool + operator!=(const iterator& __it) const + { return _M_cur != __it._M_cur; } + }; + + template<class _Val, class _Key, class _HashFcn, + class _ExtractKey, class _EqualKey, class _Alloc> + struct _Hashtable_const_iterator + { + typedef hashtable<_Val, _Key, _HashFcn, _ExtractKey, _EqualKey, _Alloc> + _Hashtable; + typedef _Hashtable_iterator<_Val,_Key,_HashFcn, + _ExtractKey,_EqualKey,_Alloc> + iterator; + typedef _Hashtable_const_iterator<_Val, _Key, _HashFcn, + _ExtractKey, _EqualKey, _Alloc> + const_iterator; + typedef _Hashtable_node<_Val> _Node; + + typedef forward_iterator_tag iterator_category; + typedef _Val value_type; + typedef ptrdiff_t difference_type; + typedef size_t size_type; + typedef const _Val& reference; + typedef const _Val* pointer; + + const _Node* _M_cur; + const _Hashtable* _M_ht; + + _Hashtable_const_iterator(const _Node* __n, const _Hashtable* __tab) + : _M_cur(__n), _M_ht(__tab) { } + + _Hashtable_const_iterator() { } + + _Hashtable_const_iterator(const iterator& __it) + : _M_cur(__it._M_cur), _M_ht(__it._M_ht) { } + + reference + operator*() const + { return _M_cur->_M_val; } + + pointer + operator->() const + { return &(operator*()); } + + const_iterator& + operator++(); + + const_iterator + operator++(int); + + bool + operator==(const const_iterator& __it) const + { return _M_cur == __it._M_cur; } + + bool + operator!=(const const_iterator& __it) const + { return _M_cur != __it._M_cur; } + }; + + // Note: assumes long is at least 32 bits. + enum { _S_num_primes = 28 }; + + static const unsigned long __stl_prime_list[_S_num_primes] = + { + 53ul, 97ul, 193ul, 389ul, 769ul, + 1543ul, 3079ul, 6151ul, 12289ul, 24593ul, + 49157ul, 98317ul, 196613ul, 393241ul, 786433ul, + 1572869ul, 3145739ul, 6291469ul, 12582917ul, 25165843ul, + 50331653ul, 100663319ul, 201326611ul, 402653189ul, 805306457ul, + 1610612741ul, 3221225473ul, 4294967291ul + }; + + inline unsigned long + __stl_next_prime(unsigned long __n) + { + const unsigned long* __first = __stl_prime_list; + const unsigned long* __last = __stl_prime_list + (int)_S_num_primes; + const unsigned long* pos = std::lower_bound(__first, __last, __n); + return pos == __last ? *(__last - 1) : *pos; + } + + // Forward declaration of operator==. + template<class _Val, class _Key, class _HF, class _Ex, + class _Eq, class _All> + class hashtable; + + template<class _Val, class _Key, class _HF, class _Ex, + class _Eq, class _All> + bool + operator==(const hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>& __ht1, + const hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>& __ht2); + + // Hashtables handle allocators a bit differently than other + // containers do. If we're using standard-conforming allocators, then + // a hashtable unconditionally has a member variable to hold its + // allocator, even if it so happens that all instances of the + // allocator type are identical. This is because, for hashtables, + // this extra storage is negligible. Additionally, a base class + // wouldn't serve any other purposes; it wouldn't, for example, + // simplify the exception-handling code. + template<class _Val, class _Key, class _HashFcn, + class _ExtractKey, class _EqualKey, class _Alloc> + class hashtable + { + public: + typedef _Key key_type; + typedef _Val value_type; + typedef _HashFcn hasher; + typedef _EqualKey key_equal; + + typedef size_t size_type; + typedef ptrdiff_t difference_type; + typedef value_type* pointer; + typedef const value_type* const_pointer; + typedef value_type& reference; + typedef const value_type& const_reference; + + hasher + hash_funct() const + { return _M_hash; } + + key_equal + key_eq() const + { return _M_equals; } + + private: + typedef _Hashtable_node<_Val> _Node; + + public: + typedef typename _Alloc::template rebind<value_type>::other allocator_type; + allocator_type + get_allocator() const + { return _M_node_allocator; } + + private: + typedef typename _Alloc::template rebind<_Node>::other _Node_Alloc; + typedef typename _Alloc::template rebind<_Node*>::other _Nodeptr_Alloc; + typedef vector<_Node*, _Nodeptr_Alloc> _Vector_type; + + _Node_Alloc _M_node_allocator; + + _Node* + _M_get_node() + { return _M_node_allocator.allocate(1); } + + void + _M_put_node(_Node* __p) + { _M_node_allocator.deallocate(__p, 1); } + + private: + hasher _M_hash; + key_equal _M_equals; + _ExtractKey _M_get_key; + _Vector_type _M_buckets; + size_type _M_num_elements; + + public: + typedef _Hashtable_iterator<_Val, _Key, _HashFcn, _ExtractKey, + _EqualKey, _Alloc> + iterator; + typedef _Hashtable_const_iterator<_Val, _Key, _HashFcn, _ExtractKey, + _EqualKey, _Alloc> + const_iterator; + + friend struct + _Hashtable_iterator<_Val, _Key, _HashFcn, _ExtractKey, _EqualKey, _Alloc>; + + friend struct + _Hashtable_const_iterator<_Val, _Key, _HashFcn, _ExtractKey, + _EqualKey, _Alloc>; + + public: + hashtable(size_type __n, const _HashFcn& __hf, + const _EqualKey& __eql, const _ExtractKey& __ext, + const allocator_type& __a = allocator_type()) + : _M_node_allocator(__a), _M_hash(__hf), _M_equals(__eql), + _M_get_key(__ext), _M_buckets(__a), _M_num_elements(0) + { _M_initialize_buckets(__n); } + + hashtable(size_type __n, const _HashFcn& __hf, + const _EqualKey& __eql, + const allocator_type& __a = allocator_type()) + : _M_node_allocator(__a), _M_hash(__hf), _M_equals(__eql), + _M_get_key(_ExtractKey()), _M_buckets(__a), _M_num_elements(0) + { _M_initialize_buckets(__n); } + + hashtable(const hashtable& __ht) + : _M_node_allocator(__ht.get_allocator()), _M_hash(__ht._M_hash), + _M_equals(__ht._M_equals), _M_get_key(__ht._M_get_key), + _M_buckets(__ht.get_allocator()), _M_num_elements(0) + { _M_copy_from(__ht); } + + hashtable& + operator= (const hashtable& __ht) + { + if (&__ht != this) + { + clear(); + _M_hash = __ht._M_hash; + _M_equals = __ht._M_equals; + _M_get_key = __ht._M_get_key; + _M_copy_from(__ht); + } + return *this; + } + + ~hashtable() + { clear(); } + + size_type + size() const + { return _M_num_elements; } + + size_type + max_size() const + { return size_type(-1); } + + bool + empty() const + { return size() == 0; } + + void + swap(hashtable& __ht) + { + std::swap(_M_hash, __ht._M_hash); + std::swap(_M_equals, __ht._M_equals); + std::swap(_M_get_key, __ht._M_get_key); + _M_buckets.swap(__ht._M_buckets); + std::swap(_M_num_elements, __ht._M_num_elements); + } + + iterator + begin() + { + for (size_type __n = 0; __n < _M_buckets.size(); ++__n) + if (_M_buckets[__n]) + return iterator(_M_buckets[__n], this); + return end(); + } + + iterator + end() + { return iterator(0, this); } + + const_iterator + begin() const + { + for (size_type __n = 0; __n < _M_buckets.size(); ++__n) + if (_M_buckets[__n]) + return const_iterator(_M_buckets[__n], this); + return end(); + } + + const_iterator + end() const + { return const_iterator(0, this); } + + template<class _Vl, class _Ky, class _HF, class _Ex, class _Eq, + class _Al> + friend bool + operator==(const hashtable<_Vl, _Ky, _HF, _Ex, _Eq, _Al>&, + const hashtable<_Vl, _Ky, _HF, _Ex, _Eq, _Al>&); + + public: + size_type + bucket_count() const + { return _M_buckets.size(); } + + size_type + max_bucket_count() const + { return __stl_prime_list[(int)_S_num_primes - 1]; } + + size_type + elems_in_bucket(size_type __bucket) const + { + size_type __result = 0; + for (_Node* __n = _M_buckets[__bucket]; __n; __n = __n->_M_next) + __result += 1; + return __result; + } + + pair<iterator, bool> + insert_unique(const value_type& __obj) + { + resize(_M_num_elements + 1); + return insert_unique_noresize(__obj); + } + + iterator + insert_equal(const value_type& __obj) + { + resize(_M_num_elements + 1); + return insert_equal_noresize(__obj); + } + + pair<iterator, bool> + insert_unique_noresize(const value_type& __obj); + + iterator + insert_equal_noresize(const value_type& __obj); + + template<class _InputIterator> + void + insert_unique(_InputIterator __f, _InputIterator __l) + { insert_unique(__f, __l, __iterator_category(__f)); } + + template<class _InputIterator> + void + insert_equal(_InputIterator __f, _InputIterator __l) + { insert_equal(__f, __l, __iterator_category(__f)); } + + template<class _InputIterator> + void + insert_unique(_InputIterator __f, _InputIterator __l, + input_iterator_tag) + { + for ( ; __f != __l; ++__f) + insert_unique(*__f); + } + + template<class _InputIterator> + void + insert_equal(_InputIterator __f, _InputIterator __l, + input_iterator_tag) + { + for ( ; __f != __l; ++__f) + insert_equal(*__f); + } + + template<class _ForwardIterator> + void + insert_unique(_ForwardIterator __f, _ForwardIterator __l, + forward_iterator_tag) + { + size_type __n = distance(__f, __l); + resize(_M_num_elements + __n); + for ( ; __n > 0; --__n, ++__f) + insert_unique_noresize(*__f); + } + + template<class _ForwardIterator> + void + insert_equal(_ForwardIterator __f, _ForwardIterator __l, + forward_iterator_tag) + { + size_type __n = distance(__f, __l); + resize(_M_num_elements + __n); + for ( ; __n > 0; --__n, ++__f) + insert_equal_noresize(*__f); + } + + reference + find_or_insert(const value_type& __obj); + + iterator + find(const key_type& __key) + { + size_type __n = _M_bkt_num_key(__key); + _Node* __first; + for (__first = _M_buckets[__n]; + __first && !_M_equals(_M_get_key(__first->_M_val), __key); + __first = __first->_M_next) + { } + return iterator(__first, this); + } + + const_iterator + find(const key_type& __key) const + { + size_type __n = _M_bkt_num_key(__key); + const _Node* __first; + for (__first = _M_buckets[__n]; + __first && !_M_equals(_M_get_key(__first->_M_val), __key); + __first = __first->_M_next) + { } + return const_iterator(__first, this); + } + + size_type + count(const key_type& __key) const + { + const size_type __n = _M_bkt_num_key(__key); + size_type __result = 0; + + for (const _Node* __cur = _M_buckets[__n]; __cur; + __cur = __cur->_M_next) + if (_M_equals(_M_get_key(__cur->_M_val), __key)) + ++__result; + return __result; + } + + pair<iterator, iterator> + equal_range(const key_type& __key); + + pair<const_iterator, const_iterator> + equal_range(const key_type& __key) const; + + size_type + erase(const key_type& __key); + + void + erase(const iterator& __it); + + void + erase(iterator __first, iterator __last); + + void + erase(const const_iterator& __it); + + void + erase(const_iterator __first, const_iterator __last); + + void + resize(size_type __num_elements_hint); + + void + clear(); + + private: + size_type + _M_next_size(size_type __n) const + { return __stl_next_prime(__n); } + + void + _M_initialize_buckets(size_type __n) + { + const size_type __n_buckets = _M_next_size(__n); + _M_buckets.reserve(__n_buckets); + _M_buckets.insert(_M_buckets.end(), __n_buckets, (_Node*) 0); + _M_num_elements = 0; + __profcxx_hashtable_construct(this, __n_buckets); + } + + size_type + _M_bkt_num_key(const key_type& __key) const + { return _M_bkt_num_key(__key, _M_buckets.size()); } + + size_type + _M_bkt_num(const value_type& __obj) const + { return _M_bkt_num_key(_M_get_key(__obj)); } + + size_type + _M_bkt_num_key(const key_type& __key, size_t __n) const + { return _M_hash(__key) % __n; } + + size_type + _M_bkt_num(const value_type& __obj, size_t __n) const + { return _M_bkt_num_key(_M_get_key(__obj), __n); } + + _Node* + _M_new_node(const value_type& __obj) + { + _Node* __n = _M_get_node(); + __n->_M_next = 0; + try + { + this->get_allocator().construct(&__n->_M_val, __obj); + return __n; + } + catch(...) + { + _M_put_node(__n); + __throw_exception_again; + } + } + + void + _M_delete_node(_Node* __n) + { + this->get_allocator().destroy(&__n->_M_val); + _M_put_node(__n); + } + + void + _M_erase_bucket(const size_type __n, _Node* __first, _Node* __last); + + void + _M_erase_bucket(const size_type __n, _Node* __last); + + void + _M_copy_from(const hashtable& __ht); + }; + + template<class _Val, class _Key, class _HF, class _ExK, class _EqK, + class _All> + _Hashtable_iterator<_Val, _Key, _HF, _ExK, _EqK, _All>& + _Hashtable_iterator<_Val, _Key, _HF, _ExK, _EqK, _All>:: + operator++() + { + const _Node* __old = _M_cur; + _M_cur = _M_cur->_M_next; + if (!_M_cur) + { + size_type __bucket = _M_ht->_M_bkt_num(__old->_M_val); + while (!_M_cur && ++__bucket < _M_ht->_M_buckets.size()) + _M_cur = _M_ht->_M_buckets[__bucket]; + } + return *this; + } + + template<class _Val, class _Key, class _HF, class _ExK, class _EqK, + class _All> + inline _Hashtable_iterator<_Val, _Key, _HF, _ExK, _EqK, _All> + _Hashtable_iterator<_Val, _Key, _HF, _ExK, _EqK, _All>:: + operator++(int) + { + iterator __tmp = *this; + ++*this; + return __tmp; + } + + template<class _Val, class _Key, class _HF, class _ExK, class _EqK, + class _All> + _Hashtable_const_iterator<_Val, _Key, _HF, _ExK, _EqK, _All>& + _Hashtable_const_iterator<_Val, _Key, _HF, _ExK, _EqK, _All>:: + operator++() + { + const _Node* __old = _M_cur; + _M_cur = _M_cur->_M_next; + if (!_M_cur) + { + size_type __bucket = _M_ht->_M_bkt_num(__old->_M_val); + while (!_M_cur && ++__bucket < _M_ht->_M_buckets.size()) + _M_cur = _M_ht->_M_buckets[__bucket]; + } + return *this; + } + + template<class _Val, class _Key, class _HF, class _ExK, class _EqK, + class _All> + inline _Hashtable_const_iterator<_Val, _Key, _HF, _ExK, _EqK, _All> + _Hashtable_const_iterator<_Val, _Key, _HF, _ExK, _EqK, _All>:: + operator++(int) + { + const_iterator __tmp = *this; + ++*this; + return __tmp; + } + + template<class _Val, class _Key, class _HF, class _Ex, class _Eq, class _All> + bool + operator==(const hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>& __ht1, + const hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>& __ht2) + { + typedef typename hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>::_Node _Node; + + if (__ht1._M_buckets.size() != __ht2._M_buckets.size()) + return false; + + for (size_t __n = 0; __n < __ht1._M_buckets.size(); ++__n) + { + _Node* __cur1 = __ht1._M_buckets[__n]; + _Node* __cur2 = __ht2._M_buckets[__n]; + // Check same length of lists + for (; __cur1 && __cur2; + __cur1 = __cur1->_M_next, __cur2 = __cur2->_M_next) + { } + if (__cur1 || __cur2) + return false; + // Now check one's elements are in the other + for (__cur1 = __ht1._M_buckets[__n] ; __cur1; + __cur1 = __cur1->_M_next) + { + bool _found__cur1 = false; + for (__cur2 = __ht2._M_buckets[__n]; + __cur2; __cur2 = __cur2->_M_next) + { + if (__cur1->_M_val == __cur2->_M_val) + { + _found__cur1 = true; + break; + } + } + if (!_found__cur1) + return false; + } + } + return true; + } + + template<class _Val, class _Key, class _HF, class _Ex, class _Eq, class _All> + inline bool + operator!=(const hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>& __ht1, + const hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>& __ht2) + { return !(__ht1 == __ht2); } + + template<class _Val, class _Key, class _HF, class _Extract, class _EqKey, + class _All> + inline void + swap(hashtable<_Val, _Key, _HF, _Extract, _EqKey, _All>& __ht1, + hashtable<_Val, _Key, _HF, _Extract, _EqKey, _All>& __ht2) + { __ht1.swap(__ht2); } + + template<class _Val, class _Key, class _HF, class _Ex, class _Eq, class _All> + pair<typename hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>::iterator, bool> + hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>:: + insert_unique_noresize(const value_type& __obj) + { + const size_type __n = _M_bkt_num(__obj); + _Node* __first = _M_buckets[__n]; + + for (_Node* __cur = __first; __cur; __cur = __cur->_M_next) + if (_M_equals(_M_get_key(__cur->_M_val), _M_get_key(__obj))) + return pair<iterator, bool>(iterator(__cur, this), false); + + _Node* __tmp = _M_new_node(__obj); + __tmp->_M_next = __first; + _M_buckets[__n] = __tmp; + ++_M_num_elements; + return pair<iterator, bool>(iterator(__tmp, this), true); + } + + template<class _Val, class _Key, class _HF, class _Ex, class _Eq, class _All> + typename hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>::iterator + hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>:: + insert_equal_noresize(const value_type& __obj) + { + const size_type __n = _M_bkt_num(__obj); + _Node* __first = _M_buckets[__n]; + + for (_Node* __cur = __first; __cur; __cur = __cur->_M_next) + if (_M_equals(_M_get_key(__cur->_M_val), _M_get_key(__obj))) + { + _Node* __tmp = _M_new_node(__obj); + __tmp->_M_next = __cur->_M_next; + __cur->_M_next = __tmp; + ++_M_num_elements; + return iterator(__tmp, this); + } + + _Node* __tmp = _M_new_node(__obj); + __tmp->_M_next = __first; + _M_buckets[__n] = __tmp; + ++_M_num_elements; + return iterator(__tmp, this); + } + + template<class _Val, class _Key, class _HF, class _Ex, class _Eq, class _All> + typename hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>::reference + hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>:: + find_or_insert(const value_type& __obj) + { + resize(_M_num_elements + 1); + + size_type __n = _M_bkt_num(__obj); + _Node* __first = _M_buckets[__n]; + + for (_Node* __cur = __first; __cur; __cur = __cur->_M_next) + if (_M_equals(_M_get_key(__cur->_M_val), _M_get_key(__obj))) + return __cur->_M_val; + + _Node* __tmp = _M_new_node(__obj); + __tmp->_M_next = __first; + _M_buckets[__n] = __tmp; + ++_M_num_elements; + return __tmp->_M_val; + } + + template<class _Val, class _Key, class _HF, class _Ex, class _Eq, class _All> + pair<typename hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>::iterator, + typename hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>::iterator> + hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>:: + equal_range(const key_type& __key) + { + typedef pair<iterator, iterator> _Pii; + const size_type __n = _M_bkt_num_key(__key); + + for (_Node* __first = _M_buckets[__n]; __first; + __first = __first->_M_next) + if (_M_equals(_M_get_key(__first->_M_val), __key)) + { + for (_Node* __cur = __first->_M_next; __cur; + __cur = __cur->_M_next) + if (!_M_equals(_M_get_key(__cur->_M_val), __key)) + return _Pii(iterator(__first, this), iterator(__cur, this)); + for (size_type __m = __n + 1; __m < _M_buckets.size(); ++__m) + if (_M_buckets[__m]) + return _Pii(iterator(__first, this), + iterator(_M_buckets[__m], this)); + return _Pii(iterator(__first, this), end()); + } + return _Pii(end(), end()); + } + + template<class _Val, class _Key, class _HF, class _Ex, class _Eq, class _All> + pair<typename hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>::const_iterator, + typename hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>::const_iterator> + hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>:: + equal_range(const key_type& __key) const + { + typedef pair<const_iterator, const_iterator> _Pii; + const size_type __n = _M_bkt_num_key(__key); + + for (const _Node* __first = _M_buckets[__n]; __first; + __first = __first->_M_next) + { + if (_M_equals(_M_get_key(__first->_M_val), __key)) + { + for (const _Node* __cur = __first->_M_next; __cur; + __cur = __cur->_M_next) + if (!_M_equals(_M_get_key(__cur->_M_val), __key)) + return _Pii(const_iterator(__first, this), + const_iterator(__cur, this)); + for (size_type __m = __n + 1; __m < _M_buckets.size(); ++__m) + if (_M_buckets[__m]) + return _Pii(const_iterator(__first, this), + const_iterator(_M_buckets[__m], this)); + return _Pii(const_iterator(__first, this), end()); + } + } + return _Pii(end(), end()); + } + + template<class _Val, class _Key, class _HF, class _Ex, class _Eq, class _All> + typename hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>::size_type + hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>:: + erase(const key_type& __key) + { + const size_type __n = _M_bkt_num_key(__key); + _Node* __first = _M_buckets[__n]; + size_type __erased = 0; + + if (__first) + { + _Node* __cur = __first; + _Node* __next = __cur->_M_next; + while (__next) + { + if (_M_equals(_M_get_key(__next->_M_val), __key)) + { + __cur->_M_next = __next->_M_next; + _M_delete_node(__next); + __next = __cur->_M_next; + ++__erased; + --_M_num_elements; + } + else + { + __cur = __next; + __next = __cur->_M_next; + } + } + if (_M_equals(_M_get_key(__first->_M_val), __key)) + { + _M_buckets[__n] = __first->_M_next; + _M_delete_node(__first); + ++__erased; + --_M_num_elements; + } + } + return __erased; + } + + template<class _Val, class _Key, class _HF, class _Ex, class _Eq, class _All> + void hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>:: + erase(const iterator& __it) + { + _Node* __p = __it._M_cur; + if (__p) + { + const size_type __n = _M_bkt_num(__p->_M_val); + _Node* __cur = _M_buckets[__n]; + + if (__cur == __p) + { + _M_buckets[__n] = __cur->_M_next; + _M_delete_node(__cur); + --_M_num_elements; + } + else + { + _Node* __next = __cur->_M_next; + while (__next) + { + if (__next == __p) + { + __cur->_M_next = __next->_M_next; + _M_delete_node(__next); + --_M_num_elements; + break; + } + else + { + __cur = __next; + __next = __cur->_M_next; + } + } + } + } + } + + template<class _Val, class _Key, class _HF, class _Ex, class _Eq, class _All> + void + hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>:: + erase(iterator __first, iterator __last) + { + size_type __f_bucket = __first._M_cur ? _M_bkt_num(__first._M_cur->_M_val) + : _M_buckets.size(); + + size_type __l_bucket = __last._M_cur ? _M_bkt_num(__last._M_cur->_M_val) + : _M_buckets.size(); + + if (__first._M_cur == __last._M_cur) + return; + else if (__f_bucket == __l_bucket) + _M_erase_bucket(__f_bucket, __first._M_cur, __last._M_cur); + else + { + _M_erase_bucket(__f_bucket, __first._M_cur, 0); + for (size_type __n = __f_bucket + 1; __n < __l_bucket; ++__n) + _M_erase_bucket(__n, 0); + if (__l_bucket != _M_buckets.size()) + _M_erase_bucket(__l_bucket, __last._M_cur); + } + } + + template<class _Val, class _Key, class _HF, class _Ex, class _Eq, class _All> + inline void + hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>:: + erase(const_iterator __first, const_iterator __last) + { + erase(iterator(const_cast<_Node*>(__first._M_cur), + const_cast<hashtable*>(__first._M_ht)), + iterator(const_cast<_Node*>(__last._M_cur), + const_cast<hashtable*>(__last._M_ht))); + } + + template<class _Val, class _Key, class _HF, class _Ex, class _Eq, class _All> + inline void + hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>:: + erase(const const_iterator& __it) + { erase(iterator(const_cast<_Node*>(__it._M_cur), + const_cast<hashtable*>(__it._M_ht))); } + + template<class _Val, class _Key, class _HF, class _Ex, class _Eq, class _All> + void + hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>:: + resize(size_type __num_elements_hint) + { + const size_type __old_n = _M_buckets.size(); + if (__num_elements_hint > __old_n) + { + const size_type __n = _M_next_size(__num_elements_hint); + if (__n > __old_n) + { + _Vector_type __tmp(__n, (_Node*)(0), _M_buckets.get_allocator()); + try + { + for (size_type __bucket = 0; __bucket < __old_n; ++__bucket) + { + _Node* __first = _M_buckets[__bucket]; + while (__first) + { + size_type __new_bucket = _M_bkt_num(__first->_M_val, + __n); + _M_buckets[__bucket] = __first->_M_next; + __first->_M_next = __tmp[__new_bucket]; + __tmp[__new_bucket] = __first; + __first = _M_buckets[__bucket]; + } + } + _M_buckets.swap(__tmp); + } + catch(...) + { + for (size_type __bucket = 0; __bucket < __tmp.size(); + ++__bucket) + { + while (__tmp[__bucket]) + { + _Node* __next = __tmp[__bucket]->_M_next; + _M_delete_node(__tmp[__bucket]); + __tmp[__bucket] = __next; + } + } + __throw_exception_again; + } + __profcxx_hashtable_resize(this, __num_elements_hint, __n); + } + } + } + + template<class _Val, class _Key, class _HF, class _Ex, class _Eq, class _All> + void + hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>:: + _M_erase_bucket(const size_type __n, _Node* __first, _Node* __last) + { + _Node* __cur = _M_buckets[__n]; + if (__cur == __first) + _M_erase_bucket(__n, __last); + else + { + _Node* __next; + for (__next = __cur->_M_next; + __next != __first; + __cur = __next, __next = __cur->_M_next) + ; + while (__next != __last) + { + __cur->_M_next = __next->_M_next; + _M_delete_node(__next); + __next = __cur->_M_next; + --_M_num_elements; + } + } + } + + template<class _Val, class _Key, class _HF, class _Ex, class _Eq, class _All> + void + hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>:: + _M_erase_bucket(const size_type __n, _Node* __last) + { + _Node* __cur = _M_buckets[__n]; + while (__cur != __last) + { + _Node* __next = __cur->_M_next; + _M_delete_node(__cur); + __cur = __next; + _M_buckets[__n] = __cur; + --_M_num_elements; + } + } + + template<class _Val, class _Key, class _HF, class _Ex, class _Eq, class _All> + void + hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>:: + clear() + { + if (_M_num_elements != 0) + __profcxx_hashtable_destruct(this, _M_buckets.size(), _M_num_elements); + for (size_type __i = 0; __i < _M_buckets.size(); ++__i) + { + _Node* __cur = _M_buckets[__i]; + while (__cur != 0) + { + _Node* __next = __cur->_M_next; + _M_delete_node(__cur); + __cur = __next; + } + _M_buckets[__i] = 0; + } + _M_num_elements = 0; + } + + template<class _Val, class _Key, class _HF, class _Ex, class _Eq, class _All> + void + hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>:: + _M_copy_from(const hashtable& __ht) + { + _M_buckets.clear(); + _M_buckets.reserve(__ht._M_buckets.size()); + _M_buckets.insert(_M_buckets.end(), __ht._M_buckets.size(), (_Node*) 0); + try + { + for (size_type __i = 0; __i < __ht._M_buckets.size(); ++__i) { + const _Node* __cur = __ht._M_buckets[__i]; + if (__cur) + { + _Node* __local_copy = _M_new_node(__cur->_M_val); + _M_buckets[__i] = __local_copy; + + for (_Node* __next = __cur->_M_next; + __next; + __cur = __next, __next = __cur->_M_next) + { + __local_copy->_M_next = _M_new_node(__next->_M_val); + __local_copy = __local_copy->_M_next; + } + } + } + _M_num_elements = __ht._M_num_elements; + } + catch(...) + { + clear(); + __throw_exception_again; + } + } + +_GLIBCXX_END_NAMESPACE + +#endif diff --git a/libstdc++-v3/include/profile/list b/libstdc++-v3/include/profile/list new file mode 100644 index 00000000000..eccb36c2f01 --- /dev/null +++ b/libstdc++-v3/include/profile/list @@ -0,0 +1,189 @@ +// Profiling list implementation -*- C++ -*- + +// Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 +// Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +/** @file profile/list + * This file is a GNU profile extension to the Standard C++ Library. + */ + +#ifndef _GLIBCXX_PROFILE_LIST +#define _GLIBCXX_PROFILE_LIST 1 + +#include <list> +#include <bits/stl_algo.h> + +namespace std +{ +namespace __profile +{ + template<typename _Tp, typename _Allocator = std::allocator<_Tp> > + class list + : public _GLIBCXX_STD_PR::list<_Tp, _Allocator> + { + typedef _GLIBCXX_STD_D::list<_Tp, _Allocator> _Base; + + public: + typedef typename _Base::size_type size_type; + + // 23.2.2.1 construct/copy/destroy: + explicit list(const _Allocator& __a = _Allocator()) + : _Base(__a) { } + + explicit list(size_type __n, const _Tp& __value = _Tp(), + const _Allocator& __a = _Allocator()) + : _Base(__n, __value, __a) { } + + template<class _InputIterator> + list(_InputIterator __first, _InputIterator __last, + const _Allocator& __a = _Allocator()) + : _Base(__first, __last, __a) + { } + + + list(const list& __x) + : _Base(__x) { } + + list(const _Base& __x) + : _Base(__x) { } + +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + list(list&& __x) + : _Base(std::forward<list>(__x)) + {} +#endif + + ~list() { } + + list& + operator=(const list& __x) + { + static_cast<_Base&>(*this) = __x; + return *this; + } + + void +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + swap(list&& __x) +#else + swap(list& __x) +#endif + { + _Base::swap(__x); + } + +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + list& + operator=(list&& __x) + { + // NB: DR 675. + _Base::clear(); + _Base::swap(__x); + return *this; + } +#endif + + _Base& + _M_base() { return *this; } + + const _Base& + _M_base() const { return *this; } + }; + + template<typename _Tp, typename _Alloc> + inline bool + operator==(const list<_Tp, _Alloc>& __lhs, + const list<_Tp, _Alloc>& __rhs) + { return __lhs._M_base() == __rhs._M_base(); } + + template<typename _Tp, typename _Alloc> + inline bool + operator!=(const list<_Tp, _Alloc>& __lhs, + const list<_Tp, _Alloc>& __rhs) + { return __lhs._M_base() != __rhs._M_base(); } + + template<typename _Tp, typename _Alloc> + inline bool + operator<(const list<_Tp, _Alloc>& __lhs, + const list<_Tp, _Alloc>& __rhs) + { return __lhs._M_base() < __rhs._M_base(); } + + template<typename _Tp, typename _Alloc> + inline bool + operator<=(const list<_Tp, _Alloc>& __lhs, + const list<_Tp, _Alloc>& __rhs) + { return __lhs._M_base() <= __rhs._M_base(); } + + template<typename _Tp, typename _Alloc> + inline bool + operator>=(const list<_Tp, _Alloc>& __lhs, + const list<_Tp, _Alloc>& __rhs) + { return __lhs._M_base() >= __rhs._M_base(); } + + template<typename _Tp, typename _Alloc> + inline bool + operator>(const list<_Tp, _Alloc>& __lhs, + const list<_Tp, _Alloc>& __rhs) + { return __lhs._M_base() > __rhs._M_base(); } + + template<typename _Tp, typename _Alloc> + inline void + swap(list<_Tp, _Alloc>& __lhs, list<_Tp, _Alloc>& __rhs) + { __lhs.swap(__rhs); } + +} // namespace __profile +} // namespace std + +#endif diff --git a/libstdc++-v3/include/profile/map b/libstdc++-v3/include/profile/map new file mode 100644 index 00000000000..43d4f05ddc0 --- /dev/null +++ b/libstdc++-v3/include/profile/map @@ -0,0 +1,42 @@ +// Profiling map/multimap implementation -*- C++ -*- + +// Copyright (C) 2003, 2006 +// Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +/** @file profile/map + * This file is a GNU profile extension to the Standard C++ Library. + */ + +#ifndef _GLIBCXX_PROFILE_MAP +#define _GLIBCXX_PROFILE_MAP 1 + +#include <map> +#include <profile/map.h> +#include <profile/multimap.h> + +#endif diff --git a/libstdc++-v3/include/profile/map.h b/libstdc++-v3/include/profile/map.h new file mode 100644 index 00000000000..8923b59a2eb --- /dev/null +++ b/libstdc++-v3/include/profile/map.h @@ -0,0 +1,178 @@ +// Profiling map implementation -*- C++ -*- + +// Copyright (C) 2003, 2004, 2005, 2006, 2007 +// Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +/** @file profile/map.h + * This file is a GNU profile extension to the Standard C++ Library. + */ + +#ifndef _GLIBCXX_PROFILE_MAP_H +#define _GLIBCXX_PROFILE_MAP_H 1 + +#include <utility> + +namespace std +{ +namespace __profile +{ + template<typename _Key, typename _Tp, typename _Compare = std::less<_Key>, + typename _Allocator = std::allocator<std::pair<const _Key, _Tp> > > + class map + : public _GLIBCXX_STD_PR::map<_Key, _Tp, _Compare, _Allocator> + { + typedef _GLIBCXX_STD_D::map<_Key, _Tp, _Compare, _Allocator> _Base; + + public: + explicit map(const _Compare& __comp = _Compare(), + const _Allocator& __a = _Allocator()) + : _Base(__comp, __a) { } + + template<typename _InputIterator> + map(_InputIterator __first, _InputIterator __last, + const _Compare& __comp = _Compare(), + const _Allocator& __a = _Allocator()) + : _Base(__first, __last, __comp, __a) { } + + map(const map& __x) + : _Base(__x) { } + + map(const _Base& __x) + : _Base(__x) { } + +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + map(map&& __x) + : _Base(std::forward<map>(__x)) + { } +#endif + ~map() { } + + void +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + swap(map&& __x) +#else + swap(map& __x) +#endif + { + _Base::swap(__x); + } + + + map& + operator=(const map& __x) + { + *static_cast<_Base*>(this) = __x; + return *this; + } + +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + map& + operator=(map&& __x) + { + // NB: DR 675. + _Base::clear(); + _Base::swap(__x); + return *this; + } +#endif + + _Base& + _M_base() { return *this; } + + const _Base& + _M_base() const { return *this; } + }; + + template<typename _Key, typename _Tp, + typename _Compare, typename _Allocator> + inline bool + operator==(const map<_Key, _Tp, _Compare, _Allocator>& __lhs, + const map<_Key, _Tp, _Compare, _Allocator>& __rhs) + { return __lhs._M_base() == __rhs._M_base(); } + + template<typename _Key, typename _Tp, + typename _Compare, typename _Allocator> + inline bool + operator!=(const map<_Key, _Tp, _Compare, _Allocator>& __lhs, + const map<_Key, _Tp, _Compare, _Allocator>& __rhs) + { return __lhs._M_base() != __rhs._M_base(); } + + template<typename _Key, typename _Tp, + typename _Compare, typename _Allocator> + inline bool + operator<(const map<_Key, _Tp, _Compare, _Allocator>& __lhs, + const map<_Key, _Tp, _Compare, _Allocator>& __rhs) + { return __lhs._M_base() < __rhs._M_base(); } + + template<typename _Key, typename _Tp, + typename _Compare, typename _Allocator> + inline bool + operator<=(const map<_Key, _Tp, _Compare, _Allocator>& __lhs, + const map<_Key, _Tp, _Compare, _Allocator>& __rhs) + { return __lhs._M_base() <= __rhs._M_base(); } + + template<typename _Key, typename _Tp, + typename _Compare, typename _Allocator> + inline bool + operator>=(const map<_Key, _Tp, _Compare, _Allocator>& __lhs, + const map<_Key, _Tp, _Compare, _Allocator>& __rhs) + { return __lhs._M_base() >= __rhs._M_base(); } + + template<typename _Key, typename _Tp, + typename _Compare, typename _Allocator> + inline bool + operator>(const map<_Key, _Tp, _Compare, _Allocator>& __lhs, + const map<_Key, _Tp, _Compare, _Allocator>& __rhs) + { return __lhs._M_base() > __rhs._M_base(); } + + template<typename _Key, typename _Tp, + typename _Compare, typename _Allocator> + inline void + swap(map<_Key, _Tp, _Compare, _Allocator>& __lhs, + map<_Key, _Tp, _Compare, _Allocator>& __rhs) + { __lhs.swap(__rhs); } + +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + template<typename _Key, typename _Tp, + typename _Compare, typename _Allocator> + inline void + swap(map<_Key, _Tp, _Compare, _Allocator>&& __lhs, + map<_Key, _Tp, _Compare, _Allocator>& __rhs) + { __lhs.swap(__rhs); } + + template<typename _Key, typename _Tp, + typename _Compare, typename _Allocator> + inline void + swap(map<_Key, _Tp, _Compare, _Allocator>& __lhs, + map<_Key, _Tp, _Compare, _Allocator>&& __rhs) + { __lhs.swap(__rhs); } +#endif +} // namespace __profile +} // namespace std + +#endif diff --git a/libstdc++-v3/include/profile/multimap.h b/libstdc++-v3/include/profile/multimap.h new file mode 100644 index 00000000000..7219eaaf716 --- /dev/null +++ b/libstdc++-v3/include/profile/multimap.h @@ -0,0 +1,177 @@ +// Profiling multimap implementation -*- C++ -*- + +// Copyright (C) 2003, 2004, 2005, 2006, 2007 +// Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +/** @file profile/multimap.h + * This file is a GNU profile extension to the Standard C++ Library. + */ + +#ifndef _GLIBCXX_PROFILE_MULTIMAP_H +#define _GLIBCXX_PROFILE_MULTIMAP_H 1 + +#include <utility> + +namespace std +{ +namespace __profile +{ + template<typename _Key, typename _Tp, typename _Compare = std::less<_Key>, + typename _Allocator = std::allocator<std::pair<const _Key, _Tp> > > + class multimap + : public _GLIBCXX_STD_PR::multimap<_Key, _Tp, _Compare, _Allocator> + { + typedef _GLIBCXX_STD_D::multimap<_Key, _Tp, _Compare, _Allocator> _Base; + + public: + explicit multimap(const _Compare& __comp = _Compare(), + const _Allocator& __a = _Allocator()) + : _Base(__comp, __a) { } + + template<typename _InputIterator> + multimap(_InputIterator __first, _InputIterator __last, + const _Compare& __comp = _Compare(), + const _Allocator& __a = _Allocator()) + : _Base(__first, __last, __comp, __a) { } + + multimap(const multimap& __x) + : _Base(__x) { } + + multimap(const _Base& __x) + : _Base(__x) { } + +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + multimap(multimap&& __x) + : _Base(std::forward<multimap>(__x)) + { } +#endif + + ~multimap() { } + + multimap& + operator=(const multimap& __x) + { + *static_cast<_Base*>(this) = __x; + return *this; + } + +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + multimap& + operator=(multimap&& __x) + { + _Base::clear(); + _Base::swap(__x); + return *this; + } +#endif + _Base& + _M_base() { return *this; } + + const _Base& + _M_base() const { return *this; } + + void +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + swap(multimap&& __x) +#else + swap(multimap& __x) +#endif + { + _Base::swap(__x); + } + + }; + template<typename _Key, typename _Tp, + typename _Compare, typename _Allocator> + inline bool + operator==(const multimap<_Key, _Tp, _Compare, _Allocator>& __lhs, + const multimap<_Key, _Tp, _Compare, _Allocator>& __rhs) + { return __lhs._M_base() == __rhs._M_base(); } + + template<typename _Key, typename _Tp, + typename _Compare, typename _Allocator> + inline bool + operator!=(const multimap<_Key, _Tp, _Compare, _Allocator>& __lhs, + const multimap<_Key, _Tp, _Compare, _Allocator>& __rhs) + { return __lhs._M_base() != __rhs._M_base(); } + + template<typename _Key, typename _Tp, + typename _Compare, typename _Allocator> + inline bool + operator<(const multimap<_Key, _Tp, _Compare, _Allocator>& __lhs, + const multimap<_Key, _Tp, _Compare, _Allocator>& __rhs) + { return __lhs._M_base() < __rhs._M_base(); } + + template<typename _Key, typename _Tp, + typename _Compare, typename _Allocator> + inline bool + operator<=(const multimap<_Key, _Tp, _Compare, _Allocator>& __lhs, + const multimap<_Key, _Tp, _Compare, _Allocator>& __rhs) + { return __lhs._M_base() <= __rhs._M_base(); } + + template<typename _Key, typename _Tp, + typename _Compare, typename _Allocator> + inline bool + operator>=(const multimap<_Key, _Tp, _Compare, _Allocator>& __lhs, + const multimap<_Key, _Tp, _Compare, _Allocator>& __rhs) + { return __lhs._M_base() >= __rhs._M_base(); } + + template<typename _Key, typename _Tp, + typename _Compare, typename _Allocator> + inline bool + operator>(const multimap<_Key, _Tp, _Compare, _Allocator>& __lhs, + const multimap<_Key, _Tp, _Compare, _Allocator>& __rhs) + { return __lhs._M_base() > __rhs._M_base(); } + + template<typename _Key, typename _Tp, + typename _Compare, typename _Allocator> + inline void + swap(multimap<_Key, _Tp, _Compare, _Allocator>& __lhs, + multimap<_Key, _Tp, _Compare, _Allocator>& __rhs) + { __lhs.swap(__rhs); } + +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + template<typename _Key, typename _Tp, + typename _Compare, typename _Allocator> + inline void + swap(multimap<_Key, _Tp, _Compare, _Allocator>&& __lhs, + multimap<_Key, _Tp, _Compare, _Allocator>& __rhs) + { __lhs.swap(__rhs); } + + template<typename _Key, typename _Tp, + typename _Compare, typename _Allocator> + inline void + swap(multimap<_Key, _Tp, _Compare, _Allocator>& __lhs, + multimap<_Key, _Tp, _Compare, _Allocator>&& __rhs) + { __lhs.swap(__rhs); } + +#endif +} // namespace __profile +} // namespace std + +#endif diff --git a/libstdc++-v3/include/profile/multiset.h b/libstdc++-v3/include/profile/multiset.h new file mode 100644 index 00000000000..260298b5b3e --- /dev/null +++ b/libstdc++-v3/include/profile/multiset.h @@ -0,0 +1,168 @@ +// Profiling multiset implementation -*- C++ -*- + +// Copyright (C) 2008 +// Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +/** @file profile/multiset.h + * This file is a GNU profile extension to the Standard C++ Library. + */ + +#ifndef _GLIBCXX_PROFILE_MULTISET_H +#define _GLIBCXX_PROFILE_MULTISET_H 1 + +#include <utility> + +namespace std +{ +namespace __profile +{ + template<typename _Key, typename _Compare = std::less<_Key>, + typename _Allocator = std::allocator<_Key> > + class multiset + : public _GLIBCXX_STD_PR::multiset<_Key, _Compare, _Allocator> + { + typedef _GLIBCXX_STD_PR::multiset<_Key, _Compare, _Allocator> _Base; + + public: + explicit multiset(const _Compare& __comp = _Compare(), + const _Allocator& __a = _Allocator()) + : _Base(__comp, __a) { } + + template<typename _InputIterator> + multiset(_InputIterator __first, _InputIterator __last, + const _Compare& __comp = _Compare(), + const _Allocator& __a = _Allocator()) + : _Base(__first, __last, __comp, __a) { } + + multiset(const multiset& __x) + : _Base(__x) { } + + multiset(const _Base& __x) + : _Base(__x) { } + +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + multiset(multiset&& __x) + : _Base(std::forward<multiset>(__x)) + {} +#endif + ~multiset() { } + + multiset& + operator=(const multiset& __x) + { + *static_cast<_Base*>(this) = __x; + return *this; + } + +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + multiset& + operator=(multiset&& __x) + { + _Base::clear(); + _Base::swap(__x); + return *this; + } +#endif + + void +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + swap(multiset&& __x) +#else + swap(multiset& __x) +#endif + { + _Base::swap(__x); + } + + _Base& + _M_base() { return *this; } + + const _Base& + _M_base() const { return *this; } + }; + + template<typename _Key, typename _Compare, typename _Allocator> + inline bool + operator==(const multiset<_Key, _Compare, _Allocator>& __lhs, + const multiset<_Key, _Compare, _Allocator>& __rhs) + { return __lhs._M_base() == __rhs._M_base(); } + + template<typename _Key, typename _Compare, typename _Allocator> + inline bool + operator!=(const multiset<_Key, _Compare, _Allocator>& __lhs, + const multiset<_Key, _Compare, _Allocator>& __rhs) + { return __lhs._M_base() != __rhs._M_base(); } + + template<typename _Key, typename _Compare, typename _Allocator> + inline bool + operator<(const multiset<_Key, _Compare, _Allocator>& __lhs, + const multiset<_Key, _Compare, _Allocator>& __rhs) + { return __lhs._M_base() < __rhs._M_base(); } + + template<typename _Key, typename _Compare, typename _Allocator> + inline bool + operator<=(const multiset<_Key, _Compare, _Allocator>& __lhs, + const multiset<_Key, _Compare, _Allocator>& __rhs) + { return __lhs._M_base() <= __rhs._M_base(); } + + template<typename _Key, typename _Compare, typename _Allocator> + inline bool + operator>=(const multiset<_Key, _Compare, _Allocator>& __lhs, + const multiset<_Key, _Compare, _Allocator>& __rhs) + { return __lhs._M_base() >= __rhs._M_base(); } + + template<typename _Key, typename _Compare, typename _Allocator> + inline bool + operator>(const multiset<_Key, _Compare, _Allocator>& __lhs, + const multiset<_Key, _Compare, _Allocator>& __rhs) + { return __lhs._M_base() > __rhs._M_base(); } + + template<typename _Key, typename _Compare, typename _Allocator> + void + swap(multiset<_Key, _Compare, _Allocator>& __x, + multiset<_Key, _Compare, _Allocator>& __y) + { return __x.swap(__y); } + +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + template<typename _Key, typename _Compare, typename _Allocator> + void + swap(multiset<_Key, _Compare, _Allocator>&& __x, + multiset<_Key, _Compare, _Allocator>& __y) + { return __x.swap(__y); } + + template<typename _Key, typename _Compare, typename _Allocator> + void + swap(multiset<_Key, _Compare, _Allocator>& __x, + multiset<_Key, _Compare, _Allocator>&& __y) + { return __x.swap(__y); } +#endif + +} // namespace __profile +} // namespace std + +#endif diff --git a/libstdc++-v3/include/profile/set b/libstdc++-v3/include/profile/set new file mode 100644 index 00000000000..cce4a49e7c0 --- /dev/null +++ b/libstdc++-v3/include/profile/set @@ -0,0 +1,42 @@ +// Profiling set/multiset implementation -*- C++ -*- + +// Copyright (C) 2003-2008 +// Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +/** @file profile/set + * This file is a GNU profile extension to the Standard C++ Library. + */ + +#ifndef _GLIBCXX_PROFILE_SET +#define _GLIBCXX_PROFILE_SET 1 + +#include <set> +#include <profile/set.h> +#include <profile/multiset.h> + +#endif diff --git a/libstdc++-v3/include/profile/set.h b/libstdc++-v3/include/profile/set.h new file mode 100644 index 00000000000..668549e9bd7 --- /dev/null +++ b/libstdc++-v3/include/profile/set.h @@ -0,0 +1,156 @@ +// Profiling set implementation -*- C++ -*- + +// Copyright (C) 2003, 2004, 2005, 2006, 2007 +// Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +/** @file profile/set.h + * This file is a GNU profile extension to the Standard C++ Library. + */ + +#ifndef _GLIBCXX_PROFILE_SET_H +#define _GLIBCXX_PROFILE_SET_H 1 + +#include <utility> + +namespace std +{ +namespace __profile +{ + template<typename _Key, typename _Compare = std::less<_Key>, + typename _Allocator = std::allocator<_Key> > + class set + : public _GLIBCXX_STD_PR::set<_Key,_Compare,_Allocator> + { + typedef _GLIBCXX_STD_PR::set<_Key, _Compare, _Allocator> _Base; + + public: + explicit set(const _Compare& __comp = _Compare(), + const _Allocator& __a = _Allocator()) + : _Base(__comp, __a) { } + + template<typename _InputIterator> + set(_InputIterator __first, _InputIterator __last, + const _Compare& __comp = _Compare(), + const _Allocator& __a = _Allocator()) + : _Base(__first, __last, __comp, __a) { } + + set(const set& __x) + : _Base(__x) { } + + set(const _Base& __x) + : _Base(__x) { } + +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + set(set&& __x) + : _Base(std::forward<set>(__x)) + { } +#endif + ~set() { } + + set& + operator=(const set& __x) + { + *static_cast<_Base*>(this) = __x; + return *this; + } + +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + set& + operator=(set&& __x) + { + _Base::clear(); + _Base::swap(__x); + return *this; + } +#endif + + void +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + swap(set&& __x) +#else + swap(set& __x) +#endif + { + _Base::swap(__x); + } + + _Base& + _M_base() { return *this; } + + const _Base& + _M_base() const { return *this; } + }; + + template<typename _Key, typename _Compare, typename _Allocator> + inline bool + operator<(const set<_Key, _Compare, _Allocator>& __lhs, + const set<_Key, _Compare, _Allocator>& __rhs) + { return __lhs._M_base() < __rhs._M_base(); } + + template<typename _Key, typename _Compare, typename _Allocator> + inline bool + operator<=(const set<_Key, _Compare, _Allocator>& __lhs, + const set<_Key, _Compare, _Allocator>& __rhs) + { return __lhs._M_base() <= __rhs._M_base(); } + + template<typename _Key, typename _Compare, typename _Allocator> + inline bool + operator>=(const set<_Key, _Compare, _Allocator>& __lhs, + const set<_Key, _Compare, _Allocator>& __rhs) + { return __lhs._M_base() >= __rhs._M_base(); } + + template<typename _Key, typename _Compare, typename _Allocator> + inline bool + operator>(const set<_Key, _Compare, _Allocator>& __lhs, + const set<_Key, _Compare, _Allocator>& __rhs) + { return __lhs._M_base() > __rhs._M_base(); } + + template<typename _Key, typename _Compare, typename _Allocator> + void + swap(set<_Key, _Compare, _Allocator>& __x, + set<_Key, _Compare, _Allocator>& __y) + { return __x.swap(__y); } + +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + template<typename _Key, typename _Compare, typename _Allocator> + void + swap(set<_Key, _Compare, _Allocator>&& __x, + set<_Key, _Compare, _Allocator>& __y) + { return __x.swap(__y); } + + template<typename _Key, typename _Compare, typename _Allocator> + void + swap(set<_Key, _Compare, _Allocator>& __x, + set<_Key, _Compare, _Allocator>&& __y) + { return __x.swap(__y); } +#endif + +} // namespace __profile +} // namespace std + +#endif diff --git a/libstdc++-v3/include/profile/unordered_map b/libstdc++-v3/include/profile/unordered_map new file mode 100644 index 00000000000..63fb5ce141b --- /dev/null +++ b/libstdc++-v3/include/profile/unordered_map @@ -0,0 +1,416 @@ +// Profiling unordered_map/unordered_multimap implementation -*- C++ -*- + +// Copyright (C) 2003, 2004, 2005, 2006, 2007 +// Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +/** @file profile/unordered_map + * This file is a GNU profile extension to the Standard C++ Library. + */ + +#ifndef _GLIBCXX_PROFILE_UNORDERED_MAP +#define _GLIBCXX_PROFILE_UNORDERED_MAP 1 + +#include <profile/base.h> + +#ifdef __GXX_EXPERIMENTAL_CXX0X__ +# include <unordered_map> +#else +# include <c++0x_warning.h> +#endif + +#define _GLIBCXX_BASE unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc> +#define _GLIBCXX_STD_BASE _GLIBCXX_STD_PR::_GLIBCXX_BASE + +namespace std +{ +namespace __profile +{ + template<typename _Key, typename _Tp, + typename _Hash = std::hash<_Key>, + typename _Pred = std::equal_to<_Key>, + typename _Alloc = std::allocator<_Key> > + class unordered_map + : public _GLIBCXX_STD_BASE + { + typedef typename _GLIBCXX_STD_BASE _Base; + + public: + typedef typename _Base::size_type size_type; + typedef typename _Base::hasher hasher; + typedef typename _Base::key_equal key_equal; + typedef typename _Base::allocator_type allocator_type; + typedef typename _Base::key_type key_type; + typedef typename _Base::value_type value_type; + typedef typename _Base::difference_type difference_type; + typedef typename _Base::reference reference; + typedef typename _Base::const_reference const_reference; + typedef typename _Base::mapped_type mapped_type; + typedef std::pair<typename _Base::iterator, bool> pair_type; + typedef typename _Base::insert_return_type insert_return_type; + + typedef typename _Base::iterator iterator; + typedef typename _Base::const_iterator const_iterator; + + explicit + unordered_map(size_type __n = 10, + const hasher& __hf = hasher(), + const key_equal& __eql = key_equal(), + const allocator_type& __a = allocator_type()) + : _Base(__n, __hf, __eql, __a) + { + __profcxx_hashtable_construct(this, _Base::bucket_count()); + } + + template<typename _InputIterator> + unordered_map(_InputIterator __f, _InputIterator __l, + size_type __n = 10, + const hasher& __hf = hasher(), + const key_equal& __eql = key_equal(), + const allocator_type& __a = allocator_type()) + : _Base(__f, __l, __n, __hf, __eql, __a) + { + __profcxx_hashtable_construct(this, _Base::bucket_count()); + } + + unordered_map(const _Base& __x) + : _Base(__x) + { + __profcxx_hashtable_construct(this, _Base::bucket_count()); + } + + unordered_map(unordered_map&& __x) + : _Base(std::forward<_Base>(__x)) + { + __profcxx_hashtable_construct(this, _Base::bucket_count()); + } + + ~unordered_map() + { + __profcxx_hashtable_destruct(this, _Base::bucket_count(), _Base::size()); + } + + unordered_map& + operator=(unordered_map&& __x) + { + // NB: DR 675. + _Base::clear(); + _Base::swap(__x); + return *this; + } + + _Base& + _M_base() { return *this; } + + const _Base& + _M_base() const { return *this; } + + + void + clear() + { + __profcxx_hashtable_destruct(this, _Base::bucket_count(), _Base::size()); + _Base::clear(); + } + + insert_return_type + insert(const value_type& __obj) + { + size_type old_size = _Base::bucket_count(); + insert_return_type __res = _Base::insert(__obj); + profile_resize(this, old_size, _Base::bucket_count()); + return __res; + } + iterator + insert(iterator __iter, const value_type& __v) + { + size_type old_size = _Base::bucket_count(); + iterator res = _Base::insert(__iter, __v); + profile_resize(this, old_size, _Base::bucket_count()); + return res; + } + + const_iterator + insert(const_iterator __iter, const value_type& __v) + { + size_type old_size = _Base::bucket_count(); + const_iterator res =_Base::insert(__iter, __v); + profile_resize(this, old_size, _Base::bucket_count()); + return res; + } + + template<typename _InputIter> + void + insert(_InputIter __first, _InputIter __last) + { + size_type old_size = _Base::bucket_count(); + _Base::insert(__first.base(), __last.base()); + profile_resize(this, old_size, _Base::bucket_count()); + } + + void + insert(const value_type* __first, const value_type* __last) + { + size_type old_size = _Base::bucket_count(); + _Base::insert(__first, __last); + profile_resize(this, old_size, _Base::bucket_count()); + } + + // operator [] + mapped_type& + operator[](const _Key& _k) + { + size_type old_size = _Base::bucket_count(); + mapped_type& __res = _M_base()[_k]; + size_type new_size = _Base::bucket_count(); + profile_resize(this, old_size, _Base::bucket_count()); + return __res; + } + void + swap(unordered_map&& __x) + { + _Base::swap(__x); + } + + void rehash(size_type __n) + { + size_type old_size = _Base::bucket_count(); + _Base::rehash(__n); + profile_resize(this, old_size, _Base::bucket_count()); + } + private: + void profile_resize(void* obj, size_type old_size, size_type new_size) + { + if (old_size != new_size) + { + __profcxx_hashtable_resize(this, old_size, new_size); + } + } + }; + template<typename _Key, typename _Tp, typename _Hash, + typename _Pred, typename _Alloc> + inline void + swap(unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __x, + unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __y) + { __x.swap(__y); } + + template<typename _Key, typename _Tp, typename _Hash, + typename _Pred, typename _Alloc> + inline void + swap(unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>&& __x, + unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __y) + { __x.swap(__y); } + + template<typename _Key, typename _Tp, typename _Hash, + typename _Pred, typename _Alloc> + inline void + swap(unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __x, + unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>&& __y) + { __x.swap(__y); } + +#undef _GLIBCXX_BASE +#undef _GLIBCXX_STD_BASE +#define _GLIBCXX_BASE unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc> +#define _GLIBCXX_STD_BASE _GLIBCXX_STD_PR::_GLIBCXX_BASE + + template<typename _Key, typename _Tp, + typename _Hash = std::hash<_Key>, + typename _Pred = std::equal_to<_Key>, + typename _Alloc = std::allocator<_Key> > + class unordered_multimap + : public _GLIBCXX_STD_BASE + { + typedef typename _GLIBCXX_STD_BASE _Base; + + public: + typedef typename _Base::size_type size_type; + typedef typename _Base::hasher hasher; + typedef typename _Base::key_equal key_equal; + typedef typename _Base::allocator_type allocator_type; + typedef typename _Base::key_type key_type; + typedef typename _Base::value_type value_type; + typedef typename _Base::difference_type difference_type; + typedef typename _Base::reference reference; + typedef typename _Base::const_reference const_reference; + typedef std::pair<typename _Base::iterator, bool> pair_type; + typedef typename _Base::insert_return_type insert_return_type; + + typedef typename _Base::iterator iterator; + typedef typename _Base::const_iterator const_iterator; + + explicit + unordered_multimap(size_type __n = 10, + const hasher& __hf = hasher(), + const key_equal& __eql = key_equal(), + const allocator_type& __a = allocator_type()) + : _Base(__n, __hf, __eql, __a) + { + __profcxx_hashtable_construct(this, _Base::bucket_count()); + } + template<typename _InputIterator> + unordered_multimap(_InputIterator __f, _InputIterator __l, + size_type __n = 10, + const hasher& __hf = hasher(), + const key_equal& __eql = key_equal(), + const allocator_type& __a = allocator_type()) + : _Base(__f, __l, __n, __hf, __eql, __a) + { + __profcxx_hashtable_construct(this, _Base::bucket_count()); + } + + unordered_multimap(const _Base& __x) + : _Base(__x) + { + __profcxx_hashtable_construct(this, _Base::bucket_count()); + } + + unordered_multimap(unordered_multimap&& __x) + : _Base(std::forward<_Base>(__x)) + { + __profcxx_hashtable_construct(this, _Base::bucket_count()); + } + + ~unordered_multimap() + { + __profcxx_hashtable_destruct(this, _Base::bucket_count(), _Base::size()); + } + + _Base& + _M_base() { return *this; } + + const _Base& + _M_base() const { return *this; } + + + void + clear() + { + __profcxx_hashtable_destruct(this, _Base::bucket_count(), _Base::size()); + _Base::clear(); + } + + insert_return_type + insert(const value_type& __obj) + { + size_type old_size = _Base::bucket_count(); + insert_return_type __res = _Base::insert(__obj); + profile_resize(this, old_size, _Base::bucket_count()); + return __res; + } + iterator + insert(iterator __iter, const value_type& __v) + { + size_type old_size = _Base::bucket_count(); + iterator res = _Base::insert(__iter, __v); + profile_resize(this, old_size, _Base::bucket_count()); + return res; + } + + const_iterator + insert(const_iterator __iter, const value_type& __v) + { + size_type old_size = _Base::bucket_count(); + const_iterator res =_Base::insert(__iter, __v); + profile_resize(this, old_size, _Base::bucket_count()); + return res; + } + + template<typename _InputIter> + void + insert(_InputIter __first, _InputIter __last) + { + size_type old_size = _Base::bucket_count(); + _Base::insert(__first.base(), __last.base()); + profile_resize(this, old_size, _Base::bucket_count()); + } + + void + insert(const value_type* __first, const value_type* __last) + { + size_type old_size = _Base::bucket_count(); + _Base::insert(__first, __last); + profile_resize(this, old_size, _Base::bucket_count()); + } + + unordered_multimap& + operator=(unordered_multimap&& __x) + { + // NB: DR 675. + _Base::clear(); + _Base::swap(__x); + return *this; + } + + void + swap(unordered_multimap&& __x) + { + _Base::swap(__x); + } + + void rehash(size_type __n) + { + size_type old_size = _Base::bucket_count(); + _Base::rehash(__n); + profile_resize(this, old_size, _Base::bucket_count()); + } + private: + void profile_resize(void* obj, size_type old_size, size_type new_size) + { + if (old_size != new_size) + { + __profcxx_hashtable_resize(this, old_size, new_size); + } + } + }; + template<typename _Key, typename _Tp, typename _Hash, + typename _Pred, typename _Alloc> + inline void + swap(unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __x, + unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __y) + { __x.swap(__y); } + + template<typename _Key, typename _Tp, typename _Hash, + typename _Pred, typename _Alloc> + inline void + swap(unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>&& __x, + unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __y) + { __x.swap(__y); } + + template<typename _Key, typename _Tp, typename _Hash, + typename _Pred, typename _Alloc> + inline void + swap(unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __x, + unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>&& __y) + { __x.swap(__y); } + +} // namespace __profile +} // namespace std + +#undef _GLIBCXX_BASE +#undef _GLIBCXX_STD_BASE + +#endif diff --git a/libstdc++-v3/include/profile/unordered_set b/libstdc++-v3/include/profile/unordered_set new file mode 100644 index 00000000000..01b2249e2c8 --- /dev/null +++ b/libstdc++-v3/include/profile/unordered_set @@ -0,0 +1,374 @@ +// Profiling unordered_set/unordered_multiset implementation -*- C++ -*- + +// Copyright (C) 2003, 2004, 2005, 2006, 2007 +// Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +/** @file profile/unordered_set + * This file is a GNU profile extension to the Standard C++ Library. + */ + +#ifndef _GLIBCXX_PROFILE_UNORDERED_SET +#define _GLIBCXX_PROFILE_UNORDERED_SET 1 + +#include <profile/base.h> + +#ifdef __GXX_EXPERIMENTAL_CXX0X__ +# include <unordered_set> +#else +# include <c++0x_warning.h> +#endif + +#define _GLIBCXX_BASE unordered_set<_Key, _Hash, _Pred, _Alloc> +#define _GLIBCXX_STD_BASE _GLIBCXX_STD_PR::_GLIBCXX_BASE + +namespace std +{ +namespace __profile +{ + template<typename _Key, + typename _Hash = std::hash<_Key>, + typename _Pred = std::equal_to<_Key>, + typename _Alloc = std::allocator<_Key> > + class unordered_set + : public _GLIBCXX_STD_BASE + { + typedef typename _GLIBCXX_STD_BASE _Base; + + public: + typedef typename _Base::size_type size_type; + typedef typename _Base::hasher hasher; + typedef typename _Base::key_equal key_equal; + typedef typename _Base::allocator_type allocator_type; + typedef typename _Base::key_type key_type; + typedef typename _Base::value_type value_type; + typedef typename _Base::difference_type difference_type; + typedef typename _Base::reference reference; + typedef typename _Base::const_reference const_reference; + typedef typename _Base::insert_return_type insert_return_type; + + typedef typename _Base::iterator iterator; + typedef typename _Base::const_iterator const_iterator; + + explicit + unordered_set(size_type __n = 10, + const hasher& __hf = hasher(), + const key_equal& __eql = key_equal(), + const allocator_type& __a = allocator_type()) + : _Base(__n, __hf, __eql, __a) + { + __profcxx_hashtable_construct(this, _Base::bucket_count()); + } + + template<typename _InputIterator> + unordered_set(_InputIterator __f, _InputIterator __l, + size_type __n = 10, + const hasher& __hf = hasher(), + const key_equal& __eql = key_equal(), + const allocator_type& __a = allocator_type()) + : _Base(__f, __l, __n, __hf, __eql, __a) + { + __profcxx_hashtable_construct(this, _Base::bucket_count()); + } + + unordered_set(const _Base& __x) + : _Base(__x) + { + __profcxx_hashtable_construct(this, _Base::bucket_count()); + } + + unordered_set(unordered_set&& __x) + : _Base(std::forward<_Base>(__x)) + { + __profcxx_hashtable_construct(this, _Base::bucket_count()); + } + + ~unordered_set() + { + __profcxx_hashtable_destruct(this, _Base::bucket_count(), _Base::size()); + } + + void + swap(unordered_set&& __x) + { + _Base::swap(__x); + } + + void + clear() + { + __profcxx_hashtable_destruct(this, _Base::bucket_count(), _Base::size()); + _Base::clear(); + } + insert_return_type insert(const value_type& __obj) + { + size_type old_size = _Base::bucket_count(); + insert_return_type __res = _Base::insert(__obj); + profile_resize(this, old_size, _Base::bucket_count()); + return __res; + } + iterator + insert(iterator __iter, const value_type& __v) + { + size_type old_size = _Base::bucket_count(); + iterator res = _Base::insert(__iter, __v); + profile_resize(this, old_size, _Base::bucket_count()); + return res; + } + + const_iterator + insert(const_iterator __iter, const value_type& __v) + { + size_type old_size = _Base::bucket_count(); + const_iterator res =_Base::insert(__iter, __v); + profile_resize(this, old_size, _Base::bucket_count()); + return res; + } + + template<typename _InputIter> + void + insert(_InputIter __first, _InputIter __last) + { + size_type old_size = _Base::bucket_count(); + _Base::insert(__first.base(), __last.base()); + profile_resize(this, old_size, _Base::bucket_count()); + } + + void + insert(const value_type* __first, const value_type* __last) + { + size_type old_size = _Base::bucket_count(); + _Base::insert(__first, __last); + profile_resize(this, old_size, _Base::bucket_count()); + } + + void rehash(size_type __n) + { + size_type old_size = _Base::bucket_count(); + _Base::rehash(__n); + profile_resize(this, old_size, _Base::bucket_count()); + } + private: + _Base& + _M_base() { return *this; } + + const _Base& + _M_base() const { return *this; } + + void profile_resize(void* obj, size_type old_size, size_type new_size) + { + if (old_size != new_size) + { + __profcxx_hashtable_resize(this, old_size, new_size); + } + } + }; + template<typename _Value, typename _Hash, typename _Pred, typename _Alloc> + inline void + swap(unordered_set<_Value, _Hash, _Pred, _Alloc>& __x, + unordered_set<_Value, _Hash, _Pred, _Alloc>& __y) + { __x.swap(__y); } + + template<typename _Value, typename _Hash, typename _Pred, typename _Alloc> + inline void + swap(unordered_set<_Value, _Hash, _Pred, _Alloc>&& __x, + unordered_set<_Value, _Hash, _Pred, _Alloc>& __y) + { __x.swap(__y); } + + template<typename _Value, typename _Hash, typename _Pred, typename _Alloc> + inline void + swap(unordered_set<_Value, _Hash, _Pred, _Alloc>& __x, + unordered_set<_Value, _Hash, _Pred, _Alloc>&& __y) + { __x.swap(__y); } + +#undef _GLIBCXX_BASE +#undef _GLIBCXX_STD_BASE +#define _GLIBCXX_STD_BASE _GLIBCXX_STD_PR::_GLIBCXX_BASE +#define _GLIBCXX_BASE unordered_multiset<_Value, _Hash, _Pred, _Alloc> + + template<typename _Value, + typename _Hash = std::hash<_Value>, + typename _Pred = std::equal_to<_Value>, + typename _Alloc = std::allocator<_Value> > + class unordered_multiset + : public _GLIBCXX_STD_BASE + { + typedef typename _GLIBCXX_STD_BASE _Base; + + public: + typedef typename _Base::size_type size_type; + typedef typename _Base::hasher hasher; + typedef typename _Base::key_equal key_equal; + typedef typename _Base::allocator_type allocator_type; + typedef typename _Base::key_type key_type; + typedef typename _Base::value_type value_type; + typedef typename _Base::difference_type difference_type; + typedef typename _Base::reference reference; + typedef typename _Base::const_reference const_reference; + typedef typename _Base::insert_return_type insert_return_type; + + typedef typename _Base::iterator iterator; + typedef typename _Base::const_iterator const_iterator; + + explicit + unordered_multiset(size_type __n = 10, + const hasher& __hf = hasher(), + const key_equal& __eql = key_equal(), + const allocator_type& __a = allocator_type()) + : _Base(__n, __hf, __eql, __a) + { + __profcxx_hashtable_construct(this, _Base::bucket_count()); + } + + template<typename _InputIterator> + unordered_multiset(_InputIterator __f, _InputIterator __l, + size_type __n = 10, + const hasher& __hf = hasher(), + const key_equal& __eql = key_equal(), + const allocator_type& __a = allocator_type()) + : _Base(__f, __l, __n, __hf, __eql, __a) + { + __profcxx_hashtable_construct(this, _Base::bucket_count()); + } + + unordered_multiset(const _Base& __x) + : _Base(__x) + { + __profcxx_hashtable_construct(this, _Base::bucket_count()); + } + + unordered_multiset(unordered_multiset&& __x) + : _Base(std::forward<_Base>(__x)) + { + __profcxx_hashtable_construct(this, _Base::bucket_count()); + } + + ~unordered_multiset() + { + __profcxx_hashtable_destruct(this, _Base::bucket_count(), _Base::size()); + } + + void + swap(unordered_multiset&& __x) + { + _Base::swap(__x); + } + + void + clear() + { + __profcxx_hashtable_destruct(this, _Base::bucket_count(), _Base::size()); + _Base::clear(); + } + insert_return_type insert(const value_type& __obj) + { + size_type old_size = _Base::bucket_count(); + insert_return_type __res = _Base::insert(__obj); + profile_resize(this, old_size, _Base::bucket_count()); + return __res; + } + iterator + insert(iterator __iter, const value_type& __v) + { + size_type old_size = _Base::bucket_count(); + iterator res = _Base::insert(__iter, __v); + profile_resize(this, old_size, _Base::bucket_count()); + return res; + } + + const_iterator + insert(const_iterator __iter, const value_type& __v) + { + size_type old_size = _Base::bucket_count(); + const_iterator res =_Base::insert(__iter, __v); + profile_resize(this, old_size, _Base::bucket_count()); + return res; + } + + template<typename _InputIter> + void + insert(_InputIter __first, _InputIter __last) + { + size_type old_size = _Base::bucket_count(); + _Base::insert(__first.base(), __last.base()); + profile_resize(this, old_size, _Base::bucket_count()); + } + + void + insert(const value_type* __first, const value_type* __last) + { + size_type old_size = _Base::bucket_count(); + _Base::insert(__first, __last); + profile_resize(this, old_size, _Base::bucket_count()); + } + + void rehash(size_type __n) + { + size_type old_size = _Base::bucket_count(); + _Base::rehash(__n); + profile_resize(this, old_size, _Base::bucket_count()); + } + private: + _Base& + _M_base() { return *this; } + + const _Base& + _M_base() const { return *this; } + + void profile_resize(void* obj, size_type old_size, size_type new_size) + { + if (old_size != new_size) + { + __profcxx_hashtable_resize(this, old_size, new_size); + } + } + }; + template<typename _Value, typename _Hash, typename _Pred, typename _Alloc> + inline void + swap(unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __x, + unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __y) + { __x.swap(__y); } + + template<typename _Value, typename _Hash, typename _Pred, typename _Alloc> + inline void + swap(unordered_multiset<_Value, _Hash, _Pred, _Alloc>&& __x, + unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __y) + { __x.swap(__y); } + + template<typename _Value, typename _Hash, typename _Pred, typename _Alloc> + inline void + swap(unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __x, + unordered_multiset<_Value, _Hash, _Pred, _Alloc>&& __y) + { __x.swap(__y); } + +} // namespace __profile +} // namespace std + +#undef _GLIBCXX_BASE +#undef _GLIBCXX_STD_BASE + +#endif diff --git a/libstdc++-v3/include/profile/vector b/libstdc++-v3/include/profile/vector new file mode 100644 index 00000000000..d7d66f4b947 --- /dev/null +++ b/libstdc++-v3/include/profile/vector @@ -0,0 +1,339 @@ +// Profiling vector implementation -*- C++ -*- + +// Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 +// Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +/** @file profile/vector + * This file is a GNU profile extension to the Standard C++ Library. + */ + +#ifndef _GLIBCXX_PROFILE_VECTOR +#define _GLIBCXX_PROFILE_VECTOR 1 + +#include <vector> +#include <utility> +#include <profile/base.h> + +namespace std +{ +namespace __profile +{ + template<typename _Tp, + typename _Allocator = std::allocator<_Tp> > + class vector + : public _GLIBCXX_STD_PR::vector<_Tp, _Allocator> + { + typedef _GLIBCXX_STD_PR::vector<_Tp, _Allocator> _Base; + + public: + typedef typename _Base::reference reference; + typedef typename _Base::const_reference const_reference; + + typedef typename _Base::iterator iterator; + typedef typename _Base::const_iterator const_iterator; + + typedef typename _Base::size_type size_type; + typedef typename _Base::difference_type difference_type; + + typedef _Tp value_type; + typedef _Allocator allocator_type; + typedef typename _Base::pointer pointer; + typedef typename _Base::const_pointer const_pointer; + + _Base& + _M_base() { return *this; } + + const _Base& + _M_base() const { return *this; } + + // 23.2.4.1 construct/copy/destroy: + explicit vector(const _Allocator& __a = _Allocator()) + : _Base(__a) + { + __profcxx_vector_construct(this, this->capacity()); + } + + explicit vector(size_type __n, const _Tp& __value = _Tp(), + const _Allocator& __a = _Allocator()) + : _Base(__n, __value, __a) + { + __profcxx_vector_construct(this, this->capacity()); + } + + template<class _InputIterator> + vector(_InputIterator __first, _InputIterator __last, + const _Allocator& __a = _Allocator()) + : _Base(__first, __last, __a) + { + __profcxx_vector_construct(this, this->capacity()); + } + + vector(const vector& __x) + : _Base(__x) + { + __profcxx_vector_construct(this, this->capacity()); + } + + /// Construction from a release-mode vector + vector(const _Base& __x) + : _Base(__x) + { + __profcxx_vector_construct(this, this->capacity()); + } + +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + vector(vector&& __x) + : _Base(std::forward<vector>(__x)) + { + __profcxx_vector_construct(this, this->capacity()); + } +#endif + + ~vector() { + __profcxx_vector_destruct(this, this->capacity(), this->size()); + } + + vector& + operator=(const vector& __x) + { + static_cast<_Base&>(*this) = __x; + return *this; + } + +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + vector& + operator=(vector&& __x) + { + // NB: DR 675. + clear(); + swap(__x); + return *this; + } +#endif + + using _Base::get_allocator; + + // 23.2.4.2 capacity: + using _Base::size; + using _Base::max_size; + + void + resize(size_type __sz, _Tp __c = _Tp()) + { + profile_resize(this, this->capacity(), __sz); + _Base::resize(__sz, __c); + } + + using _Base::empty; + + // element access: + reference + operator[](size_type __n) + { + return _M_base()[__n]; + } + + const_reference + operator[](size_type __n) const + { + return _M_base()[__n]; + } + + using _Base::at; + + reference + front() + { + return _Base::front(); + } + + const_reference + front() const + { + return _Base::front(); + } + + reference + back() + { + return _Base::back(); + } + + const_reference + back() const + { + return _Base::back(); + } + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // DR 464. Suggestion for new member functions in standard containers. + using _Base::data; + + // 23.2.4.3 modifiers: + void + push_back(const _Tp& __x) + { + size_type old_size = this->capacity(); + _Base::push_back(__x); + profile_resize(this, old_size, this->capacity()); + } + +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + void + push_back(_Tp&& __x) + { + size_type old_size = this->capacity(); + _Base::push_back(__x); + profile_resize(this, old_size, this->capacity()); + } + +#endif + + iterator + insert(iterator __position, const _Tp& __x) + { + size_type old_size = this->capacity(); + typename _Base::iterator __res = _Base::insert(__position,__x); + profile_resize(this, old_size, this->capacity()); + return __res; + } + +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + iterator + insert(iterator __position, _Tp&& __x) + { + size_type old_size = this->capacity(); + typename _Base::iterator __res = _Base::insert(__position,__x); + profile_resize(this, old_size, this->capacity()); + return __res; + } +#endif + + void +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + swap(vector&& __x) +#else + swap(vector& __x) +#endif + { + _Base::swap(__x); + } + + + void + insert(iterator __position, size_type __n, const _Tp& __x) + { + size_type old_size = this->capacity(); + _Base::insert(__position, __n, __x); + profile_resize(this, old_size, this->capacity()); + } + + template<class _InputIterator> + void + insert(iterator __position, + _InputIterator __first, _InputIterator __last) + { + size_type old_size = this->capacity(); + _Base::insert(__position, __first, __last); + profile_resize(this, old_size, this->capacity()); + } + + void + clear() + { + __profcxx_vector_destruct(this, this->capacity(), this->size()); + _Base::clear(); + } + + private: + void profile_resize(void* obj, size_type old_size, size_type new_size) + { + if (old_size < new_size) { + __profcxx_vector_resize(this, old_size, new_size); + } + } + }; + + template<typename _Tp, typename _Alloc> + inline bool + operator==(const vector<_Tp, _Alloc>& __lhs, + const vector<_Tp, _Alloc>& __rhs) + { return __lhs._M_base() == __rhs._M_base(); } + + template<typename _Tp, typename _Alloc> + inline bool + operator!=(const vector<_Tp, _Alloc>& __lhs, + const vector<_Tp, _Alloc>& __rhs) + { return __lhs._M_base() != __rhs._M_base(); } + + template<typename _Tp, typename _Alloc> + inline bool + operator<(const vector<_Tp, _Alloc>& __lhs, + const vector<_Tp, _Alloc>& __rhs) + { return __lhs._M_base() < __rhs._M_base(); } + + template<typename _Tp, typename _Alloc> + inline bool + operator<=(const vector<_Tp, _Alloc>& __lhs, + const vector<_Tp, _Alloc>& __rhs) + { return __lhs._M_base() <= __rhs._M_base(); } + + template<typename _Tp, typename _Alloc> + inline bool + operator>=(const vector<_Tp, _Alloc>& __lhs, + const vector<_Tp, _Alloc>& __rhs) + { return __lhs._M_base() >= __rhs._M_base(); } + + template<typename _Tp, typename _Alloc> + inline bool + operator>(const vector<_Tp, _Alloc>& __lhs, + const vector<_Tp, _Alloc>& __rhs) + { return __lhs._M_base() > __rhs._M_base(); } + + template<typename _Tp, typename _Alloc> + inline void + swap(vector<_Tp, _Alloc>& __lhs, vector<_Tp, _Alloc>& __rhs) + { __lhs.swap(__rhs); } + +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + template<typename _Tp, typename _Alloc> + inline void + swap(vector<_Tp, _Alloc>&& __lhs, vector<_Tp, _Alloc>& __rhs) + { __lhs.swap(__rhs); } + + template<typename _Tp, typename _Alloc> + inline void + swap(vector<_Tp, _Alloc>& __lhs, vector<_Tp, _Alloc>&& __rhs) + { __lhs.swap(__rhs); } +#endif + +} // namespace __profile + using _GLIBCXX_STD_D::_S_word_bit; +} // namespace std + +#endif |