00001 /* 00002 * This program is free software; you can redistribute it and/or modify 00003 * it under the terms of the GNU General Public License as published by 00004 * the Free Software Foundation; either version 3 of the License, or 00005 * (at your option) any later version. 00006 * 00007 * Written (W) 1999-2008 Soeren Sonnenburg 00008 * Written (W) 1999-2008 Gunnar Raetsch 00009 * Copyright (C) 1999-2008 Fraunhofer Institute FIRST and Max-Planck-Society 00010 */ 00011 00012 #include "preproc/SortUlongString.h" 00013 #include "features/Features.h" 00014 #include "features/StringFeatures.h" 00015 #include "lib/Mathematics.h" 00016 00017 CSortUlongString::CSortUlongString() 00018 : CStringPreProc<ULONG>("SortUlongString", "STUS") 00019 { 00020 } 00021 00022 CSortUlongString::~CSortUlongString() 00023 { 00024 } 00025 00027 bool CSortUlongString::init(CFeatures* f) 00028 { 00029 ASSERT(f->get_feature_class()==C_STRING); 00030 ASSERT(f->get_feature_type()==F_ULONG); 00031 00032 return true; 00033 } 00034 00036 void CSortUlongString::cleanup() 00037 { 00038 } 00039 00041 bool CSortUlongString::load(FILE* f) 00042 { 00043 return false; 00044 } 00045 00047 bool CSortUlongString::save(FILE* f) 00048 { 00049 return false; 00050 } 00051 00055 bool CSortUlongString::apply_to_string_features(CFeatures* f) 00056 { 00057 INT i; 00058 INT num_vec=((CStringFeatures<ULONG>*)f)->get_num_vectors() ; 00059 00060 for (i=0; i<num_vec; i++) 00061 { 00062 INT len = 0 ; 00063 ULONG* vec = ((CStringFeatures<ULONG>*)f)->get_feature_vector(i, len) ; 00064 SG_DEBUG( "sorting string of length %i\n", len) ; 00065 00066 //CMath::qsort(vec, len); 00067 CMath::radix_sort(vec, len); 00068 } 00069 return true ; 00070 } 00071 00073 ULONG* CSortUlongString::apply_to_string(ULONG* f, INT& len) 00074 { 00075 ULONG* vec=new ULONG[len]; 00076 INT i=0; 00077 00078 for (i=0; i<len; i++) 00079 vec[i]=f[i]; 00080 00081 //CMath::qsort(vec, len); 00082 CMath::radix_sort(vec, len); 00083 00084 return vec; 00085 } 00086 00088 bool CSortUlongString::load_init_data(FILE* src) 00089 { 00090 return true; 00091 } 00092 00094 bool CSortUlongString::save_init_data(FILE* dst) 00095 { 00096 return true; 00097 }