Commit e538847e by Paolo Carlini Committed by Paolo Carlini

hash_map: Move into __gnu_cxx, tweak, add using declarations.

2001-12-31  Paolo Carlini  <pcarlini@unitus.it>

	* include/ext/hash_map:  Move into __gnu_cxx,
	tweak, add using declarations.
	* include/ext/hash_set:  Ditto.
	* include/ext/ropeimpl.h:  Ditto.
	* include/ext/stl_hash_fun.h:  Ditto.
	* include/ext/stl_hashtable.h:  Ditto.
	* include/ext/stl_rope.h:  Ditto.
	* src/ext-inst.cc: Tweak.
	* testsuite/ext/rope.cc: Tweak.

From-SVN: r48422
parent a2ee9144
2001-12-31 Paolo Carlini <pcarlini@unitus.it> 2001-12-31 Paolo Carlini <pcarlini@unitus.it>
* include/ext/hash_map: Move into __gnu_cxx,
tweak, add using declarations.
* include/ext/hash_set: Ditto.
* include/ext/ropeimpl.h: Ditto.
* include/ext/stl_hash_fun.h: Ditto.
* include/ext/stl_hashtable.h: Ditto.
* include/ext/stl_rope.h: Ditto.
* src/ext-inst.cc: Tweak.
* testsuite/ext/rope.cc: Tweak.
2001-12-31 Paolo Carlini <pcarlini@unitus.it>
* include/backward/algo.h: Include <ext/algorithm>, * include/backward/algo.h: Include <ext/algorithm>,
tweak using declarations. tweak using declarations.
......
...@@ -64,8 +64,12 @@ ...@@ -64,8 +64,12 @@
#include <ext/stl_hashtable.h> #include <ext/stl_hashtable.h>
#include <bits/concept_check.h> #include <bits/concept_check.h>
namespace std namespace __gnu_cxx
{ {
using std::equal_to;
using std::allocator;
using std::pair;
using std::_Select1st;
// Forward declaration of equality operator; needed for friend declaration. // Forward declaration of equality operator; needed for friend declaration.
...@@ -371,14 +375,17 @@ swap(hash_multimap<_Key,_Tp,_HashFcn,_EqlKey,_Alloc>& __hm1, ...@@ -371,14 +375,17 @@ swap(hash_multimap<_Key,_Tp,_HashFcn,_EqlKey,_Alloc>& __hm1,
__hm1.swap(__hm2); __hm1.swap(__hm2);
} }
} // namespace __gnu_cxx
namespace std
{
// Specialization of insert_iterator so that it will work for hash_map // Specialization of insert_iterator so that it will work for hash_map
// and hash_multimap. // and hash_multimap.
template <class _Key, class _Tp, class _HashFn, class _EqKey, class _Alloc> template <class _Key, class _Tp, class _HashFn, class _EqKey, class _Alloc>
class insert_iterator<hash_map<_Key, _Tp, _HashFn, _EqKey, _Alloc> > { class insert_iterator<__gnu_cxx::hash_map<_Key, _Tp, _HashFn, _EqKey, _Alloc> > {
protected: protected:
typedef hash_map<_Key, _Tp, _HashFn, _EqKey, _Alloc> _Container; typedef __gnu_cxx::hash_map<_Key, _Tp, _HashFn, _EqKey, _Alloc> _Container;
_Container* container; _Container* container;
public: public:
typedef _Container container_type; typedef _Container container_type;
...@@ -402,9 +409,9 @@ public: ...@@ -402,9 +409,9 @@ public:
}; };
template <class _Key, class _Tp, class _HashFn, class _EqKey, class _Alloc> template <class _Key, class _Tp, class _HashFn, class _EqKey, class _Alloc>
class insert_iterator<hash_multimap<_Key, _Tp, _HashFn, _EqKey, _Alloc> > { class insert_iterator<__gnu_cxx::hash_multimap<_Key, _Tp, _HashFn, _EqKey, _Alloc> > {
protected: protected:
typedef hash_multimap<_Key, _Tp, _HashFn, _EqKey, _Alloc> _Container; typedef __gnu_cxx::hash_multimap<_Key, _Tp, _HashFn, _EqKey, _Alloc> _Container;
_Container* container; _Container* container;
typename _Container::iterator iter; typename _Container::iterator iter;
public: public:
......
...@@ -64,8 +64,12 @@ ...@@ -64,8 +64,12 @@
#include <ext/stl_hashtable.h> #include <ext/stl_hashtable.h>
#include <bits/concept_check.h> #include <bits/concept_check.h>
namespace std namespace __gnu_cxx
{ {
using std::equal_to;
using std::allocator;
using std::pair;
using std::_Identity;
// Forward declaration of equality operator; needed for friend declaration. // Forward declaration of equality operator; needed for friend declaration.
...@@ -361,13 +365,17 @@ swap(hash_multiset<_Val,_HashFcn,_EqualKey,_Alloc>& __hs1, ...@@ -361,13 +365,17 @@ swap(hash_multiset<_Val,_HashFcn,_EqualKey,_Alloc>& __hs1,
__hs1.swap(__hs2); __hs1.swap(__hs2);
} }
} // namespace __gnu_cxx
namespace std
{
// Specialization of insert_iterator so that it will work for hash_set // Specialization of insert_iterator so that it will work for hash_set
// and hash_multiset. // and hash_multiset.
template <class _Value, class _HashFcn, class _EqualKey, class _Alloc> template <class _Value, class _HashFcn, class _EqualKey, class _Alloc>
class insert_iterator<hash_set<_Value, _HashFcn, _EqualKey, _Alloc> > { class insert_iterator<__gnu_cxx::hash_set<_Value, _HashFcn, _EqualKey, _Alloc> > {
protected: protected:
typedef hash_set<_Value, _HashFcn, _EqualKey, _Alloc> _Container; typedef __gnu_cxx::hash_set<_Value, _HashFcn, _EqualKey, _Alloc> _Container;
_Container* container; _Container* container;
public: public:
typedef _Container container_type; typedef _Container container_type;
...@@ -391,9 +399,9 @@ public: ...@@ -391,9 +399,9 @@ public:
}; };
template <class _Value, class _HashFcn, class _EqualKey, class _Alloc> template <class _Value, class _HashFcn, class _EqualKey, class _Alloc>
class insert_iterator<hash_multiset<_Value, _HashFcn, _EqualKey, _Alloc> > { class insert_iterator<__gnu_cxx::hash_multiset<_Value, _HashFcn, _EqualKey, _Alloc> > {
protected: protected:
typedef hash_multiset<_Value, _HashFcn, _EqualKey, _Alloc> _Container; typedef __gnu_cxx::hash_multiset<_Value, _HashFcn, _EqualKey, _Alloc> _Container;
_Container* container; _Container* container;
typename _Container::iterator iter; typename _Container::iterator iter;
public: public:
......
...@@ -49,8 +49,17 @@ ...@@ -49,8 +49,17 @@
#include <bits/std_iostream.h> #include <bits/std_iostream.h>
#include <bits/functexcept.h> #include <bits/functexcept.h>
namespace std namespace __gnu_cxx
{ {
using std::size_t;
using std::printf;
using std::basic_ostream;
using std::__throw_length_error;
using std::__alloc;
using std::_Destroy;
using std::uninitialized_fill_n;
using std::lexicographical_compare_3way;
using std::uninitialized_copy_n;
// Set buf_start, buf_end, and buf_ptr appropriately, filling tmp_buf // Set buf_start, buf_end, and buf_ptr appropriately, filling tmp_buf
// if necessary. Assumes _M_path_end[leaf_index] and leaf_pos are correct. // if necessary. Assumes _M_path_end[leaf_index] and leaf_pos are correct.
...@@ -837,13 +846,13 @@ bool rope<_CharT, _Alloc>::_S_apply_to_pieces( ...@@ -837,13 +846,13 @@ bool rope<_CharT, _Alloc>::_S_apply_to_pieces(
_RopeRep* __left = __conc->_M_left; _RopeRep* __left = __conc->_M_left;
size_t __left_len = __left->_M_size; size_t __left_len = __left->_M_size;
if (__begin < __left_len) { if (__begin < __left_len) {
size_t __left_end = min(__left_len, __end); size_t __left_end = std::min(__left_len, __end);
if (!_S_apply_to_pieces(__c, __left, __begin, __left_end)) if (!_S_apply_to_pieces(__c, __left, __begin, __left_end))
return false; return false;
} }
if (__end > __left_len) { if (__end > __left_len) {
_RopeRep* __right = __conc->_M_right; _RopeRep* __right = __conc->_M_right;
size_t __right_start = max(__left_len, __begin); size_t __right_start = std::max(__left_len, __begin);
if (!_S_apply_to_pieces(__c, __right, if (!_S_apply_to_pieces(__c, __right,
__right_start - __left_len, __right_start - __left_len,
__end - __left_len)) { __end - __left_len)) {
...@@ -901,7 +910,7 @@ basic_ostream<_CharT, _Traits>& operator<< (basic_ostream<_CharT, _Traits>& __o, ...@@ -901,7 +910,7 @@ basic_ostream<_CharT, _Traits>& operator<< (basic_ostream<_CharT, _Traits>& __o,
const rope<_CharT, _Alloc>& __r) const rope<_CharT, _Alloc>& __r)
{ {
size_t __w = __o.width(); size_t __w = __o.width();
bool __left = bool(__o.flags() & ios::left); bool __left = bool(__o.flags() & std::ios::left);
size_t __pad_len; size_t __pad_len;
size_t __rope_len = __r.size(); size_t __rope_len = __r.size();
_Rope_insert_char_consumer<_CharT, _Traits> __c(__o); _Rope_insert_char_consumer<_CharT, _Traits> __c(__o);
...@@ -974,7 +983,7 @@ rope<_CharT,_Alloc>::_S_flatten(_RopeRep* __r, _CharT* __buffer) ...@@ -974,7 +983,7 @@ rope<_CharT,_Alloc>::_S_flatten(_RopeRep* __r, _CharT* __buffer)
case _RopeRep::_S_leaf: case _RopeRep::_S_leaf:
{ {
_RopeLeaf* __l = (_RopeLeaf*)__r; _RopeLeaf* __l = (_RopeLeaf*)__r;
return copy_n(__l->_M_data, __l->_M_size, __buffer).second; return std::copy_n(__l->_M_data, __l->_M_size, __buffer).second;
} }
case _RopeRep::_S_function: case _RopeRep::_S_function:
case _RopeRep::_S_substringfn: case _RopeRep::_S_substringfn:
...@@ -1449,7 +1458,7 @@ const _CharT* rope<_CharT,_Alloc>::c_str() const { ...@@ -1449,7 +1458,7 @@ const _CharT* rope<_CharT,_Alloc>::c_str() const {
_M_tree_ptr->_M_c_string = __result; _M_tree_ptr->_M_c_string = __result;
# else # else
if ((__old_c_string = (__GC_CONST _CharT*) if ((__old_c_string = (__GC_CONST _CharT*)
_Atomic_swap((unsigned long *)(&(_M_tree_ptr->_M_c_string)), std::_Atomic_swap((unsigned long *)(&(_M_tree_ptr->_M_c_string)),
(unsigned long)__result)) != 0) { (unsigned long)__result)) != 0) {
// It must have been added in the interim. Hence it had to have been // It must have been added in the interim. Hence it had to have been
// separately allocated. Deallocate the old copy, since we just // separately allocated. Deallocate the old copy, since we just
...@@ -1530,7 +1539,7 @@ inline void rotate( ...@@ -1530,7 +1539,7 @@ inline void rotate(
} }
# endif # endif
} // namespace std } // namespace __gnu_cxx
// Local Variables: // Local Variables:
// mode:C++ // mode:C++
......
...@@ -63,8 +63,9 @@ ...@@ -63,8 +63,9 @@
#include <bits/std_cstddef.h> #include <bits/std_cstddef.h>
namespace std namespace __gnu_cxx
{ {
using std::size_t;
template <class _Key> struct hash { }; template <class _Key> struct hash { };
...@@ -115,7 +116,7 @@ template<> struct hash<unsigned long> { ...@@ -115,7 +116,7 @@ template<> struct hash<unsigned long> {
size_t operator()(unsigned long __x) const { return __x; } size_t operator()(unsigned long __x) const { return __x; }
}; };
} // namespace std } // namespace __gnu_cxx
#endif /* _CPP_BITS_STL_HASH_FUN_H */ #endif /* _CPP_BITS_STL_HASH_FUN_H */
......
...@@ -74,8 +74,18 @@ ...@@ -74,8 +74,18 @@
#include <bits/stl_vector.h> #include <bits/stl_vector.h>
#include <ext/stl_hash_fun.h> #include <ext/stl_hash_fun.h>
namespace std namespace __gnu_cxx
{ {
using std::size_t;
using std::ptrdiff_t;
using std::forward_iterator_tag;
using std::input_iterator_tag;
using std::_Alloc_traits;
using std::_Construct;
using std::_Destroy;
using std::distance;
using std::vector;
using std::pair;
template <class _Val> template <class _Val>
struct _Hashtable_node struct _Hashtable_node
...@@ -85,7 +95,7 @@ struct _Hashtable_node ...@@ -85,7 +95,7 @@ struct _Hashtable_node
}; };
template <class _Val, class _Key, class _HashFcn, template <class _Val, class _Key, class _HashFcn,
class _ExtractKey, class _EqualKey, class _Alloc = __alloc> class _ExtractKey, class _EqualKey, class _Alloc = std::__alloc>
class hashtable; class hashtable;
template <class _Val, class _Key, class _HashFcn, template <class _Val, class _Key, class _HashFcn,
...@@ -188,7 +198,7 @@ inline unsigned long __stl_next_prime(unsigned long __n) ...@@ -188,7 +198,7 @@ inline unsigned long __stl_next_prime(unsigned long __n)
{ {
const unsigned long* __first = __stl_prime_list; const unsigned long* __first = __stl_prime_list;
const unsigned long* __last = __stl_prime_list + (int)__stl_num_primes; const unsigned long* __last = __stl_prime_list + (int)__stl_num_primes;
const unsigned long* pos = lower_bound(__first, __last, __n); const unsigned long* pos = std::lower_bound(__first, __last, __n);
return pos == __last ? *(__last - 1) : *pos; return pos == __last ? *(__last - 1) : *pos;
} }
...@@ -964,7 +974,7 @@ void hashtable<_Val,_Key,_HF,_Ex,_Eq,_All> ...@@ -964,7 +974,7 @@ void hashtable<_Val,_Key,_HF,_Ex,_Eq,_All>
} }
} }
} // namespace std } // namespace __gnu_cxx
#endif /* __SGI_STL_INTERNAL_HASHTABLE_H */ #endif /* __SGI_STL_INTERNAL_HASHTABLE_H */
......
...@@ -61,8 +61,17 @@ ...@@ -61,8 +61,17 @@
# define __GC_CONST // constant except for deallocation # define __GC_CONST // constant except for deallocation
# endif # endif
namespace std namespace __gnu_cxx
{ {
using std::size_t;
using std::ptrdiff_t;
using std::allocator;
using std::iterator;
using std::reverse_iterator;
using std::_Alloc_traits;
using std::_Destroy;
using std::_Refcount_Base;
using std::uninitialized_copy_n;
// The _S_eos function is used for those functions that // The _S_eos function is used for those functions that
// convert to/from C-like strings to detect the end of the string. // convert to/from C-like strings to detect the end of the string.
...@@ -122,7 +131,7 @@ class char_producer { ...@@ -122,7 +131,7 @@ class char_producer {
// little like containers. // little like containers.
template<class _Sequence, size_t _Buf_sz = 100> template<class _Sequence, size_t _Buf_sz = 100>
class sequence_buffer : public iterator<output_iterator_tag,void,void,void,void> class sequence_buffer : public iterator<std::output_iterator_tag,void,void,void,void>
{ {
public: public:
typedef typename _Sequence::value_type value_type; typedef typename _Sequence::value_type value_type;
...@@ -316,7 +325,7 @@ rope<_CharT,_Alloc> operator+ (const rope<_CharT,_Alloc>& __left, ...@@ -316,7 +325,7 @@ rope<_CharT,_Alloc> operator+ (const rope<_CharT,_Alloc>& __left,
// The result has refcount 0. // The result has refcount 0.
template<class _CharT, class _Alloc> template<class _CharT, class _Alloc>
struct _Rope_Concat_fn struct _Rope_Concat_fn
: public binary_function<rope<_CharT,_Alloc>, rope<_CharT,_Alloc>, : public std::binary_function<rope<_CharT,_Alloc>, rope<_CharT,_Alloc>,
rope<_CharT,_Alloc> > { rope<_CharT,_Alloc> > {
rope<_CharT,_Alloc> operator() (const rope<_CharT,_Alloc>& __x, rope<_CharT,_Alloc> operator() (const rope<_CharT,_Alloc>& __x,
const rope<_CharT,_Alloc>& __y) { const rope<_CharT,_Alloc>& __y) {
...@@ -601,7 +610,7 @@ struct _Rope_RopeConcatenation : public _Rope_RopeRep<_CharT,_Alloc> { ...@@ -601,7 +610,7 @@ struct _Rope_RopeConcatenation : public _Rope_RopeRep<_CharT,_Alloc> {
allocator_type __a) allocator_type __a)
: _Rope_RopeRep<_CharT,_Alloc>(_S_concat, : _Rope_RopeRep<_CharT,_Alloc>(_S_concat,
max(__l->_M_depth, __r->_M_depth) + 1, std::max(__l->_M_depth, __r->_M_depth) + 1,
false, false,
__l->_M_size + __r->_M_size, __a), __l->_M_size + __r->_M_size, __a),
_M_left(__l), _M_right(__r) _M_left(__l), _M_right(__r)
...@@ -838,7 +847,7 @@ class _Rope_char_ptr_proxy { ...@@ -838,7 +847,7 @@ class _Rope_char_ptr_proxy {
template<class _CharT, class _Alloc> template<class _CharT, class _Alloc>
class _Rope_iterator_base class _Rope_iterator_base
: public iterator<random_access_iterator_tag, _CharT> : public iterator<std::random_access_iterator_tag, _CharT>
{ {
friend class rope<_CharT,_Alloc>; friend class rope<_CharT,_Alloc>;
public: public:
...@@ -1538,7 +1547,7 @@ class rope : public _Rope_base<_CharT,_Alloc> { ...@@ -1538,7 +1547,7 @@ class rope : public _Rope_base<_CharT,_Alloc> {
{ {
_CharT* __buf = _Data_allocate(_S_rounded_up_size(1)); _CharT* __buf = _Data_allocate(_S_rounded_up_size(1));
_Construct(__buf, __c); std::_Construct(__buf, __c);
try { try {
_M_tree_ptr = _S_new_RopeLeaf(__buf, 1, __a); _M_tree_ptr = _S_new_RopeLeaf(__buf, 1, __a);
} }
...@@ -2107,8 +2116,9 @@ class rope : public _Rope_base<_CharT,_Alloc> { ...@@ -2107,8 +2116,9 @@ class rope : public _Rope_base<_CharT,_Alloc> {
size_type find(_CharT __c, size_type __pos = 0) const; size_type find(_CharT __c, size_type __pos = 0) const;
size_type find(const _CharT* __s, size_type __pos = 0) const { size_type find(const _CharT* __s, size_type __pos = 0) const {
size_type __result_pos; size_type __result_pos;
const_iterator __result = search(const_begin() + __pos, const_end(), const_iterator __result =
__s, __s + _S_char_ptr_len(__s)); std::search(const_begin() + __pos, const_end(),
__s, __s + _S_char_ptr_len(__s));
__result_pos = __result.index(); __result_pos = __result.index();
# ifndef __STL_OLD_ROPE_SEMANTICS # ifndef __STL_OLD_ROPE_SEMANTICS
if (__result_pos == size()) __result_pos = npos; if (__result_pos == size()) __result_pos = npos;
...@@ -2429,8 +2439,8 @@ inline bool operator!= (const _Rope_char_ptr_proxy<_CharT,_Alloc>& __x, ...@@ -2429,8 +2439,8 @@ inline bool operator!= (const _Rope_char_ptr_proxy<_CharT,_Alloc>& __x,
} }
template<class _CharT, class _Traits, class _Alloc> template<class _CharT, class _Traits, class _Alloc>
basic_ostream<_CharT, _Traits>& operator<< std::basic_ostream<_CharT, _Traits>& operator<<
(basic_ostream<_CharT, _Traits>& __o, (std::basic_ostream<_CharT, _Traits>& __o,
const rope<_CharT, _Alloc>& __r); const rope<_CharT, _Alloc>& __r);
typedef rope<char> crope; typedef rope<char> crope;
...@@ -2475,7 +2485,7 @@ template<> struct hash<wrope> ...@@ -2475,7 +2485,7 @@ template<> struct hash<wrope>
} }
}; };
} // namespace std } // namespace __gnu_cxx
# include <ext/ropeimpl.h> # include <ext/ropeimpl.h>
......
...@@ -35,5 +35,6 @@ ...@@ -35,5 +35,6 @@
namespace std namespace std
{ {
template const unsigned long rope<char, std::allocator<char> >::_S_min_len; template
const unsigned long __gnu_cxx::rope<char, std::allocator<char> >::_S_min_len;
} // namespace std } // namespace std
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
void test01() void test01()
{ {
std::crope foo; __gnu_cxx::crope foo;
foo += "bar"; foo += "bar";
const char* data = foo.c_str(); const char* data = foo.c_str();
std::cout << data << std::endl; std::cout << data << std::endl;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment