本文整理汇总了C++中s2i函数的典型用法代码示例。如果您正苦于以下问题:C++ s2i函数的具体用法?C++ s2i怎么用?C++ s2i使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了s2i函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: print_prob
static void print_prob(
double *a_p, /* tuple->prob assoc. array */
int n, /* widest tuple */
char *tuple, /* call with "" */
int tuplew, /* tuple width; call with 0 */
char *alpha /* alphabet */
)
{
int i;
char *t = NULL; /* tuple */
if (n==0) return; /* everything is OK */
Resize(t, tuplew+2, char);
for(i=0; alpha[i]; i++) { /* include last letter (X) */
/* append letter to tuple */
strcpy(t, tuple); t[tuplew] = alpha[i]; t[tuplew+1] = '\0';
/* print tuple and probability */
if (a_p[s2i(t)]) printf("%10s %8.4f\n", t, a_p[s2i(t)]);
/* recur */
print_prob(a_p, n-1, t, tuplew+1, alpha);
} /* letter */
myfree(t);
} /* print_prob */
开发者ID:CPFL,项目名称:gmeme,代码行数:26,代码来源:background.c
示例2: AreEqualPartOfSpeech
int CAgramtab :: AreEqualPartOfSpeech (char *grm1, char* grm2)
{
if ((grm1==0) && (grm2==0)) return 1;
if ((grm1==0) && (grm2!=0)) return 0;
if ((grm2==0) && (grm1!=0)) return 0;
if (((unsigned char)grm1[0] == '?') || ((unsigned char)grm2[0] == '?')) return 0;
return GetLine(s2i(grm1))->m_PartOfSpeech == GetLine(s2i(grm2))->m_PartOfSpeech;
}
开发者ID:deNULL,项目名称:seman,代码行数:8,代码来源:agramtab_.cpp
示例3: parse
void parse(const string & s, int *id_from, int *id_msg, int *id_cmd)
{
size_t index1 = s.find_first_not_of("-0123456789",0);
*id_from = s2i(s.substr(0,index1));
size_t index2 = s.find_first_not_of("-0123456789",index1+1);
*id_msg = s2i(s.substr(index1+1,index2));
*id_cmd = s2i(s.substr(index2+1));
}
开发者ID:utcoupe,项目名称:coupe2011,代码行数:12,代码来源:comManger.cpp
示例4: linear_pcm32_be_2ch
void linear_pcm32_be_2ch(uint8_t *rawdata, samples_t samples, size_t size)
{
samples_t src = samples;
int32_t *dst = (int32_t *)rawdata;
int r = set_rounding();
while (size--)
{
dst[0] = int2be32(s2i(*src[0])); src[0]++;
dst[1] = int2be32(s2i(*src[1])); src[1]++;
dst += 2;
}
restore_rounding(r);
}
开发者ID:9060,项目名称:ac3filter.valib,代码行数:14,代码来源:linear2pcm.cpp
示例5: linear_pcm24_be_3ch
void linear_pcm24_be_3ch(uint8_t *rawdata, samples_t samples, size_t size)
{
samples_t src = samples;
int24_t *dst = (int24_t *)rawdata;
int r = set_rounding();
while (size--)
{
dst[0] = int2be24(s2i(*src[0])); src[0]++;
dst[1] = int2be24(s2i(*src[1])); src[1]++;
dst[2] = int2be24(s2i(*src[2])); src[2]++;
dst += 3;
}
restore_rounding(r);
}
开发者ID:9060,项目名称:ac3filter.valib,代码行数:15,代码来源:linear2pcm.cpp
示例6: linear_pcm16_4ch
void linear_pcm16_4ch(uint8_t *rawdata, samples_t samples, size_t size)
{
samples_t src = samples;
int16_t *dst = (int16_t *)rawdata;
int r = set_rounding();
while (size--)
{
dst[0] = int2le16(s2i(*src[0])); src[0]++;
dst[1] = int2le16(s2i(*src[1])); src[1]++;
dst[2] = int2le16(s2i(*src[2])); src[2]++;
dst[3] = int2le16(s2i(*src[3])); src[3]++;
dst += 4;
}
restore_rounding(r);
}
开发者ID:9060,项目名称:ac3filter.valib,代码行数:16,代码来源:linear2pcm.cpp
示例7: s2i
/* ----------------------------------------------------------------------------
* Reads the provided script variables, if any, and does stuff with them.
*/
void pikmin::read_script_vars(const string &vars) {
mob::read_script_vars(vars);
maturity = s2i(get_var_value(vars, "maturity", "2"));
if(s2b(get_var_value(vars, "sprout", "0"))) {
fsm.first_state_override = PIKMIN_STATE_SPROUT;
}
}
开发者ID:Espyo,项目名称:Pikmin_fangame_engine,代码行数:10,代码来源:pikmin.cpp
示例8: log_cum_back
extern double log_cum_back(
char *seq, /* the sequence */
double *a_cp, /* the conditional probs */
int order, /* the order of the model */
double *logcumback /* the result */
)
{
int i;
int len = strlen(seq); /* length of sequence */
/* compute probability for each position in string */
int ipos; // gets reset by ambig
for (i=ipos=0, logcumback[0]=0; i<len; i++) { /* position of "a" */
int lp = MIN(ipos+1, order+1); /* substring length */
char *wa = &seq[i-lp+1]; /* next wa */
char *wa_end = &seq[i+1]; /* position after wa */
char save = *wa_end; /* save character after wa */
*wa_end = '\0'; /* make wa a string */
int index = s2i(wa); /* index into conditional probs */
double log_pwa; /* log Pr(a | w) */
if (index < 0) { // set prob to 1 and reset ipos
log_pwa = 0;
ipos = 0;
} else {
log_pwa = log(a_cp[index]); /* log Pr(a | w) */
ipos++;
}
logcumback[i+1] = logcumback[i] + log_pwa;
//printf("wa:: %s log_pwa %g\n", wa, log_pwa);
*wa_end = save; /* restore seq */
}
return(logcumback[i]); /* total cumulative prob. */
} /* log_cum_back */
开发者ID:CPFL,项目名称:gmeme,代码行数:33,代码来源:background.c
示例9: add_x_tuples
static void add_x_tuples(
double *a_p, /* tuple->prob assoc. array */
char *ntuple, /* non-X-containing tuple */
int ntuplew, /* ntuple width */
int ntuplei, /* ntuple index */
char *xtuple, /* X-containing tuple */
int xtuplew, /* xtuple width */
int xcnt /* count of X's in xtuple */
)
{
if (xtuplew == ntuplew) { /* add prob. of non-X-tuple */
int xtuplei;
xtuple[xtuplew] = '\0'; /* end tuple */
xtuplei = s2i(xtuple);
if (a_p[xtuplei] == -1) a_p[xtuplei] = 0; /* first time for x-tuple */
a_p[xtuplei] += a_p[ntuplei];
} else { /* continue building x-tuple */
xtuple[xtuplew] = 'X'; /* add X to xtuple */
add_x_tuples(a_p, ntuple, ntuplew, ntuplei, xtuple, xtuplew+1, xcnt+1);
if (xcnt || xtuplew < ntuplew-1) { /* OK to add non-X to xtuple */
xtuple[xtuplew] = ntuple[xtuplew]; /* add X to xtuple */
add_x_tuples(a_p, ntuple, ntuplew, ntuplei, xtuple, xtuplew+1, xcnt);
}
}
} /* add_x_tuples */
开发者ID:CPFL,项目名称:gmeme,代码行数:25,代码来源:background.c
示例10: FindGrammems
bool CAgramtab :: FindGrammems (const char* gram_codes, QWORD grammems) const
{
for (size_t l=0; l<strlen(gram_codes); l+=2)
if ( (GetLine(s2i(gram_codes+l))->m_Grammems & grammems) == grammems)
return true;
return false;
};
开发者ID:deNULL,项目名称:seman,代码行数:8,代码来源:agramtab_.cpp
示例11: strlen
//changes GramCodes1pair according to satisfied GramCodes1
//(if gramcode number N is good(bad) in GramCodes1 it must be good(bad) in GramCodes1pair)
string CAgramtab::GleicheAncode1 (GrammemCompare CompareFunc, string GramCodes1, string GramCodes2, string& GramCodes1pair) const
{
string Result;
string pair;
const char* gram_codes1 = GramCodes1.c_str();
const char* gram_codes2 = GramCodes2.c_str();
if (!gram_codes1) return "";
if (!gram_codes2) return "";
if (!strcmp(gram_codes1, "??")) return gram_codes2;
if (!strcmp(gram_codes2, "??")) return gram_codes2;
size_t len1 = strlen(gram_codes1);
size_t len2 = strlen(gram_codes2);
bool has_pair = GramCodes1pair.length() == len1;
for (size_t l=0; l<len1; l+=2)
if(CompareFunc)
{
const CAgramtabLine* l1 = GetLine(s2i(gram_codes1+l));
for (size_t m=0; m<len2; m+=2)
{
const CAgramtabLine* l2 = GetLine(s2i(gram_codes2+m));
if ( CompareFunc (l1, l2) )
{
//printf ("%s[%i]=%c\n",gram_codes1,l,gram_codes1[l]);
Result.append(gram_codes1+l,2);
if(has_pair) pair.append(GramCodes1pair.substr(l,2));
//Result += gram_codes1[l+1];
break;
};
};
}
else
{
for (size_t m=0; m<len2; m+=2)
{
if ( s2i(gram_codes1+l) == s2i(gram_codes2+m) )
{
Result.append(gram_codes1+l,2);
if(has_pair) pair.append(GramCodes1pair.substr(l,2));
break;
};
};
};
if(has_pair) GramCodes1pair = pair;
return Result;
};
开发者ID:deNULL,项目名称:seman,代码行数:47,代码来源:agramtab_.cpp
示例12: Read
bool CAgramtab :: Read (const char * FileName)
{
if (FileName == NULL) return true;
for (size_t i=0; i<GetMaxGrmCount(); i++)
GetLine(i) = 0;
FILE* fp = fopen (FileName,"r");
assert (fp);
if( !fp)
return false;
char buff[300];
size_t LineNo = 0;;
while (fgets (buff,300,fp))
{
LineNo++;
char * s = buff;
for (; isspace ( (unsigned char) *s); s++);
if (!*s) continue;
if (!strncmp (s,"//",2)) continue;
CAgramtabLine* pAgramtabLine = new CAgramtabLine(LineNo);
// a double can occur
if (GetLine(s2i(s))) delete GetLine(s2i(s));
GetLine(s2i(s)) = pAgramtabLine;
bool bResult = ProcessAgramtabLine(*this, buff,s2i(s));
}
fclose (fp);
m_bInited = true;
return true;
};
开发者ID:deNULL,项目名称:seman,代码行数:40,代码来源:agramtab_.cpp
示例13: phoneHome
unsigned int
MBVersion::publicVersion() {
if (!m_talkedToMama)
phoneHome();
unsigned int version=0;
CString val = m_pairs.getVal("version");
if (val.GetLength())
version = s2i(val);
return version;
}
开发者ID:mikemakuch,项目名称:muzikbrowzer,代码行数:13,代码来源:muzikbrowzerVersion.cpp
示例14: GetLine
BYTE CAgramtab::GetPartOfSpeech(const char* gram_code) const
{
if (gram_code == 0) return UnknownPartOfSpeech;
if (*gram_code == 0) return UnknownPartOfSpeech;
if (*gram_code == '?') return UnknownPartOfSpeech;
const CAgramtabLine* L = GetLine(s2i(gram_code));
if (L == NULL)
return UnknownPartOfSpeech;
return L->m_PartOfSpeech;
}
开发者ID:deNULL,项目名称:seman,代码行数:13,代码来源:agramtab_.cpp
示例15: linear_pcm16_be_1ch
void linear_pcm16_be_1ch(uint8_t *rawdata, samples_t samples, size_t size)
{
samples_t src = samples;
int16_t *dst = (int16_t *)rawdata;
int r = set_rounding();
while (size--)
{
dst[0] = int2be16(s2i(*src[0])); src[0]++;
dst += 1;
}
restore_rounding(r);
}
开发者ID:9060,项目名称:ac3filter.valib,代码行数:13,代码来源:linear2pcm.cpp
示例16: average_rc
static void average_rc(
BOOLEAN add_x, /* add x-tuples if TRUE */
double *a_p, /* tuple->prob assoc. array */
int n, /* widest tuple */
char *tuple, /* call with "" */
int tuplew, /* tuple width; call with 0 */
const char *alpha /* alphabet */
)
{
int i, j;
char *t = NULL, *rc = NULL; /* tuple and rc-tuple */
int ti, rci; /* index of tuple */
if (n==0) return; /* everything is OK */
Resize(t, tuplew+2, char);
Resize(rc, tuplew+2, char);
for(i=0; alpha[i+add_x]; i++) { /* ignore last letter (X) */
/* append letter to tuple */
strcpy(t, tuple); t[tuplew] = alpha[i]; t[tuplew+1] = '\0';
/* make reverse complement of tuple */
for (j=0; j<=tuplew; j++) rc[j] = comp_dna(t[tuplew-j]);
rc[tuplew+1] = '\0';
/* get tuple and rc indices */
ti = s2i(t); /* index of tuple */
rci = s2i(rc); /* index of reverse complement*/
/* average their probabilites */
a_p[ti] = a_p[rci] = (a_p[ti] + a_p[rci]) / 2.0;
/* recur */
average_rc(add_x, a_p, n-1, t, tuplew+1, alpha);
} /* letter */
myfree(t);
myfree(rc);
return;
} /* average_rc */
开发者ID:CPFL,项目名称:gmeme,代码行数:38,代码来源:background.c
示例17: mob
/* ----------------------------------------------------------------------------
* Creates a Pikmin.
*/
pikmin::pikmin(const float x, const float y, pikmin_type* type, const float angle, const string &vars)
: mob(x, y, type, angle, vars) {
pik_type = type;
hazard_time_left = -1;
attacking_mob = NULL;
latched = false;
attack_time = 0;
being_chomped = false;
carrying_mob = NULL;
wants_to_carry = NULL;
pluck_reserved = false;
team = MOB_TEAM_PLAYER_1; // TODO
maturity = s2i(get_var_value(vars, "maturity", "2"));
if(s2b(get_var_value(vars, "buried", "0"))) state = PIKMIN_STATE_BURIED;
}
开发者ID:Xemplar,项目名称:Pikmin_fangame_engine,代码行数:20,代码来源:pikmin.cpp
示例18: backwards_message
void vsx_widget_base_edit::vsx_command_process_b(vsx_command_s *t) {
updates++;
if (t->cmd == "action")
{
// TODO: take into account hidden lines
backwards_message("editor_action "+i2s(id)+" "+lines[scroll_y+s2i(t->parts[1])]);
}
else
if (t->cmd == "font_size")
{
font_size = s2f(t->parts[1]);
}
else
if (t->cmd == "clear") {
k_focus = this;
set_string("");
}
}
开发者ID:ChunhuiWu,项目名称:vsxu,代码行数:18,代码来源:vsx_widget_base_edit.cpp
示例19: linear_pcm16_be_8ch
void linear_pcm16_be_8ch(uint8_t *rawdata, samples_t samples, size_t size)
{
samples_t src = samples;
int16_t *dst = (int16_t *)rawdata;
int r = set_rounding();
while (size--)
{
dst[0] = int2be16(s2i(*src[0])); src[0]++;
dst[1] = int2be16(s2i(*src[1])); src[1]++;
dst[2] = int2be16(s2i(*src[2])); src[2]++;
dst[3] = int2be16(s2i(*src[3])); src[3]++;
dst[4] = int2be16(s2i(*src[4])); src[4]++;
dst[5] = int2be16(s2i(*src[5])); src[5]++;
dst[6] = int2be16(s2i(*src[6])); src[6]++;
dst[7] = int2be16(s2i(*src[7])); src[7]++;
dst += 8;
}
restore_rounding(r);
}
开发者ID:9060,项目名称:ac3filter.valib,代码行数:20,代码来源:linear2pcm.cpp
示例20: vsx_get_data_path
void vsx_widget_desktop::load_configuration()
{
vsx_command_list main_conf;
vsx_string config_file = vsx_get_data_path() + "vsxu.conf";
if (access(config_file.c_str(),0) == 0)
{
main_conf.load_from_file(config_file.c_str(),true,0);
} else
{
main_conf.load_from_file(PLATFORM_SHARED_FILES+"vsxu.conf",true,0);
}
#ifdef VSXU_DEBUG
printf("conf: %s\n", config_file.c_str());
#endif
main_conf.reset();
vsx_command_s* mc = 0;
auto_undo = 1;
while ( (mc = main_conf.get()) ) {
if (mc->cmd == "skin") {
skin_path = PLATFORM_SHARED_FILES+vsx_string("gfx")+DIRECTORY_SEPARATOR+mc->cmd_data+DIRECTORY_SEPARATOR;
#ifdef VSXU_DEBUG
printf("skin path: %s\n",skin_path.c_str());
#endif
} else
if (mc->cmd == "global_interpolation_speed") {
global_interpolation_speed = s2f(mc->cmd_data);
} else
if (mc->cmd == "automatic_undo") {
auto_undo = s2i(mc->cmd_data);
} else
if (mc->cmd == "global_framerate_limit") {
global_framerate_limit = s2f(mc->cmd_data);
} else
if (mc->cmd == "global_key_speed") {
global_key_speed = s2f(mc->cmd_data);
}
if (mc->cmd != "" && mc->cmd != "#")
configuration[mc->cmd] = mc->cmd_data;
}
}
开发者ID:Who828,项目名称:vsxu,代码行数:41,代码来源:vsx_widget_desktop.cpp
注:本文中的s2i函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论