Biorithm  1.1
 All Classes Functions Variables Typedefs Friends
ItemsetCompare.h
00001 /**************************************************************************
00002  * Copyright (c) 2007 Clifford Conley Owens III                           *
00003  *                                                                        *
00004  * This file is part of Biorithm.                                         *
00005  *                                                                        *
00006  * Biorithm is free software: you can redistribute it and/or modify       *
00007  * it under the terms of the GNU General Public License as published by   *
00008  * the Free Software Foundation, either version 3 of the License, or      *
00009  * (at your option) any later version.                                    *
00010  *                                                                        *
00011  * Biorithm is distributed in the hope that it will be useful,            *
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of         *
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
00014  * GNU General Public License for more details.                           *
00015  *                                                                        *
00016  * You should have received a copy of the GNU General Public License      *
00017  * along with Biorithm.  If not, see <http://www.gnu.org/licenses/>.      *
00018  *                                                                        *
00019  **************************************************************************/
00020 
00031 #ifndef ITEMSETCOMPARE_H
00032 #define ITEMSETCOMPARE_H
00033 
00034 // ---------------------------- Internal Headers ---------------------------- //
00035 
00036 #include "Itemset.h"
00037 
00038 int compare(const Itemset* is1, const Itemset* is2);
00039 
00040 // The hash template
00041 template<typename T> struct hash
00042 {
00043 
00044 };
00045 
00046 // The less than template
00047 template<typename T> struct ltis
00048 {
00049 
00050 };
00051 
00052 // The less than operator
00053 template<> struct ltis<const Itemset*>
00054 {
00055     bool operator()(const Itemset* is1, const Itemset* is2) const
00056     {
00057         if (is1 && is2)
00058         {
00059             return compare(is1, is2) < 0;
00060         }
00061         return false;
00062     }
00063 };
00064 
00065 // The hash function
00066 template<> struct hash<const Itemset*>
00067 {
00068    size_t operator()(const Itemset* is) const
00069    {
00070       unsigned long ret = 0;
00071       for (unsigned int i = 0; i < (*is).getSize(); i++)
00072       {
00073           ret = (113 * ret) + (*is)[i];
00074       }
00075       return (size_t)ret;
00076    }
00077 };
00078 
00079 // The equal function
00080 struct eqis
00081 {
00082     bool operator()(const Itemset* is1, const Itemset* is2) const
00083     {
00084         if (is1 && is2)
00085         {
00086             return !compare(is1, is2);
00087         }
00088         return false;
00089     }
00090 };
00091 
00092 #endif
00093 
 All Classes Functions Variables Typedefs Friends