Rudiments
|
00001 // Copyright (c) 2003 David Muse 00002 // See the COPYING file for more information. 00003 00004 #ifndef EXCLUDE_RUDIMENTS_TEMPLATE_IMPLEMENTATIONS 00005 00006 #include <rudiments/charstring.h> 00007 00008 #include <stdio.h> 00009 00010 #include <rudiments/private/rudimentsinlines.h> 00011 00012 #ifdef RUDIMENTS_NAMESPACE 00013 namespace rudiments { 00014 #endif 00015 00016 template <class datatype> 00017 RUDIMENTS_TEMPLATE_INLINE 00018 int32_t linkedlistutil<datatype>::compare(datatype data1, 00019 datatype data2) const { 00020 if (data1<data2) { 00021 return -1; 00022 } else if (data1==data2) { 00023 return 0; 00024 } else { 00025 return 1; 00026 } 00027 } 00028 00029 RUDIMENTS_EXPLICIT_SPECIALIZATION 00030 RUDIMENTS_TEMPLATE_INLINE 00031 void linkedlistutil<char *>::print(char *data) const { 00032 printf("%s",data); 00033 } 00034 00035 RUDIMENTS_EXPLICIT_SPECIALIZATION 00036 RUDIMENTS_TEMPLATE_INLINE 00037 void linkedlistutil<const char *>::print(const char *data) const { 00038 printf("%s",data); 00039 } 00040 00041 RUDIMENTS_EXPLICIT_SPECIALIZATION 00042 RUDIMENTS_TEMPLATE_INLINE 00043 int32_t linkedlistutil<char *>::compare(char *data1, char *data2) const { 00044 return charstring::compare(data1,data2); 00045 } 00046 00047 RUDIMENTS_EXPLICIT_SPECIALIZATION 00048 RUDIMENTS_TEMPLATE_INLINE 00049 int32_t linkedlistutil<const char *>::compare(const char *data1, 00050 const char *data2) const { 00051 return charstring::compare(data1,data2); 00052 } 00053 00054 RUDIMENTS_EXPLICIT_SPECIALIZATION 00055 RUDIMENTS_TEMPLATE_INLINE 00056 void linkedlistutil<char>::print(char data) const { 00057 printf("%c",data); 00058 } 00059 00060 RUDIMENTS_EXPLICIT_SPECIALIZATION 00061 RUDIMENTS_TEMPLATE_INLINE 00062 void linkedlistutil<int32_t>::print(int32_t data) const { 00063 // some compilers complain without this cast 00064 printf("%d",(int)data); 00065 } 00066 00067 RUDIMENTS_EXPLICIT_SPECIALIZATION 00068 RUDIMENTS_TEMPLATE_INLINE 00069 void linkedlistutil<int16_t>::print(int16_t data) const { 00070 printf("%hd",data); 00071 } 00072 00073 RUDIMENTS_EXPLICIT_SPECIALIZATION 00074 RUDIMENTS_TEMPLATE_INLINE 00075 void linkedlistutil<int64_t>::print(int64_t data) const { 00076 // compilers complain if this isn't cast to a long long 00077 printf("%lld",(long long)data); 00078 } 00079 00080 RUDIMENTS_EXPLICIT_SPECIALIZATION 00081 RUDIMENTS_TEMPLATE_INLINE 00082 void linkedlistutil<float>::print(float data) const { 00083 printf("%f",data); 00084 } 00085 00086 RUDIMENTS_EXPLICIT_SPECIALIZATION 00087 RUDIMENTS_TEMPLATE_INLINE 00088 void linkedlistutil<double>::print(double data) const { 00089 printf("%f",data); 00090 } 00091 00092 template <class datatype> 00093 RUDIMENTS_TEMPLATE_INLINE 00094 void linkedlistutil<datatype>::print(datatype data) const { 00095 printf("%llx",(uint64_t)data); 00096 } 00097 00098 #ifdef RUDIMENTS_NAMESPACE 00099 } 00100 #endif 00101 00102 #endif