nor_utils Namespace Reference


Classes

class  Args
 Handle the command line arguments. More...
class  StreamTokenizer
 Can tokenize a stream. More...
struct  white_tab
 Set the whitespace to tabs and newlines only. More...

Enumerations

enum  ArgsOutType { AOT_OK, AOT_NO_ARGUMENTS, AOT_UNKOWN_ARGUMENT, AOT_TOO_FEW_VALUES }
 The enum returned by readArguments(). More...

Functions

void skip_line (istream &inFile, const int nLines=1)
 Skip nLine lines of a given stream.
string addAndCheckExtension (const string &file, const string &extension)
 Returns the file with the extension.
string trim (const string &str)
 Trim a string on the left and on the right.
bool cmp_nocase (const string &s1, const string &s2)
 Case insensitive comparison.
size_t count_columns (istream &in)
 Count the number of columns from a stream.
template<typename T1, typename T2, typename Pred>
bool comparePairOnSecond (const pair< T1, T2 > &el1, const pair< T1, T2 > &el2)
 Sort pairs on the second element.
template<typename T>
bool is_zero (const T val, const T smallVal=1E-10)
 Checks if a number is equal to zero, between a positive and negative limit of smallVal.


Enumeration Type Documentation

enum ArgsOutType
 

The enum returned by readArguments().

It gives informations about the status of the read arguments.

Date:
10/11/2005
Enumerator:
AOT_OK  Everything went ok.
AOT_NO_ARGUMENTS  No argument in the command line.
AOT_UNKOWN_ARGUMENT  Unknown argument (not registered argument).
AOT_TOO_FEW_VALUES  The number of values for the given argument does not match the declaration.

Definition at line 47 of file Args.h.


Function Documentation

string nor_utils::addAndCheckExtension const string &  file,
const string &  extension
[inline]
 

Returns the file with the extension.

If the given extension already exist in the file name, then ignore it. Examples:

 addAndCheckExtension("hello.dat", "dat"); // -> "hello.dat"
 addAndCheckExtension("hello", "dat"); // -> "hello.dat"
 addAndCheckExtension("hello.txt", "dat"); // -> "hello.txt.dat"
Parameters:
file The fileName
extension The extension to append
Returns:
The string with filename and extension
Date:
11/11/2005

Definition at line 126 of file Utils.h.

bool nor_utils::cmp_nocase const string &  s1,
const string &  s2
[inline]
 

Case insensitive comparison.

Parameters:
s1 The first string.
s2 The second string.
Returns:
True if the two string are equal (regardless of the case), false otherwise.
Date:
16/11/2005

Definition at line 178 of file Utils.h.

Referenced by UnSerialization::seekAndParseEnclosedValue(), UnSerialization::seekAndParseParamTag(), UnSerialization::seekAndParseVectorTag(), UnSerialization::seekParamTag(), and UnSerialization::seekSimpleTag().

bool nor_utils::comparePairOnSecond const pair< T1, T2 > &  el1,
const pair< T1, T2 > &  el2
 

Sort pairs on the second element.

The predicate gives the sorting direction.

To sort from small to big:

 vector< pair<int, double> > v;
 sort( v.begin(), v.end(), nor_utils::comparePairOnSecond< int, double, less<double> > );
From big to small:
 vector< pair<int, double> > v;
 sort( v.begin(), v.end(), nor_utils::comparePairOnSecond< int, double, greater<double> > );
Remarks:
Don't forget to include <functional> if you use the standard predicates

I could have done a predicate for the element of the pair too, but they are just two, and I don't really need the first.. :P

T1 The type of the first element of the pair

T2 The type of the second element of the pair

Pred The predicate used for the comparison

Parameters:
el1 The first pair
el2 The second pair
Date:
11/11/2005

Definition at line 266 of file Utils.h.

Referenced by SortedData::load().

size_t nor_utils::count_columns istream &  in  )  [inline]
 

Count the number of columns from a stream.

Parameters:
in The stream to be examined
Returns:
The number of columns found
Remarks:
The stream will be modified
Date:
11/11/2005

Definition at line 207 of file Utils.h.

bool nor_utils::is_zero const T  val,
const T  smallVal = 1E-10
 

Checks if a number is equal to zero, between a positive and negative limit of smallVal.

Should be used with floating numbers to overcome numerical problems.

Parameters:
val The value to check
smallVal An arbitrary small value that defines the positive and negative limits
Returns:
true if it is between the limits, false otherwise
Date:
11/11/2005

Definition at line 282 of file Utils.h.

Referenced by StumpLearner::doFullAbstention(), StumpLearner::doGreedyAbstention(), BaseLearner::getAlpha(), and StumpLearner::getEnergy().

void nor_utils::skip_line istream &  inFile,
const int  nLines = 1
[inline]
 

Skip nLine lines of a given stream.

Parameters:
inFile The input stream
nLines The number of lines to skip (default = 1)
Date:
11/11/2005

Definition at line 104 of file Utils.h.

string nor_utils::trim const string &  str  )  [inline]
 

Trim a string on the left and on the right.

Parameters:
str The string to be trimmed
Returns:
The trimmed string
Date:
11/11/2005

Definition at line 155 of file Utils.h.


Generated on Mon Nov 28 21:43:48 2005 for MultiBoost by  doxygen 1.4.5