/* -*- C++ -*- */
/*************************************************************************
 * Copyright(c) 1995~2005  Masaharu Goto (cint@pcroot.cern.ch)
 *
 * For the licensing terms see the file COPYING
 *
 ************************************************************************/
// lib/prec_stl/map

#pragma ifndef PREC_STL_MAP
#pragma define PREC_STL_MAP
#pragma link off global PREC_STL_MAP;
#pragma link C++ nestedtypedef;
#pragma link C++ nestedclass;
#if defined(G__HP_aCC) || defined(G__SUNPRO_CC)
#pragma mask_newdelete 0x1c;
#else
#pragma mask_newdelete 0x10;
#endif

// Imported from ANSI/ISO C++ 1997/Nov draft 
// Got some ideas from Scott Snyder, Fermi-lab
// Modified by Masaharu Goto
// SGI KCC porting by Philippe Canal, Fermi-lab

#include <_utility>
#include <_memory>
#include <_iterator>
#include <_functional>

//////////////////////////////////////////////////////////////////////////
#if defined(G__ANSIISOLIB) || (G__GNUC>=3) || defined(G__INTEL_COMPILER) || defined(G__KCC)
template<class Key,class T,class Compare=std::less<Key>
        ,class Allocator=std::allocator<pair<const Key, T> > >

#elif defined (G__VISUAL) && (G__MSC_VER>=1300)
template<class Key,class T,class Compare=std::less<Key>
        ,class Allocator=std::allocator<pair<const Key, T> > >

#elif defined(G__SUNPRO_CC) && (G__SUNPRO_CC>=0x500)
template<class Key,class T,class Compare=std::less<Key>
        ,class Allocator=std::allocator<pair<const Key, T> > >

#elif defined(G__GNUC) && !defined(G__KCC)

#if (G__GNUC_VER>=2095)
template<class Key,class T,class Compare=std::less<Key>
        ,class Allocator=allocator<T> >
#else
template<class Key,class T,class Compare=std::less<Key>
        ,class Allocator=alloc>
#endif

#elif defined(G__HPUX)
template<class Key,class T,class Compare=std::less<Key>
        ,class Allocator=allocator>

#else
template<class Key,class T,class Compare=std::less<Key>
        ,class Allocator=std::allocator<T> >
        //,class Allocator=std::allocator<pair<const Key,T> > >
#endif
class map {
 public:
  typedef Key                                       key_type;
  typedef T                                         mapped_type;
#if defined(G__VISUAL) && (G__MSC_VER>=1310)
  typedef pair<const Key,T>                         value_type;
#else
  typedef pair<Key,T>                               value_type;
#endif
  typedef Compare                                   key_compare;
  typedef Allocator                                 allocator_type;
#if (defined(G__GNUC) && !defined(G__KCC)) || defined(G__HPUX)
  //typedef Key*                                     pointer;
  //typedef const Key*                               const_pointer;
  //typedef Key&                                     reference;
  //typedef const Key&                               const_reference;
  typedef size_t                                   size_type;
  typedef ptrdiff_t                                difference_type;
#else
  typedef typename Allocator::pointer               pointer;
  typedef typename Allocator::const_pointer         const_pointer;
  typedef typename Allocator::reference             reference;
  typedef typename Allocator::const_reference       const_reference;
  typedef typename Allocator::size_type             size_type;
  typedef typename Allocator::difference_type       difference_type;
#endif

  class iterator 
#if defined(G__VISUAL) && (G__MSC_VER>=1300)
#elif defined(G__VISUAL)
	: public _Bidit<T,difference_type> 
#elif defined(G__SUNPRO_CC) || defined(G__BORLANDCC5)
#elif (G__GNUC_VER>=3001)
#elif defined(G__INTEL_COMPILER)
#elif defined(G__KCC)
#elif defined(G__AIX)
#elif defined(G__ALPHA)
#else
  	: public bidirectional_iterator<T,difference_type> 
#endif
	{
   public:
    iterator() ;
    iterator(const iterator& x) ;
#if !defined(G__BORLAND) && !defined(G__KCC) && !(defined (G__SGI)&&!defined(G__GNU)) && !defined(G__ALPHA)
    iterator& operator=(const iterator& x) ;
#endif
    value_type& operator*() ;
#ifndef G__OLDIMPLEMENTATION2019
    value_type* operator->() ;
#endif
    iterator& operator++();
    iterator operator++(int a);
    iterator& operator--();
    iterator operator--(int a);
#if defined (G__VISUAL) || (defined(G__GNUC_VER) && G__GNUC_VER>=3004) || defined(G__INTEL_COMPILER)
    bool operator==(const iterator& x) ;
    bool operator!=(const iterator& x) ;
#endif
#ifdef G__HPUX
    bool operator==(const iterator& x) ;
#endif
  };
#if defined(G__GNUC) && !defined(G__KCC) && !defined(G__INTEL_COMPILER)  && !(G__GNUC_VER>=3004)
  friend bool operator==(const map::iterator& x ,const map::iterator& y) const;
  friend bool operator!=(const map::iterator& x ,const map::iterator& y) const;
#endif
#ifdef G__HPUX
  friend bool operator!=(const map::iterator& x,const map::iterator& y)const;
#endif

  class reverse_iterator 
#if defined(G__VISUAL) && (G__MSC_VER>=1300)
#elif defined(G__VISUAL)
	: public _Bidit<T,difference_type> 
#elif defined(G__SUNPRO_CC) || defined(G__BORLANDCC5)
#elif (G__GNUC_VER>=3001)
#elif defined(G__INTEL_COMPILER)
#elif defined(G__KCC)
#elif defined(G__AIX)
#elif defined(G__ALPHA)
#else
  	: public bidirectional_iterator<T,difference_type> 
#endif
	{
   public:
    reverse_iterator(const reverse_iterator& x);
#if !defined(G__BORLAND) && !defined(G__KCC) && !(defined (G__SGI)&&!defined(G__GNU)) && !defined(G__ALPHA)
    reverse_iterator& operator=(const reverse_iterator& x) ;
#endif
    value_type& operator*() ;
#ifndef G__OLDIMPLEMENTATION2019
    value_type* operator->() ;
#endif
    reverse_iterator& operator++();
    reverse_iterator operator++(int a);
    reverse_iterator& operator--();
    reverse_iterator operator--(int a);
   private:
  };
#ifndef G__INTEL_COMPILER
  friend bool operator==(const map::reverse_iterator& x
                        ,const map::reverse_iterator& y) const;
  friend bool operator!=(const map::reverse_iterator& x
                        ,const map::reverse_iterator& y) const;
#endif

  typedef const iterator const_iterator;
  typedef const reverse_iterator const_reverse_iterator;

  // _lib.map.cons_ construct/copy/destroy:
  map();
#if 0
  template <class InputIterator>
    map(InputIterator first, InputIterator last,
     const Compare& comp = Compare(), const Allocator& = Allocator());
#endif
#if defined(G__GNUC) || defined(G__KCC)
  map(iterator first, iterator last);
  map(reverse_iterator first, reverse_iterator last);
#endif
  map(const map& x);
  ~map();
  map& operator=(const map& x);
  // iterators:
  iterator               begin();
  iterator               end();
  reverse_iterator       rbegin();
  reverse_iterator       rend();
#ifdef G__CONSTNESSFLAG
  const_iterator begin(void) const;
  const_iterator end(void) const;
  const_reverse_iterator rbegin(void) const;
  const_reverse_iterator rend(void) const;
#endif
  // capacity:
  bool      empty() const;
  size_type size() const;
  size_type max_size() const;
  // _lib.map.access_ element access:
  T& operator[](const Key& x);
  // modifiers:
  pair<map::iterator, bool> insert(const value_type& x);
  iterator             insert(iterator position, const value_type& x);
#if defined(G__KCC)
  template <class InputIterator>
   void insert(InputIterator first, InputIterator last);
#endif
#if defined(G__GNUC) && !defined (G__KCC)
  void insert(iterator first, iterator last);
  void insert(reverse_iterator first, reverse_iterator last);
#endif
  void      erase(iterator position);
  size_type erase(const Key& x);
  void      erase(iterator first, iterator last);
  void swap(map&);
  void clear();
  // observers:
  //key_compare   key_comp() const;
  //value_compare value_comp() const;
  // _lib.map.ops_ map operations:
  iterator       find(const Key& x);
  //const_iterator find(const Key& x) const;
  size_type      count(const Key& x) const;
  iterator       lower_bound(const Key& x);
  //const_iterator lower_bound(const Key& x) const;
  iterator       upper_bound(const Key& x);
  //const_iterator upper_bound(const Key& x) const;
#if 0
  pair<iterator,iterator> equal_range(const Key& x);
  pair<const_iterator,const_iterator> equal_range(const Key& x) const;
#endif

  friend bool operator==(const map& x, const map& y);
  friend bool operator< (const map& x, const map& y);
  friend bool operator!=(const map& x, const map& y);
  friend bool operator> (const map& x, const map& y);
  friend bool operator>=(const map& x, const map& y);
  friend bool operator<=(const map& x, const map& y);
  // specialized algorithms:
#if !defined(G__GNUC) && !defined(G__KCC)
  // doesn't work on egcs nor VC++5.0
  //friend void swap(map& x, map& y);
#endif

#pragma ifndef G__NOALGORITHM
  // Generic algorithm
  friend map::iterator
    search(map::iterator first1,map::iterator last1,
           map::iterator first2,map::iterator last2);
#pragma endif // G__NOALGORITHM

  // iterator_category resolution
  //friend bidirectional_iterator_tag iterator_category(map::iterator x);

};

//////////////////////////////////////////////////////////////////////////

#pragma endif
