Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members

IntKey.H

Go to the documentation of this file.
00001 // Copyright (C) 2001, Compaq Computer Corporation
00002 
00003 // This file is part of Vesta.
00004 
00005 // Vesta is free software; you can redistribute it and/or
00006 // modify it under the terms of the GNU Lesser General Public
00007 // License as published by the Free Software Foundation; either
00008 // version 2.1 of the License, or (at your option) any later version.
00009 
00010 // Vesta is distributed in the hope that it will be useful,
00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013 // Lesser General Public License for more details.
00014 
00015 // You should have received a copy of the GNU Lesser General Public
00016 // License along with Vesta; if not, write to the Free Software
00017 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00018 
00019 // Last modified on Tue May 25 19:40:48 EDT 2004 by ken@xorian.net
00020 //      modified on Mon May  3 16:04:45 PDT 1999 by heydon
00021 
00022 // IntKey -- an integer class that can be used as the key of a Riviera table
00023 
00024 #ifndef _INT_KEY_H
00025 #define _INT_KEY_H
00026 
00027 #include <Basics.H>
00028 
00029 class IntKey {
00030   public:
00031     // constructor
00032     IntKey() throw () { }
00033     IntKey(int val) throw () { value = val; }
00034 
00035     // methods required by "Table.H"
00036     Word Hash() const throw () { return (Word)value; }
00037     int& operator = (const int& val) { return (value = val); }
00038     friend bool operator == (const IntKey& k1, const IntKey& k2) throw ()
00039         { return k1.value == k2.value; }
00040 
00041     // misc methods
00042     int Val() const { return value; }
00043     friend bool operator != (const IntKey& k1, const IntKey& k2) throw ()
00044         { return k1.value != k2.value; }
00045     friend bool operator < (const IntKey& k1, const IntKey& k2) throw ()
00046         { return k1.value < k2.value; }
00047     friend bool operator <= (const IntKey& k1, const IntKey& k2) throw ()
00048         { return k1.value <= k2.value; }
00049     friend bool operator > (const IntKey& k1, const IntKey& k2) throw ()
00050         { return k1.value > k2.value; }
00051     friend bool operator >= (const IntKey& k1, const IntKey& k2) throw ()
00052         { return k1.value >= k2.value; }
00053     friend std::ostream& operator << (std::ostream& s, const IntKey& k) throw ()
00054         { return s << k.value; }
00055   protected:
00056     int value;
00057 };
00058 
00059 #endif // _INT_KEY_H

Generated on Mon May 8 00:48:29 2006 for Vesta by  doxygen 1.4.2