本文整理汇总了C++中Locate函数的典型用法代码示例。如果您正苦于以下问题:C++ Locate函数的具体用法?C++ Locate怎么用?C++ Locate使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Locate函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: wxGetenv
bool ProcUtils::Shell()
{
wxString cmd;
#ifdef __WXMSW__
wxChar *shell = wxGetenv(wxT("COMSPEC"));
if ( !shell ) {
shell = (wxChar*) wxT("\\COMMAND.COM");
}
// just the shell
cmd = shell;
#elif defined(__WXMAC__)
wxString path = wxGetCwd();
cmd = wxString( wxT("osascript -e 'tell application \"Terminal\"' -e 'activate' -e 'do script with command \"cd ") + path + wxT("\"' -e 'end tell'") );
#else //non-windows
//try to locate the default terminal
wxString terminal;
wxString where;
if (Locate(wxT("gnome-terminal"), where)) {
terminal = where;
} else if (Locate(wxT("konsole"), where)) {
terminal = where;
} else if (Locate(wxT("xterm"), where)) {
terminal = where;
}
cmd = terminal;
#endif
return wxExecute(cmd, wxEXEC_ASYNC) != 0;
}
示例2: BiLinear
double BiLinear(int Na, double *a_table, double a,
int Nb, double *b_table, double b,
double **f, bool_t hunt)
{
static int i = 0, j = 0;
double fa, fb;
/* --- Bi-linear interpolation of function f[][] given on
rectangular grid (a_table, b_table) -- -------------- */
if (hunt) {
Hunt(Na, a_table, a, &i);
Hunt(Nb, b_table, b, &j);
} else {
Locate(Na, a_table, a, &i);
Locate(Nb, b_table, b, &j);
}
fa = (a_table[i+1] - a) / (a_table[i+1] - a_table[i]);
fb = (b_table[j+1] - b) / (b_table[j+1] - b_table[j]);
return fa*fb * f[i][j] +
fa*(1.0 - fb) * f[i][j+1] +
(1.0 - fa)*fb * f[i+1][j] +
(1.0 - fa)*(1.0 - fb) * f[i+1][j+1];
}
示例3: CreateDG
void CreateDG (MGraph *G)
{
G->kind = DG;
int i, j, k, cost;
VertexData v1, v2;
printf ("Enter vernum and arcnum:(<%d): ", MAX);
scanf ("%d %d", &(G->vernum), &(G->arcnum));
getchar ();
printf ("Enter the vertex: ");
for (i = 0; i < G->vernum; i++)
scanf ("%c", &(G->vertex[i]));
for (i = 0; i < G->vernum; i++)
for (j = 0; j < G->vernum; j++)
G->arcs[i][j] = INFINITY;
for (k = 0; k < G->arcnum; k++)
{
printf ("Enter v1 v2 and cost: ");
getchar ();
scanf ("%c %c %d", &v1, &v2, &cost);
i = Locate (G, v1);
j = Locate (G, v2);
G->arcs[i][j] = cost;
}
}
示例4: _cd
/**
*
* _cd(debug, path);
*
* Change current working directory.
*
**/
PUBLIC void _cd(DEBUG *debug, char *path)
{
Object *cwd;
if (path == NULL)
if ((path = getvar(debug->env.Envv, "HOME")) == NULL)
cmderr(debug, "No home directory");
#ifdef OLDCODE
if ((cwd = Locate(debug->env.Objv[0], path)) == NULL)
#endif
/*
-- crf : 12/08/91 - clean up use of Environment Objv
*/
if ((cwd = Locate(debug->env.Objv[OV_Cdir], path)) == NULL)
cmderr(debug, "No such directory");
#ifdef OLDCODE
Close(debug->env.Objv[0]);
debug->env.Objv[0] = cwd;
#endif
/*
-- crf : 12/08/91 - clean up use of Environment Objv
*/
Close(debug->env.Objv[OV_Cdir]);
debug->env.Objv[OV_Cdir] = cwd;
cmdmsg( debug, "Current directory is now '%s'", path );
return;
}
示例5: CreateALGraph
void CreateALGraph(ALGraph *G)
{/*建立有向图的邻接表存储*/
int i,j,k;
char vex1[3],vex2[3];
EdgeNode * s;
printf("输入图的顶点数和边数(用逗号分隔):\n");
scanf("%d,%d",&(G->n),&(G->e)); /*保存输入的顶点数和边数*/
printf("输入顶点信息(不超过2个字符):\n");
for (i=0;i<G->n;i++) /*建立n个顶点的顶点数组*/
{scanf("\n%s",G->adjlist[i].vertex); /*输入每个顶点的标识信息*/
G->adjlist[i].firstedge=NULL; /*顶点的邻接表头指针设为空*/
}
printf("\n输入图中每条边所依附的两个顶点的的标识信息: ");
for (k=0;k<G->e;k++) /*输入e条边建立邻接表*/
{
printf("\n输入第%d条边的第1个顶点:",k+1);
scanf("%s",vex1);
printf("输入第%d条边的第2个顶点:",k+1);
scanf("%s",vex2);
i=Locate(G,vex1);j=Locate(G,vex2); /*i,j为顶点在顶点数组中的下标 */
s=(EdgeNode*)malloc(sizeof(EdgeNode)); /*生成新的边结点s*/
s->adjvex=j; /*邻接点序号为j*/
s->next=G->adjlist[i].firstedge; /*将新的边结点s插入到顶点Vi的邻接表头部*/
G->adjlist[i].firstedge=s;
}
}
示例6: CreateOLG
void CreateOLG(OLGraph *G) /*采用十字链表表示,构造有向图G*/
{
int i,j,k;
char vex1[3],vex2[3];
ArcNode * s;
printf("输入有向图的顶点数和弧数(用逗号分隔:)\n");
scanf ("%d,%d",&(G->vexnum),&(G->arcnum));
printf("输入顶点信息(不超过2个字符):\n");
for (i=0;i<G->vexnum;i++) /*建立顶点表*/
{
scanf("\n%s",G->vlist[i].vertex); /*输入每个顶点的标识信息*/
G->vlist[i].firstin=NULL;G->vlist[i].firstout =NULL; /*初始化指针*/
}
for(k=0;k<G->arcnum; k++) /*输入e条弧,构造十字链表*/
{
printf("\n输入第%d条边的第1个顶点:",k+1);
scanf("%s",vex1);
printf("输入第%d条边的第2个顶点:",k+1);
scanf("%s",vex2);
i=Locate(G,vex1);j=Locate(G,vex2); /*i,j为弧<Vi,Vj>的顶点对应的数组下标 */
s=(ArcNode*) malloc (sizeof(ArcNode)); /*生成新的弧结点s */
s->tailvex=i;s->headvex=j;
s->hlink=G->vlist[j].firstin;
s->tlink=G->vlist[i].firstout;
/*
*s={ i,j,G->vlist[j].firstin,G->vlist[i].firstout}; 对弧结点进行赋值*/
/*{tailvex,headvex,hlink,tlink}*/
G->vlist[j].firstin=G->vlist[i].firstout=s; /*完成在入弧和出弧链表链头的插入*/
}
}
示例7: HandleKey
boolean TextManip::Manipulating (Event& e) {
boolean manipulating = true;
if (e.eventType == KeyEvent) {
manipulating = HandleKey(e);
} else if (e.eventType == MotionEvent && _selecting) {
SelectMore(Locate(e.x, e.y));
} else if (e.eventType == DownEvent) {
if (e.shift) {
SelectMore(Locate(e.x, e.y));
_selecting = true;
} else if (Contains(e.x, e.y)) {
Select(Locate(e.x, e.y));
_selecting = true;
} else {
manipulating = false;
}
} else if (e.eventType == UpEvent) {
_selecting = false;
}
return manipulating;
}
示例8: getBarklemcross
bool_t getBarklemcross(Barklemstruct *bs, RLK_Line *rlk)
{
const char routineName[] = "getBarklemcross";
int index;
double Z, neff1, neff2, findex1, findex2, reducedmass, meanvelocity,
crossmean, E_Rydberg, deltaEi, deltaEj;
Element *element;
element = &atmos.elements[rlk->pt_index - 1];
/* --- Note: ABO tabulations are valid only for neutral atoms -- -- */
if (rlk->stage > 0)
return FALSE;
if ((deltaEi = element->ionpot[rlk->stage] - rlk->Ei) <= 0.0)
return FALSE;
if ((deltaEj = element->ionpot[rlk->stage] - rlk->Ej) <= 0.0)
return FALSE;
Z = (double) (rlk->stage + 1);
E_Rydberg = E_RYDBERG / (1.0 + M_ELECTRON / (element->weight * AMU));
neff1 = Z * sqrt(E_Rydberg / deltaEi);
neff2 = Z * sqrt(E_Rydberg / deltaEj);
if (rlk->Li > rlk->Lj) SWAPDOUBLE(neff1, neff2);
if (neff1 < bs->neff1[0] || neff1 > bs->neff1[bs->N1-1])
return FALSE;
Locate(bs->N1, bs->neff1, neff1, &index);
findex1 =
(double) index + (neff1 - bs->neff1[index]) / BARKLEM_DELTA_NEFF;
if (neff2 < bs->neff2[0] || neff2 > bs->neff2[bs->N2-1])
return FALSE;
Locate(bs->N2, bs->neff2, neff2, &index);
findex2 =
(double) index + (neff2 - bs->neff2[index]) / BARKLEM_DELTA_NEFF;
/* --- Find interpolation in table -- -------------- */
rlk->cross = cubeconvol(bs->N2, bs->N1,
bs->cross[0], findex2, findex1);
rlk->alpha = cubeconvol(bs->N2, bs->N1,
bs->alpha[0], findex2, findex1);
reducedmass = AMU / (1.0/atmos.H->weight + 1.0/element->weight);
meanvelocity = sqrt(8.0 * KBOLTZMANN / (PI * reducedmass));
crossmean = SQ(RBOHR) * pow(meanvelocity / 1.0E4, -rlk->alpha);
rlk->cross *= 2.0 * pow(4.0/PI, rlk->alpha/2.0) *
exp(gammln((4.0 - rlk->alpha)/2.0)) * meanvelocity * crossmean;
rlk->vdwaals = BARKLEM;
return TRUE;
}
示例9: rm
void rm (char *name )
{
int no_entries;
word dirsize;
Stream *s;
int isdir;
Object *o = Locate(CurrentDir,name);
if( o == Null(Object) )
{ fprintf(stderr,"Cannot find %s : %lx\n",name, Result2(CurrentDir));
errors++;
return;
}
isdir = (int)(o->Type & Type_Directory);
if (!isdir)
{ fprintf(stderr,"%s: %s is not a directory\n", progname, name);
errors++;
return;
}
Close (o);
del(name);
while ( pflag && ( strcmp ( ( name = dirname (name) ) , "." ) != 0 ) ) {
o = Locate(CurrentDir,name);
if( o == Null(Object) )
{ fprintf(stderr,"Cannot find %s : %lx\n",name, Result2(CurrentDir));
errors++;
return;
}
s = Open(o,NULL,O_ReadOnly);
if( s == Null(Stream) )
{
fprintf(stderr,"Cannot open %s : %lx\n",name,Result2(o));
errors++;
return;
}
dirsize = GetFileSize(s);
Close(s);
Close(o);
no_entries = (int)dirsize/sizeof(DirEntry);
if (no_entries == 2)
del (name);
/* Having only two entries namely . and .. the directory 'name' will be deleted */
/* without complaint from 'delete'. */
}
return;
}
示例10: run
int run(Object *w,string program, string *argv, bool wait)
{
Object *code;
Object *prog, *objv[2];
Stream *s, *strv[4];
char *dummy = Null(char);
word e;
Environ env;
char mcname[50];
code = Locate(NULL,program);
prog = Execute(NULL,code);
if( prog == Null(Object)) return false;
s = Open(prog,NULL,O_WriteOnly);
if( s == Null(Stream) ) return false;
MachineName(mcname);
objv[0] = Locate(NULL,"/helios");
objv[1] = Null(Object);
strv[0] = Open(w,NULL,O_ReadOnly);
strv[1] = Open(w,NULL,O_WriteOnly);
strv[2] = Open(w,NULL,O_WriteOnly);
strv[3] = Null(Stream);
env.Argv = argv;
env.Envv = &dummy;
env.Objv = &objv[0];
env.Strv = &strv[0];
e = SendEnv(s->Server,&env);
if( wait )
{
MCB m;
InitMCB(&m,0,prog->Reply,NullPort,0);
m.Timeout = MaxInt;
while((e = GetMsg(&m)) == EK_Timeout);
}
Close(code);
Close(prog);
Close(s);
Close(objv[0]);
Close(strv[0]);
Close(strv[1]);
Close(strv[2]);
return true;
}
示例11: isExist
bool isExist (MGraph G, VertexData v1, VertexData v2)
{
int i, j;
i = Locate (&G, v1);
j = Locate (&G, v2);
if (G.arcs[i][j] == INFINITY)
return false;
else
return true;
}
示例12: CreateGraph
void CreateGraph(MGraph *g)
{
int i ,j,k,w;
char v1,v2;
char temp;
printf("输入顶点数目:Vexnum = ");
scanf("%d",&(g->Vexnum));
printf("\n输入边的数目:Edgenum = ");
scanf("%d",&(g->Edgenum));
#ifdef DEBUG
printf("Vexnum =%d ,edgenum = %d\n",g->Vexnum,g->Edgenum);
#endif
i = 0;
printf("请输入顶点Vex元素%d个字符:",g->Vexnum);
while(i < g->Vexnum)
{
temp = getchar();
if(temp != '\n')
g->Vex[i++] = temp;
}
while(getchar() != '\n'); //消耗掉多余的getchar(),防止过多输入;
#ifdef DEBUG
i = 0;
while(i < g->Vexnum)
{
printf("Vex[%d] = %c\n",i,g->Vex[i++]);
}
#endif
//初始化
for(i = 0 ; i < g->Vexnum ; i++)
for( j = 0 ; j < g->Vexnum ; j ++)
g->Edge[i][j] = 0;
for(k = 0 ; k < g->Edgenum ; k++)
{
printf("请输入第%d边的依附的顶点vx,vy,以及<vx,vy>的权值w,格式x,y,w:\n",k);
v1 = getchar();
v2 = getchar();
scanf("%d",&w);
while(getchar() != '\n');
#ifdef DEBUG
printf("输入为%c %c %d \n",v1 ,v2 , w);
#endif
i = Locate(g,v1);
j = Locate(g,v2);
g->Edge[i][j] = w; //弧<v1,v2>
g->Edge[j][i] = w; //对称弧<v2,v1>
}
}
示例13: Select
void ClassEditor::ScrollBy (int lines) {
TextEditor::ScrollBy(0, -lines*shape->vunits);
// explicit TextEditor:: works around cfront 1.2 bug
int line = text->LineNumber(Dot());
Coord b = display->Base(line);
Coord t = display->Top(line);
if (b < 0) {
Select(Locate(0, 0));
} else if (t > ymax) {
Select(Locate(0, ymax));
}
}
示例14: main
void main()
{
int i;
ElemType e;
DLink *L;
InitList(L); /*初始化双链表L*/
InsElem(L, 'a', 1); /*插入元素*/
InsElem(L, 'c', 2);
InsElem(L, 'a', 3);
InsElem(L, 'e', 4);
InsElem(L, 'd', 5);
InsElem(L, 'b', 6);
printf("线性表:");
DispList(L);
printf("长度:%d\n", GetLength(L));
i = 3;
GetElem(L, i, e);
printf("第%d个元素:%c\n", i, e);
e = 'a';
printf("元素%c是第%d个元素\n", e, Locate(L, e));
i = 4;
printf("删除第%d个元素\n", i);
DelElem(L, i);
printf("线性表:");
DispList(L);
}
示例15: groupsearch
void groupsearch(PEO *h) //查询函数定义
{
char temp; //定义单字符temp
char find[20]; //定义字符串find[]
int n=0;
PEO *p,*p0; //定义节点p,p0
if(h==NULL)
{
printf("\n\a对不起,无信息可查询!\n");
return;
}
else
{
printf("\n请输入您要查询的群组:");
scanf("%s",find);
p=Locate(h,find,"group"); //调用Locate 函数,按群组名进行查找匹配
}//else if
if(p)
{
printf("\n ==============>查询结果<==============\n");
menu4();
while(p)
{
p0=p;
data2(p0,find); //输出按群组名查找的结果
p=p->next; //节点后移
if((strcmp(find,p0->group)==0)) //当有重复群组名时,n加1
n++;
}//while
printf("该群组有 %d 个联系人。 \n",n);
menu4();
}//if
else printf("\n\a对不起,无信息可查询!\n");
}