[an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive]
 
[an error occurred while processing this directive] [an error occurred while processing this directive]
Skåne Sjælland Linux User Group - http://www.sslug.dk Home   Subscribe   Mail Archive   Forum   Calendar   Search
MhonArc Date: [Date Prev] [Date Index] [Date Next]   Thread: [Date Prev] [Thread Index] [Date Next]   MhonArc
 

Re: [PROGRAMMERING] C++ hashtable hjælp



Martin Møller Pedersen wrote:

> Hejsa,
>
>  Jeg programmerer i C++ og bruger g++ (GCC) 4.1.2.
>
>
> class Traxboard {
>  public:
>    bool operator==(const Traxboard& another) const;
>    bool operator<(const Traxboard& another) const;
>    int getHash() const;
> }
>
> Jeg ønsker at gemme en masse objekter af typen Traxboard i en
> hashtable og bruge værdien fra getHash() som hash-funktionen for
> hashtablen.
>
> Indtil videre har jeg har fundet ud af at det ikke findes i STL
> (endnu), men at der er på vej[1]. Ifølge gcc-dokumentationen kan man
> bruge unordered_set til mit formål, men hvordan ? Jeg har kigget i
> dokumentionen, men forstår den ikke rigtigt[2].
>
> Hvad definerer jeg en unordered_set korrekt i dette tilfælde ?
>
> /Martin
>
> [1]: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2003/n1456.html
> [2]:
> http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/classstd_1_1tr1_1_1unordered__set.html
>
>
Du kan vel bruge en STL map !

#include <map>

typedef std::map<int, Traxboard*> TraxboardMap;

TraxboardMap myMap;
myMap[myTraxboardObject.getHash()] = &myTraxboardObject;



 
Home   Subscribe   Mail Archive   Index   Calendar   Search

 
 
Questions about the web-pages to <www_admin>. Last modified 2007-05-01, 02:01 CEST [an error occurred while processing this directive]
This page is maintained by [an error occurred while processing this directive]MHonArc [an error occurred while processing this directive] # [an error occurred while processing this directive] *