TRF Language Model
wb Namespace Reference

define all the code written by Bin Wang. More...

Namespaces

 iter
 

Classes

class  _wb_HEAP_UNIT_
 heap unit More...
 
class  Array
 Dynamic array. More...
 
class  CirQueue
 Circular queue. More...
 
class  Clock
 clock - used to record the time More...
 
class  DArray
 2-dimension array. More...
 
class  File
 file class. More...
 
class  Func
 the objective function, used to derive More...
 
class  Heap
 heap More...
 
class  IO_Obj
 base class used to derive. It providing the vritual function of write and read More...
 
class  LBFGS
 
class  LHash
 a linear hash table More...
 
class  LHashIter
 the iter of LHash More...
 
class  Log
 this class can output to the cmd window and log files simultaneously. In wb-log.cpp, there are a Log variable "lout", which can be directly used just like "cout". For example: More...
 
class  Mat
 
class  Mat3d
 
class  Mat3dShell
 
class  MatShell
 
class  ObjFile
 used to read more than one objects More...
 
struct  Opt_Struct
 structure of the value More...
 
class  Option
 Get the option from command line or command files. More...
 
class  Path
 Analize the path including "*" and "?" and "+" symbols. More...
 
class  ProgressBar
 a progress bar class More...
 
class  Queue
 A queue based the dynamic memory mangement. More...
 
class  Solve
 the base class of all the solve classes, and provide a gradient descent algorithm. More...
 
class  Stack
 A dynamic stack. More...
 
class  String
 a dynamic string class More...
 
class  Title
 title class - output to the title More...
 
class  Trie
 trie structure More...
 
class  TrieIter
 iter all the sub-tries More...
 
class  TrieIter2
 Get all the values whose indexes are of a fixed length. The returned tries may not contain a legal values. More...
 
class  Vec
 
class  VecShell
 
class  Vector
 this is the basic class of Array/Stack/Queue. Realize the dynamic memory management More...
 
class  vIter
 
class  WordCluster
 
class  WordCluster_t
 

Typedefs

typedef unsigned short _wb_HEAP_MODE_
 

Enumerations

enum  ValueType {
  wbOPT_TRUE, wbOPT_FALSE, wbOPT_INT, wbOPT_STRING,
  wbOPT_FLOAT
}
 define the value type More...
 

Functions

template<class KeyT >
KeyT Map_copyKey (KeyT key)
 Copy a key. More...
 
const char * Map_copyKey (const char *key)
 Copy a string key. More...
 
template<class KeyT >
void Map_freeKey (KeyT key)
 Free a key. More...
 
void Map_freeKey (const char *key)
 Free a key, if the key is string. More...
 
template<class T >
bool VecEqual (VecShell< T > &v1, VecShell< T > &v2)
 calculate V==V More...
 
template<class T >
void VecAdd (VecShell< T > &res, VecShell< T > &v1, VecShell< T > &v2)
 calculate V + V More...
 
template<class T >
VecDot (VecShell< T > &v1, VecShell< T > &v2)
 calculate V*V More...
 
template<class T >
MatVec2 (MatShell< T > &m, VecShell< T > &v1, VecShell< T > &v2)
 calculate V1*M*V2 More...
 
template<typename T >
double VecNorm (T *pVec, int len)
 [Vec-function] sqrt(v*v^T); More...
 
template<typename T >
double VecDot (T *pVec1, T *pVec2, int len)
 [Vec-function] v1*v2^T More...
 
template<typename T >
double VecDiff (T *pVec1, T *pVec2, int len)
 [Vec-function] |v1-v2| More...
 
template<typename T >
double VecAngle (T *pVec1, T *pVec2, int len)
 [Vec-function] the cos of the angle of v1 and v2 More...
 
template<typename T >
void VecUnfold (const char *pStr, Array< T > &a)
 [Vec-function] transform the matlab-style vector to a array, such as [1,3:1:7,9] => 1,3,4,5,6,7,9 More...
 
template<typename T >
int Compar_Inc (const T &a, const T &b)
 comparing function for increase sort. More...
 
template<typename T >
int Compar_Dec (const T &a, const T &b)
 comparing function for decrease sort More...
 
template<typename T >
void Qsort (T *p, int low, int high, int(*compar)(const T &, const T &)=Compar_Inc)
 Quick sork. More...
 
template<typename T >
void Qsort (Array< T > &a, int(*compar)(const T &, const T &)=Compar_Inc)
 Quick sork, redefine for class Array. More...
 
void Pause ()
 pause More...
 
void outPrecent (long long n, bool bNew=false, long long nTotal=100, const char *title="Process")
 print precent in the cmd window More...
 
void outPrecent (ifstream &ifile, bool bNew=false, const char *title="Process")
 print precent in the cmd window More...
 
void outPrecent (FILE *fp, bool bNew=false, const char *title="Process")
 print precent in the cmd window More...
 
set key to no-key
template<class KeyT >
void Map_noKey (KeyT *&key)
 
void Map_noKey (int &key)
 
void Map_noKey (short int &key)
 
void Map_noKey (long int &key)
 
void Map_noKey (long long &key)
 
void Map_noKey (unsigned &key)
 
void Map_noKey (short unsigned &key)
 
void Map_noKey (long unsigned &key)
 
void Map_noKey (float &key)
 
void Map_noKey (double &key)
 
no-key detection

detect if the key is no-key

template<class KeyT >
bool Map_noKeyP (KeyT *key)
 
bool Map_noKeyP (int key)
 
bool Map_noKeyP (short int key)
 
bool Map_noKeyP (long int key)
 
bool Map_noKeyP (long long key)
 
bool Map_noKeyP (unsigned key)
 
bool Map_noKeyP (short unsigned key)
 
bool Map_noKeyP (long unsigned key)
 
bool Map_noKeyP (float key)
 
bool Map_noKeyP (double &key)
 
Compare two Keys

Return if the input keys are equal.

template<class KeyT >
bool Map_equalKey (KeyT key1, KeyT key2)
 
bool Map_equalKey (float key1, float key2)
 
bool Map_equalKey (double key1, double key2)
 
bool Map_equalKey (const char *pStr1, const char *pStr2)
 
HashKey

Hashing functions. (We provide versions for integral types and char strings; user has to add more specialized definitions.)

unsigned long LHash_hashKey (unsigned long key, unsigned maxBits)
 
template<class KeyT >
unsigned long LHash_hashKey (KeyT *key, unsigned maxBits)
 hash for pointer More...
 
unsigned long LHash_hashKey (int key, unsigned maxBits)
 hash for integral More...
 
unsigned long LHash_hashKey (float key, unsigned maxBits)
 hash for float More...
 
unsigned long LHash_hashKey (double key, unsigned maxBits)
 hash for double More...
 
unsigned long LHash_hashKey (const char *key, unsigned maxBits)
 hash for string More...
 
SortFunction

sort function for LHashIter

template<class KeyT >
bool LHash_IncSort (KeyT k1, KeyT k2)
 
bool LHash_IncSort (const char *p1, const char *p2)
 

Variables

const int cn_MinLHashBits = 3
 if the bits of hash less than this value, using linear table More...
 
const int cn_MaxLHashBits = 31
 the maximum bits number support by hast More...
 
const float cf_HashRatio = 0.8f
 fill-rate of the hash. More...
 
Log lout
 the defination is in wb-log.cpp More...
 
const int cn_default_str_len = 10
 default length of string More...
 
const int cn_default_max_len = 32 * 1024
 default maximum length More...
 
const int cn_title_max_len = 500
 
no-key values
  • for signed type, no-key is the smallest negative value
  • for unsigned type, no-key is the largest value
  • for float/double type, no-key is a large float/double
const short c_ShortNokeyValue = (short)(1u << (sizeof(short) * 8 - 1))
 nokey value for short More...
 
const int c_IntNokeyValue = (int)(1u << (sizeof(int) * 8 - 1))
 nokey value for int More...
 
const long c_LongNokeyValue = (long)(1uL << (sizeof(long) * 8 - 1))
 nokey value for long More...
 
const long long c_LLongNokeyValue = (long long)(1LL << (sizeof(long long) * 8 - 1))
 nokey value for longlong More...
 
const short unsigned c_UShortNokeyValue = ~(short unsigned)0
 nokey value for unsigned short More...
 
const unsigned c_UIntNokeyValue = ~(unsigned)0
 nokey value for unsigned int More...
 
const long unsigned c_ULongNokeyValue = ~(long unsigned)0
 nokey value for unsigned long More...
 
const float c_floatNokeyValue = 1e15
 nokey value for float More...
 
const double c_doubleNokeyValue = 1e20
 nokey value for double More...
 

Detailed Description

define all the code written by Bin Wang.

Typedef Documentation

§ _wb_HEAP_MODE_

typedef unsigned short wb::_wb_HEAP_MODE_

heap model, can be one of { HEAPMODE_MAXHEAP,HEAPMODE_MINHEAP }

Definition at line 53 of file wb-heap.h.

Enumeration Type Documentation

§ ValueType

define the value type

Enumerator
wbOPT_TRUE 

is true if exist

wbOPT_FALSE 

set false if exist

wbOPT_INT 

integer

wbOPT_STRING 

string

wbOPT_FLOAT 

float

Definition at line 32 of file wb-option.h.

Function Documentation

§ LHash_hashKey() [1/6]

unsigned long wb::LHash_hashKey ( unsigned long  key,
unsigned  maxBits 
)
inline

hash for unsigned long

Definition at line 130 of file wb-lhash.h.

§ LHash_hashKey() [2/6]

template<class KeyT >
unsigned long wb::LHash_hashKey ( KeyT *  key,
unsigned  maxBits 
)
inline

hash for pointer

Definition at line 137 of file wb-lhash.h.

§ LHash_hashKey() [3/6]

unsigned long wb::LHash_hashKey ( int  key,
unsigned  maxBits 
)
inline

hash for integral

Definition at line 143 of file wb-lhash.h.

§ LHash_hashKey() [4/6]

unsigned long wb::LHash_hashKey ( float  key,
unsigned  maxBits 
)
inline

hash for float

Definition at line 149 of file wb-lhash.h.

§ LHash_hashKey() [5/6]

unsigned long wb::LHash_hashKey ( double  key,
unsigned  maxBits 
)
inline

hash for double

Definition at line 154 of file wb-lhash.h.

§ LHash_hashKey() [6/6]

unsigned long wb::LHash_hashKey ( const char *  key,
unsigned  maxBits 
)
inline

hash for string

Definition at line 177 of file wb-lhash.h.

§ LHash_IncSort() [1/2]

template<class KeyT >
bool wb::LHash_IncSort ( KeyT  k1,
KeyT  k2 
)
inline

Definition at line 193 of file wb-lhash.h.

§ LHash_IncSort() [2/2]

bool wb::LHash_IncSort ( const char *  p1,
const char *  p2 
)
inline

Definition at line 194 of file wb-lhash.h.

§ Map_copyKey() [1/2]

template<class KeyT >
KeyT wb::Map_copyKey ( KeyT  key)
inline

Copy a key.

Definition at line 48 of file wb-lhash.h.

§ Map_copyKey() [2/2]

const char* wb::Map_copyKey ( const char *  key)
inline

Copy a string key.

Definition at line 50 of file wb-lhash.h.

§ Map_equalKey() [1/4]

template<class KeyT >
bool wb::Map_equalKey ( KeyT  key1,
KeyT  key2 
)
inline

Definition at line 115 of file wb-lhash.h.

§ Map_equalKey() [2/4]

bool wb::Map_equalKey ( float  key1,
float  key2 
)
inline

Definition at line 116 of file wb-lhash.h.

§ Map_equalKey() [3/4]

bool wb::Map_equalKey ( double  key1,
double  key2 
)
inline

Definition at line 117 of file wb-lhash.h.

§ Map_equalKey() [4/4]

bool wb::Map_equalKey ( const char *  pStr1,
const char *  pStr2 
)
inline

Definition at line 118 of file wb-lhash.h.

§ Map_freeKey() [1/2]

template<class KeyT >
void wb::Map_freeKey ( KeyT  key)
inline

Free a key.

Definition at line 55 of file wb-lhash.h.

§ Map_freeKey() [2/2]

void wb::Map_freeKey ( const char *  key)
inline

Free a key, if the key is string.

Definition at line 57 of file wb-lhash.h.

§ Map_noKey() [1/10]

template<class KeyT >
void wb::Map_noKey ( KeyT *&  key)
inline

Definition at line 81 of file wb-lhash.h.

§ Map_noKey() [2/10]

void wb::Map_noKey ( int &  key)
inline

Definition at line 82 of file wb-lhash.h.

§ Map_noKey() [3/10]

void wb::Map_noKey ( short int &  key)
inline

Definition at line 83 of file wb-lhash.h.

§ Map_noKey() [4/10]

void wb::Map_noKey ( long int &  key)
inline

Definition at line 84 of file wb-lhash.h.

§ Map_noKey() [5/10]

void wb::Map_noKey ( long long &  key)
inline

Definition at line 85 of file wb-lhash.h.

§ Map_noKey() [6/10]

void wb::Map_noKey ( unsigned &  key)
inline

Definition at line 86 of file wb-lhash.h.

§ Map_noKey() [7/10]

void wb::Map_noKey ( short unsigned &  key)
inline

Definition at line 87 of file wb-lhash.h.

§ Map_noKey() [8/10]

void wb::Map_noKey ( long unsigned &  key)
inline

Definition at line 88 of file wb-lhash.h.

§ Map_noKey() [9/10]

void wb::Map_noKey ( float &  key)
inline

Definition at line 89 of file wb-lhash.h.

§ Map_noKey() [10/10]

void wb::Map_noKey ( double &  key)
inline

Definition at line 90 of file wb-lhash.h.

§ Map_noKeyP() [1/10]

template<class KeyT >
bool wb::Map_noKeyP ( KeyT *  key)
inline

Definition at line 98 of file wb-lhash.h.

§ Map_noKeyP() [2/10]

bool wb::Map_noKeyP ( int  key)
inline

Definition at line 99 of file wb-lhash.h.

§ Map_noKeyP() [3/10]

bool wb::Map_noKeyP ( short int  key)
inline

Definition at line 100 of file wb-lhash.h.

§ Map_noKeyP() [4/10]

bool wb::Map_noKeyP ( long int  key)
inline

Definition at line 101 of file wb-lhash.h.

§ Map_noKeyP() [5/10]

bool wb::Map_noKeyP ( long long  key)
inline

Definition at line 102 of file wb-lhash.h.

§ Map_noKeyP() [6/10]

bool wb::Map_noKeyP ( unsigned  key)
inline

Definition at line 103 of file wb-lhash.h.

§ Map_noKeyP() [7/10]

bool wb::Map_noKeyP ( short unsigned  key)
inline

Definition at line 104 of file wb-lhash.h.

§ Map_noKeyP() [8/10]

bool wb::Map_noKeyP ( long unsigned  key)
inline

Definition at line 105 of file wb-lhash.h.

§ Map_noKeyP() [9/10]

bool wb::Map_noKeyP ( float  key)
inline

Definition at line 106 of file wb-lhash.h.

§ Map_noKeyP() [10/10]

bool wb::Map_noKeyP ( double &  key)
inline

Definition at line 107 of file wb-lhash.h.

Variable Documentation

§ c_doubleNokeyValue

const double wb::c_doubleNokeyValue = 1e20

nokey value for double

Definition at line 74 of file wb-lhash.h.

§ c_floatNokeyValue

const float wb::c_floatNokeyValue = 1e15

nokey value for float

Definition at line 73 of file wb-lhash.h.

§ c_IntNokeyValue

const int wb::c_IntNokeyValue = (int)(1u << (sizeof(int) * 8 - 1))

nokey value for int

Definition at line 67 of file wb-lhash.h.

§ c_LLongNokeyValue

const long long wb::c_LLongNokeyValue = (long long)(1LL << (sizeof(long long) * 8 - 1))

nokey value for longlong

Definition at line 69 of file wb-lhash.h.

§ c_LongNokeyValue

const long wb::c_LongNokeyValue = (long)(1uL << (sizeof(long) * 8 - 1))

nokey value for long

Definition at line 68 of file wb-lhash.h.

§ c_ShortNokeyValue

const short wb::c_ShortNokeyValue = (short)(1u << (sizeof(short) * 8 - 1))

nokey value for short

Definition at line 66 of file wb-lhash.h.

§ c_UIntNokeyValue

const unsigned wb::c_UIntNokeyValue = ~(unsigned)0

nokey value for unsigned int

Definition at line 71 of file wb-lhash.h.

§ c_ULongNokeyValue

const long unsigned wb::c_ULongNokeyValue = ~(long unsigned)0

nokey value for unsigned long

Definition at line 72 of file wb-lhash.h.

§ c_UShortNokeyValue

const short unsigned wb::c_UShortNokeyValue = ~(short unsigned)0

nokey value for unsigned short

Definition at line 70 of file wb-lhash.h.

§ cf_HashRatio

const float wb::cf_HashRatio = 0.8f

fill-rate of the hash.

Definition at line 199 of file wb-lhash.h.

§ cn_default_max_len

const int wb::cn_default_max_len = 32 * 1024

default maximum length

Definition at line 41 of file wb-string.h.

§ cn_default_str_len

const int wb::cn_default_str_len = 10

default length of string

Definition at line 40 of file wb-string.h.

§ cn_MaxLHashBits

const int wb::cn_MaxLHashBits = 31

the maximum bits number support by hast

Definition at line 198 of file wb-lhash.h.

§ cn_MinLHashBits

const int wb::cn_MinLHashBits = 3

if the bits of hash less than this value, using linear table

Definition at line 197 of file wb-lhash.h.