Skylark (Sketching Library)  0.1
/var/lib/jenkins/jobs/Skylark/workspace/examples/utilities.hpp
Go to the documentation of this file.
00001 #ifndef UTILITIES_HPP
00002 #define UTILITIES_HPP
00003 
00004 #include <cstdlib>
00005 #include <cassert>
00006 #include <iostream>
00007 #include <utility>
00008 #include <algorithm>
00009 #include <ext/hash_map>
00010 #include <ext/hash_set>
00011 
00012 /* Definitions for all the parameters and constants that we will ever use */
00013 static const int ROOT                    = 0;
00014 static const int SKETCH_LEFT             = 0;
00015 static const int SKETCH_RIGHT            = 1;
00016 static const int SKETCH_LEFT_RIGHT       = 2;
00017 
00018 static const int USE_RANDOM_INDEX        = 0;
00019 static const int RAND_SEED_INDEX         = 1;
00020 static const int DEBUG_INDEX             = 2;
00021 static const int M_INDEX                 = 3;
00022 static const int N_INDEX                 = 4;
00023 static const int N_RHS_INDEX             = 5;
00024 static const int S_INDEX                 = 6;
00025 static const int NUM_THREADS_INDEX       = 7;
00026 static const int SKETCH_DIRECTION_INDEX  = 8;
00027 static const int NUM_INT_PARAMETERS      = 9;
00028 extern int int_params[NUM_INT_PARAMETERS];
00029 
00030 static const int A_FILE_PATH_INDEX       = 0;
00031 static const int B_FILE_PATH_INDEX       = 1;
00032 static const int SA_FILE_PATH_INDEX      = 2;
00033 static const int TRANSFORM_INDEX         = 3;
00034 static const int MATRIX_TYPE_INDEX       = 4;
00035 static const int NUM_CHR_PARAMETERS      = 5;
00036 extern char* chr_params[NUM_CHR_PARAMETERS];
00037 
00038 namespace std {
00039   /* Specialize std::equal_to for strings; used for parameter passing */
00040   template <> 
00041   struct equal_to<const char*> {
00042     bool operator()(const char* one, const char* two) const {
00043       return (0==strcmp(one,two));
00044     }
00045   };
00046 
00047   /* Specialize std::equal_to for pairs; used for parameter passing */
00048   template <typename T1, typename T2> 
00049   struct equal_to<std::pair<T1,T2> >{
00050     bool operator()(const std::pair<T1,T2>& one, 
00051                     const std::pair<T1,T2>& two) const {
00052       return (one.first==two.first && one.second==two.second);
00053     }
00054   };
00055 }
00056 
00057 #endif // UTILITIES_HPP