• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ chop函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中chop函数的典型用法代码示例。如果您正苦于以下问题:C++ chop函数的具体用法?C++ chop怎么用?C++ chop使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了chop函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: units2bytes

void AdvancedSearchState::SetSizeFilter(Ui::MainWindow* window, SearchParameter& parameter)
{
	QString option = window->sizeComboBox->currentText();
	bool sizeIgnored = option.indexOf("Ignore") != -1;

	qint64 lowerSize = 0,
			 upperSize = 0;

	if (sizeIgnored == false)
	{
		bool between = option.indexOf("Between") != -1;
		bool larger  = option.indexOf("Larger")  != -1;
		bool smaller = option.indexOf("Smaller") != -1;

		if (larger)
			lowerSize = units2bytes(QString("%1 %2").arg(window->sizeLineEdit->text()).arg(
							chop(window->sizeUnitsComboBox->currentText(), 4))); // chop 'ytes'
		if (smaller)
			upperSize = units2bytes(QString("%1 %2").arg(window->sizeLineEdit->text()).arg(
							chop(window->sizeUnitsComboBox->currentText(), 4))); // chop 'ytes'
		if (between)
		{
			lowerSize = units2bytes(QString("%1 %2").arg(window->sizeLineEdit->text()).arg(
							chop(window->sizeUnitsComboBox->currentText(), 4))); // chop 'ytes'

			upperSize = units2bytes(QString("%1 %2").arg(window->sizeLineEdit2->text()).arg(
							chop(window->sizeUnitsComboBox2->currentText(), 4)));
		}
	}
	parameter.phaseOneParam->SetSizeLowerBound(lowerSize);
	parameter.phaseOneParam->SetSizeUpperBound(upperSize);
}
开发者ID:HT509-net,项目名称:SearchMonkeyClone,代码行数:32,代码来源:AdvancedSearchState.cpp


示例2: chop

int chop(int target, int* array, size_t size)
{
    // handle empty array
    if(size == 0) {
        return -1;
    } else if(size == 1) { // single element array - check value
        if(array[0] == target) {
            return 0;
        } else {
            return -1;
        }
    } else { // wider array are split into two parts and we search in the part in that the element should be
        int split = (size / 2);

        if(target < array[split]) {
            return chop(target, array, split);
        } else {
            int res;

            if((res = chop(target, array + split, size - split)) != -1) {
                return split + res;    
            } else {
                return res;
            }
            
        }
    }
}
开发者ID:schoradt,项目名称:c-code-katas,代码行数:28,代码来源:chop3.c


示例3: load_high_scores

void load_high_scores() {
	FILE *hiscores_file = fopen(options.full_path("hiscores"), "r");

	num_high_scores = 0;

	if (!hiscores_file) {
		return;
	}

	char line[256];
	char *not_empty;
	while (!feof(hiscores_file)) {
		// Get name
		not_empty = fgets(line, 256, hiscores_file);
		chop(line);
		if (line[0] == '\0' || !not_empty) break;
		strcpy(high_scores[num_high_scores].name, line);

		// Get score
		not_empty = fgets(line, 256, hiscores_file);
		chop(line);
		if (line[0] == '\0' || !not_empty) break;

		s32 the_score;
		intval(line, &the_score);
		
		high_scores[num_high_scores].score = the_score;

		num_high_scores++;
	}

	fclose(hiscores_file);
}
开发者ID:yjerem,项目名称:rodents-revenge-ds,代码行数:33,代码来源:hiscores.cpp


示例4: netchanNeedop

void netchanNeedop(BotNet *source, char *rest)
{
	BotNet	*bn;
	BotInfo	*binfo;
	char	*channel;
	int	guid;

	guid = a2i(chop(&rest));
	channel = chop(&rest);
	if (errno || guid < 1 || !channel)
		return;

	botnet_relay(source,"CO%i %s\n",guid,channel);

	for(bn=botnetlist;bn;bn=bn->next)
	{
		if (bn->status != BN_LINKED)
			continue;
		for(binfo=bn->botinfo;binfo;binfo=binfo->next)
		{
			if (binfo->guid == guid)
				check_botinfo(binfo,channel);
		}
        }
}
开发者ID:Cloudxtreme,项目名称:energymech,代码行数:25,代码来源:net_chan.c


示例5: read_seenlist_callback

int read_seenlist_callback(char *rest)
{
	char	*nick,*uh,*pa,*pb;
	time_t	when;
	int	t;

	nick = chop(&rest);
	uh   = chop(&rest);

	when = a2i(chop(&rest)); /* seen time, a2i handles NULL */
	if (errno)
		return(FALSE);

	t    = a2i(chop(&rest)); /* seen type, a2i handles NULL */
	if (errno)
		return(FALSE);

	pa = chop(&rest);
	pb = rest;

	if ((now - when) < (SEEN_TIME * 86400))
	{
		/* if (pa && !*pa)
			pa = NULL; chop() doesnt return empty strings */
		if (!*pb)
			pb = NULL;
		make_seen(nick,uh,pa,pb,when,t);
	}
	return(FALSE);
}
开发者ID:Cloudxtreme,项目名称:energymech,代码行数:30,代码来源:seen.c


示例6: r

///Calculate Exp[I*m]
LaGenMatComplex snake::math::expm2(LaGenMatDouble &m)
{
  //std::cout<<m<<std::endl;
  int dim = m.size(0);
  LaGenMatComplex r(dim,dim);
  LaGenMatDouble eigvec(dim,dim);
  LaGenMatComplex eigvecC(dim,dim);
  LaVectorDouble eigval(dim);
  LaVectorComplex eigvalim(dim);
  eigvec = m;
  snake::math::SSMED(eigvec.addr(),dim,eigval.addr());

  for(int i = 0;i<dim;i++)
    eigvalim(i) = LaComplex(cos(eigval(i)),sin(eigval(i)));
  LaGenMatComplex temp(dim,dim);
  temp = LaComplex(0,0);
  for(int i = 0;i<dim;i++)
    temp(i,i) = eigvalim(i);

  chop(temp,1e-15);
  //std::cout<<temp<<std::endl;
  eigvecC = eigvec.to_LaGenMatComplex();
  LaGenMatComplex tempx(dim,dim);
  Blas_Mat_Mat_Trans_Mult(temp,eigvecC,tempx);
  Blas_Mat_Mat_Mult(eigvecC,tempx,r);
  chop(r,1e-15);
  return r;
}
开发者ID:huangrzh,项目名称:snake-dmrg,代码行数:29,代码来源:public.cpp


示例7: chop

		TEMP_PAR
		typename NUM_SYS::DigitSet 
		  NUM_SYS::getDigits(const Vector<INT_TYPE>& z) const
		{
			bool finished = false;
			IVector v = vector_traits_int::copy(z);
			DigitSet digits;
      digits.reserve(20);
			digits.push_back(v);
			v = chop(v);
			while(!finished)
			{
				if( find_if(digits.begin(), digits.end(), DigitFinder(v)) != 
						digits.end())
				{
					finished = true;
				}
				else
				{
					digits.push_back(v);
					v = chop(v);
				}
			}
			return digits;
		}
开发者ID:elesd,项目名称:GeneralNumberSystems,代码行数:25,代码来源:numbersystem.hpp


示例8: dirtodots

static void dirtodots(char *path, unsigned maxlen)
{
	char *first_slash, *end_slash;

	first_slash = strchr(path, '/');

	if(!first_slash) {
		chop(path, maxlen);
		return;
	}

	if(strncmp(first_slash+1, "...", 3) == 0) {
		end_slash = strchr(first_slash+5, '/');
	} else
		end_slash = strchr(first_slash+1, '/');

	if(!end_slash) {
		chop(path, maxlen);
		return;
	}

	if(end_slash - first_slash < 4) /* /fu/ */
		strpush(first_slash+1, 4 - (end_slash - first_slash));
	else /* /foobar/ */
		strcpy(first_slash + 4, end_slash);
	strncpy(first_slash+1, "...", 3);
}
开发者ID:wmene,项目名称:yafc-1.1.2,代码行数:27,代码来源:shortpath.c


示例9: main

void main() {
  allegrosetup(scrwid,scrhei);
  makesplitpalette(&redtowhitepalette,&greentowhitepalette);
  PPsetup(scrwid,scrhei,4);
  JBmp j=JBmp(scrwid,scrhei);
  j.clear();
  List<Part> ps=List<Part>();
  for (int i=1;i<=10;i++) {
    Part p;
    newpart(&p);
    ps+p;
  }
  int frame=0;
  do {
    for (int i=1;i<=ps.len;i++) {
      Part *p=ps.p2num(i);
      int sx,sy;
      PPgetscrpos(p->pos,&sx,&sy);
      int sxb,syb;
      PPgetscrpos(p->pos+V3d(p->rad,0,0),&sxb,&syb);
      float rad=sqrt(mysquare(sx-sxb)+mysquare(sy-syb));
      j.filledcircle(sx,sy,rad,p->inc);
//      j.filledcirclenodarker(sx,sy,rad/3,p->inc);
    }
    for (int x=0;x<scrwid;x++)
      for (int y=0;y<scrhei;y++) {
        int k=j.bmp[y][x];
        if (k==128)
          j.bmp[y][x]=0;
        if (k<128)
          j.bmp[y][x]=chop(k-4,0,128);
        else
          j.bmp[y][x]=128+chop(k-4-128,0,128);
      }
    j.writetoscreen();
    Matrix m,n;
    V3d rotaxis=V3d::rotate(V3d(0,1,0),V3d(0,0,1),pi/4.0*sin(2*pi*frame/4000));
    m.makerotation(rotaxis,pi/1000.0);
    n.makerotation(rotaxis,-pi/1000.0);
    for (int i=1;i<=ps.len;i++) {
      Part *p=ps.p2num(i);
      if (p->sgn>0)
        p->pos=m*p->pos;
      else
        p->pos=n*p->pos;
      p->pos=p->pos+V3d(0,0,-0.03);
      if (p->pos.z<-4 || max(myabs(p->pos.x),myabs(p->pos.y))>2)
        newpart(p);
    }
    frame++;
  } while (!key[KEY_ESC]);
}
开发者ID:10crimes,项目名称:code,代码行数:52,代码来源:redgre~1.c


示例10: load_dsc

static void load_dsc()
{
    s_objtab.clear();
    Slice dsc = read_file("grafix/corri01.dsc");
    chop_until(dsc, 0); // skip until first 0 byte

    while (dsc.len()) {
        // header:
        //   void *img[3];
        //   U8 x, y;
        //   U8 unk;
        //   U8 cursorType, imgType;
        Slice header = chop(dsc, 17);
        Str name = to_string(chop_until(dsc, '\r'));
        Slice script = chop_until(dsc, 0);

		// fix up script
		for (U32 i=0; i < script.len(); i++)
			if (script[i] == '^')
				script[i] = '\n';

        //print_hex(Str::fmt("%2d %8s: ", s_objtab.size(), name), header, 17);

        ObjectDesc d;
        d.script = script;
        d.gfx_name = name;
        d.x = header[12];
        d.y = header[13];
        d.flipX = header[14];
        d.cursor = header[15];
        // imgtype = header[16]
        s_objtab.push_back(d);
    }
}
开发者ID:rygorous,项目名称:vision1,代码行数:34,代码来源:corridor.cpp


示例11: usernameHandler

void usernameHandler(char *buffer, int sock) //handles username requests
{
    grabContents(buffer); //get the actual message minus command
    chop(buffer); //chop off anything extraneous
    
    int x = 0;
    
    for (x = 0; x < MAX_USERS; x++) //check username with all users and return bad if not found
    {
        if (strcmp(users[x].username, buffer) == 0)
        {
            char tempBuffer[MAX_MESSAGE_SIZE];
            sprintf(tempBuffer, " %dError: username '%s' all ready taken\n", NAME_TAKEN, buffer);
            writeMessageDefined(sock, tempBuffer);
            return;
        }
    }
    
    //if good return a good call and establish the username
    sprintf(users[sock].username, "%s", buffer);
    printf("\nUsername established: %s\n", users[sock].username);  
    
    zeroBuffer(buffer);
    sprintf(buffer, "Server: Username established '%s'\n", users[sock].username);
    
    writeMessageDefined(sock, buffer);
}
开发者ID:auntiepickle,项目名称:YetAnotherChatClient,代码行数:27,代码来源:server.c


示例12: do_rkicksay

void do_rkicksay(COMMAND_ARGS)
{
	/*
	 *  on_msg checks: CARGS
	 */
	KickSay *kick;
	char	*channel;

	channel = chop(&rest);	/* cant be NULL (CARGS) */
	if (!ischannel(channel) && *channel != '*')
		goto usage;

	if (!*rest)
		goto usage;

	if (!(kick = find_kicksay(rest,channel)))
	{
		to_user(from,"I'm not kicking on that");
		return;
	}
	to_user(from,"No longer kicking on %s",kick->mask);
	remove_kicksay(kick);
	current->ul_save++;
	return;
usage:
	usage(from);	/* usage for CurrentCmd->name */
}
开发者ID:Cloudxtreme,项目名称:energymech,代码行数:27,代码来源:kicksay.c


示例13: main

int main(int argc,char**argv)
{
  FILE *fi,*fo;
  char buf[256];
  char *st;

  if(argc==2) {
    fi=fopen(argv[1],"r");
    strcpy(buf,argv[1]);
    //strcpy(buf+strlen(buf)-4,".log"); // ".xxx"->".log"
    strcpy(buf+strlen(buf)-4,"_smile"); // ".xxx" -> "_smile.xxx"
    strcpy(buf+strlen(buf)  ,argv[1]+strlen(argv[1])-4);
    fo=fopen(buf,"w");

    while(st=fgets(buf,sizeof(buf),fi)){
      chop(st);
      fprintf(fo,"%s(^^)/~\n",st);
    }

    fclose(fi);
    fclose(fo);
    return 0;

  } else {
    printf("USAGE: %s filename",argv[0]);
    return 0;
  }
}
开发者ID:kanedayo,项目名称:cygwin_smile,代码行数:28,代码来源:smile.c


示例14: cmd

void CIMainWindow::startBuilding()
{
    QString cmd(mCompilerPath);
    mProcBuild = new QProcess(this);

    if (mCompilerParamList.size() > 0)
    {
        QString str = mCompilerParamList[mBuildingCount++];

        // TEST ONLY!!!
        str.remove(0, 1);
        str = "\"D:/!GEMS8/" + str;

        QString arg_sln = str.section(' ', 0, 0);
        auto arg_build = str.section(' ', 1, 1);
        auto arg_build_type = str.section(' ', 2);
        arg_sln.remove(0, 1);
        arg_sln.chop(1);
        arg_build_type.remove(0, 1);
        arg_build_type.chop(1);
        QStringList args;
        args << arg_sln << arg_build << arg_build_type;
        mProcBuild->setProgram(cmd);
        mProcBuild->setArguments(args);
        mProcBuild->start();
    }

    QObject::connect(mProcBuild, SIGNAL(readyReadStandardOutput()), this, SLOT(on_readyReadBuildingStandardOutput()));
    QObject::connect(mProcBuild, SIGNAL(finished(int)), this, SLOT(buildAnotherSolutionOrDone()));
}
开发者ID:qiaone,项目名称:gems-ci,代码行数:30,代码来源:cimainwindow.cpp


示例15: convert_flags_to_str

char * convert_flags_to_str(unsigned long flags)
{
unsigned int i;
unsigned long p;
static char buffer[290];
	*buffer = 0;
	for (i = 0, p = 1; strflags[i]; i++, p <<= 1)
	{
		if (flags & p)
		{
			strmcat(buffer, strflags[i], 280);
			strmcat(buffer, ",", 280);
		}
	}
	for (i = 0, p = PROT_REOP; protflags[i]; i++, p <<= 1)
	{
		if (flags & p)
		{
			strmcat(buffer, protflags[i], 280);
			strmcat(buffer, ",", 280);
		}
	}
	if (*buffer)
		chop(buffer, 1);
	return buffer;
}
开发者ID:nikolatesla,项目名称:BitchXMPP,代码行数:26,代码来源:userlist.c


示例16: STRING_create

static uclptr_t STRING_create (const void* sample_data)
{
	if (sizeof(char*) <= sizeof(cell_t))
	{
		uclptr_t storage_index = cell_alloc();
		if (storage_index != NIL)
		{
			int length = strlen(sample_data) + 1;
			//char **storage_cell_ptr = (char**)&uclmem[storage_index];
			char **storage_cell_ptr = (char**)&CONTAINER(storage_index);
			MANAGED(storage_index) = 1;
			*storage_cell_ptr = (char*)malloc(length);
			memset (*storage_cell_ptr, 0, length);
			strcpy (*storage_cell_ptr, sample_data);
			return storage_index;
		}
	}
	else /* физический указатель очень велик и не помещается даже на место целой ячейки */
	{
		int length = strlen(sample_data) + 1;
		char *src = (char*)malloc(length);
		strcpy (src, sample_data);
		return chop (&src, sizeof(void*));
	}
	return NIL;
}
开发者ID:man-at-work,项目名称:ucl,代码行数:26,代码来源:types.c


示例17: main

main()
{
  int msqid;
  key_t msgkey;
  struct msgbuf{
    long mtype;
    char mdata[256];
  };
  struct msgbuf msgdata,*p;

  p = &msgdata;

  printf("Enter message: ");
  fflush(stdin);
  fgets(p->mdata,BUFSIZ,stdin);

  p->mtype = 2;

  chop(p->mdata);
 
  //  p->mtype = getpid();
  msgkey = ftok("mrecv",'a');
  msqid = msgget(msgkey,IPC_CREAT|0666);
  msgsnd(msqid,p,sizeof(p->mdata),0);
}
开发者ID:kento,项目名称:Samples,代码行数:25,代码来源:msg_send.c


示例18: QFileInfo

QList<ImageSourceItem> QuaZipImageSource::getImageInfoFromArchive(QuaZip *archive, const QString &extractPath)
{
    archive->open(QuaZip::mdUnzip);

    auto i = 0;
    auto images = QList<ImageSourceItem>();
    auto fileNames = archive->getFileNameList();

    fileNames.sort(Qt::CaseInsensitive);
    for (const auto &fileName : fileNames) {

        // Get the file information.
        auto fileInfo = QFileInfo(extractPath + "/" + fileName);
        auto suffix = fileInfo.suffix();
        auto relativePath = fileName;
        relativePath.chop(fileInfo.fileName().length());

        // Insert the file into the list if it is an image file.
        if (Utility::imageFileTypes().contains(suffix, Qt::CaseInsensitive)) {
            auto extractPath = fileInfo.absoluteFilePath();
            auto image = std::make_shared<ImageInfo>(extractPath, relativePath);
            images.append({++i, image});
        }
    }

    archive->close();

    return images;
}
开发者ID:ecbambrick,项目名称:archiveViewer,代码行数:29,代码来源:quazipimagesource.cpp


示例19: main

int main(int argc, char * argv[])
{
    int nbytes = 1;
    char *str = (char *) malloc (nbytes + 1);
    char ** operand = (char **)malloc(2 * sizeof(char *));
    int op;
    double rez;
    int flag = 0;

    while (getline(&str, (size_t *)&nbytes, stdin) > 0 )
    {
        op = chop(str, operand);
        switch (op)
        {
        case 1: rez = atof(operand[0]) + atof(operand[1]); break;
        case 2: rez = atof(operand[0]) - atof(operand[1]); break;
        case 3: rez = atof(operand[0]) * atof(operand[1]); break;
        case 4: rez = atof(operand[0]) / atof(operand[1]); break;
        case 5: rez = pow(atof(operand[0]), atof(operand[1])); break;
        default: flag = 1; break;
        }
        if (flag)
        {
            printf("GRESKA!\n");
        }
        else
        {
            printf("%.2lf\n", rez);
        }
    }
    return 0;
}
开发者ID:damjanmk,项目名称:seavus-praksa,代码行数:32,代码来源:zadaca1.c


示例20: parse_proc_status

int parse_proc_status(char *line)
{
	const char *key;
	char	*dest,*limit;
	int	i;

	key = chop(&line);
#ifdef DEBUG
	debug("pps key = %s (%s)\n",key,line);
#endif
	if (key == NULL)
		return(FALSE);
	for(i=0;sv[i].key;i++)
	{
		if (strncmp(key,sv[i].key,sv[i].klen) == 0)
		{
#ifdef DEBUG
			debug("(parse_proc_status) key %s -> %s\n",key,line);
#endif /* DEBUG */
			dest = sv[i].valbuf;
			limit = sv[i].valbuf + 31;
			while(*line == ' ')
				line++;
			while(*line && dest <= limit)
				*(dest++) = *(line++);
			*dest = 0;
		}
	}
	return(FALSE);
}
开发者ID:MadCamel,项目名称:energymech,代码行数:30,代码来源:hostinfo.c



注:本文中的chop函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ chopLine函数代码示例发布时间:2022-05-30
下一篇:
C++ choose_io_thread函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap