User Manual, Developers Guide and API Documentation

pointerhashset.hpp

Go to the documentation of this file.
00001 /*******************************************************************************
00002  * This file is part of openWNS (open Wireless Network Simulator)
00003  * _____________________________________________________________________________
00004  *
00005  * Copyright (C) 2004-2007
00006  * Chair of Communication Networks (ComNets)
00007  * Kopernikusstr. 5, D-52074 Aachen, Germany
00008  * phone: ++49-241-80-27910,
00009  * fax: ++49-241-80-22242
00010  * email: info@openwns.org
00011  * www: http://www.openwns.org
00012  * _____________________________________________________________________________
00013  *
00014  * openWNS is free software; you can redistribute it and/or modify it under the
00015  * terms of the GNU Lesser General Public License version 2 as published by the
00016  * Free Software Foundation;
00017  *
00018  * openWNS is distributed in the hope that it will be useful, but WITHOUT ANY
00019  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
00020  * A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
00021  * details.
00022  *
00023  * You should have received a copy of the GNU Lesser General Public License
00024  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
00025  *
00026  ******************************************************************************/
00027 
00028 #ifndef _POINTERHASHSET_HPP
00029 #define _POINTERHASHSET_HPP
00030 
00031 #include <functional>
00032 #ifndef WNS_USE_STLPORT
00033 #include <ext/hash_set>
00034 #else
00035 #include <hash_set>
00036 #endif
00037 #include <WNS/SmartPtr.hpp>
00038 
00039 namespace rise {
00041 
00042     template<class Key>
00043     class PointerHashSetFunctor :
00044 #ifndef WNS_USE_STLPORT
00045         public __gnu_cxx::hash<Key const>
00046 #else
00047         public std::hash<Key const>
00048 #endif
00049     {
00050     public:
00051         ptrdiff_t operator()(Key const k) const
00052         {
00053             return ((ptrdiff_t)(k));
00054         };
00055     };
00056 
00058     template<class Key>
00059     class PointerHashSetFunctor<wns::SmartPtr<Key> > :
00060 #ifndef WNS_USE_STLPORT
00061         public __gnu_cxx::hash<Key* const>
00062 #else
00063         public std::hash<Key* const>
00064 #endif
00065     {
00066     public:
00067         ptrdiff_t operator()(wns::SmartPtr<Key> const k) const
00068         {
00069             return ((ptrdiff_t)(k.get()));
00070         };
00071     };
00072 
00074     template<class Key>
00075     class PointerHashSet :
00076 #ifndef WNS_USE_STLPORT
00077         public __gnu_cxx::hash_set<Key,
00078 #else
00079         public std::hash_set<Key,
00080 #endif
00081                                    PointerHashSetFunctor<Key>,
00082                                    std::equal_to<Key> > {
00083     public:
00084         PointerHashSet() :
00085 #ifndef WNS_USE_STLPORT
00086             __gnu_cxx::hash_set<Key,
00087 #else
00088             std::hash_set<Key,
00089 #endif
00090                                 PointerHashSetFunctor<Key>,
00091                                 std::equal_to<Key> >() {};
00092 
00093         virtual ~PointerHashSet() {};
00094 
00095         virtual bool containsKey(Key k) const
00096         {
00097             return this->find(k)!=this->end();
00098         };
00099     };
00100 
00101 }
00102 #endif
00103 
00104 

Generated on Sun May 27 03:31:56 2012 for openWNS by  doxygen 1.5.5