home *** CD-ROM | disk | FTP | other *** search
/ Geek Gadgets 1 / ADE-1.bin / ade-dist / libg++-2.7.1-bin.lha / lib / g++-include / compare.h < prev    next >
C/C++ Source or Header  |  1996-10-12  |  2KB  |  92 lines

  1. // This may look like C code, but it is really -*- C++ -*-
  2.  
  3. /* 
  4. Copyright (C) 1988 Free Software Foundation
  5.     written by Doug Lea (dl@rocky.oswego.edu)
  6.  
  7. This file is part of the GNU C++ Library.  This library is free
  8. software; you can redistribute it and/or modify it under the terms of
  9. the GNU Library General Public License as published by the Free
  10. Software Foundation; either version 2 of the License, or (at your
  11. option) any later version.  This library is distributed in the hope
  12. that it will be useful, but WITHOUT ANY WARRANTY; without even the
  13. implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  14. PURPOSE.  See the GNU Library General Public License for more details.
  15. You should have received a copy of the GNU Library General Public
  16. License along with this library; if not, write to the Free Software
  17. Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  18. */
  19.  
  20. #ifndef _compare_h
  21. #ifdef __GNUG__
  22. #pragma interface
  23. #endif
  24. #define _compare_h 1
  25.  
  26. #include <builtin.h>
  27.  
  28. int compare(int a, int b);
  29. int compare(short a, short b);
  30. int compare(unsigned long a, unsigned long b);
  31. int compare(unsigned int a, unsigned int b);
  32. int compare(unsigned short a, unsigned short b);
  33. int compare(unsigned char a, unsigned char b);
  34. int compare(signed char a, signed char b);
  35. int compare(float a, float b);
  36. int compare(double a, double b);
  37. int compare(const char* a, const char* b);
  38.  
  39.  
  40. inline int compare(int a, int b)
  41. {
  42.   return a - b;
  43. }
  44.  
  45. inline int compare(short a, short b)
  46. {
  47.   return a - b;
  48. }
  49.  
  50.  
  51. inline int compare(signed char a, signed char b)
  52. {
  53.   return a - b;
  54. }
  55.  
  56. inline int compare(unsigned long a, unsigned long b)
  57. {
  58.   return (a < b)? -1 : (a > b)? 1 : 0;
  59. }
  60.  
  61. inline int compare(unsigned int a, unsigned int b)
  62. {
  63.   return (a < b)? -1 : (a > b)? 1 : 0;
  64. }
  65.  
  66. inline int compare(unsigned short a, unsigned short b)
  67. {
  68.   return (a < b)? -1 : (a > b)? 1 : 0;
  69. }
  70.  
  71. inline int compare(unsigned char a, unsigned char b)
  72. {
  73.   return (a < b)? -1 : (a > b)? 1 : 0;
  74. }
  75.  
  76. inline int compare(float a, float b)
  77. {
  78.   return (a < b)? -1 : (a > b)? 1 : 0;
  79. }
  80.  
  81. inline int compare(double a, double b)
  82. {
  83.   return (a < b)? -1 : (a > b)? 1 : 0;
  84. }
  85.  
  86. inline int compare(const char* a, const char* b)
  87. {
  88.   return strcmp(a,b);
  89. }
  90.  
  91. #endif
  92.