本文整理汇总了C++中std::list::unique方法的典型用法代码示例。如果您正苦于以下问题:C++ list::unique方法的具体用法?C++ list::unique怎么用?C++ list::unique使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类std::list
的用法示例。
在下文中一共展示了list::unique方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: regex_content
int regex_content(const char * regex, const char * string1, std::list<std::string> &urls) {
regex_t preg;
int cflags = REG_ICASE;
size_t size = 0;
int errcode = 0;
char errbuf[1024] = {0};
size_t errbuf_size = 1024;
errcode = regcomp(&preg, regex, cflags);
if (errcode != 0)
{
size = regerror(errcode, &preg, errbuf, errbuf_size);
plog(error, "errcode = %d, %s(%lu)\n", errcode, errbuf, size);
return 1;
}
regmatch_t pmatch[1];
size_t nmatch = 1;
int eflags = REG_NOTBOL;
while (errcode == 0)
{
do {
errcode = regexec(&preg, string1, nmatch, pmatch, eflags);
if (errcode == 0)
{
char sub_url[1024];
memset(sub_url, 0, sizeof sub_url);
memcpy(sub_url, string1 + pmatch[0].rm_so, pmatch[0].rm_eo - pmatch[0].rm_so);
if (strstr(sub_url, ".js")) { break; }
if (strstr(sub_url, ".png")) { break; }
if (strstr(sub_url, ".jpg")) { break; }
if (strstr(sub_url, ".css")) { break; }
if (strstr(sub_url, ".ico")) { break; }
if (strstr(sub_url, "img")) { break; }
if (strstr(sub_url, "cgi")) { break; }
if (strstr(sub_url, "gif")) { break; }
if (strstr(sub_url, "action.do")) { break; }
if (strstr(sub_url, ".php")) { break; }
if (strstr(sub_url, ".asp")) { break; }
if (strstr(sub_url, ".aspx")) { break; }
if (strstr(sub_url, ".jsp")) { break; }
if (strstr(sub_url, "sta")) { break; }
if (strstr(sub_url, "ccnt")) { break; }
if (strstr(sub_url, ".svg")) { break; }
if (strstr(sub_url, "?")) { break; }
if (strstr(sub_url, ".org")) { break; }
urls.push_back(sub_url);
}
} while (false);
string1 += pmatch[0].rm_so + 1;
}
urls.unique();
regfree(&preg);
return 0;
}
示例2:
void Vwr::CameraManipulator::setNewPosition(osg::Vec3d cameraTargetPoint, osg::Vec3d cameraInterestPoint, std::list<osg::ref_ptr<Data::Node> > selectedCluster, std::list<osg::ref_ptr<Data::Edge> > selectedEdges)
{
movingAutomatically = true;
this->cameraTargetPoint = cameraTargetPoint;
this->cameraInterestPoint = cameraInterestPoint;
//cout << "Camera targetPoint: " << cameraTargetPoint.x() << " " << cameraTargetPoint.y() << " " << cameraTargetPoint.z() << "\n";
//cout << "Camera interest targetPoint: " << cameraInterestPoint.x() << " " << cameraInterestPoint.y() << " " << cameraInterestPoint.z() << "\n";
std::list<osg::ref_ptr<Data::Edge> >::iterator i;
// prida hrany medzi body zaujmu
for (i = selectedEdges.begin(); i != selectedEdges.end(); ++i)
{
selectedCluster.push_back((*i)->getSrcNode());
selectedCluster.push_back((*i)->getDstNode());
}
selectedCluster.unique();
this->selectedCluster = selectedCluster;
automaticMovementInitialized = false;
}
示例3: add_antiques_to_list
//.........这里部分代码省略.........
char single_line[1024];
FILE *fp;
int dirlen=strlen(config.upload_dir);
struct passwd *apache_info=getpwnam(config.httpd_user);
int del_time=time(0)-86400*days;
int nfiles=0;
if (!apache_info) {
log_messages.printf(MSG_CRITICAL,
"default httpd_user '%s' found - add <httpd_user> entry in config.xml\n",
config.httpd_user
);
return -1;
}
log_messages.printf(MSG_DEBUG,
"Searching for antique files older than %d days\n", days
);
sprintf(command, "find %s -type f -mtime +%d -follow | head -%d", config.upload_dir, days, antique_limit);
// Now execute the command, read output on a stream. We could use
// find to also exec a 'delete' command. But we want to log all
// file names into the log, and do lots of sanity checking, so
// this way is better.
//
if (!(fp=popen(command, "r"))) {
log_messages.printf(MSG_CRITICAL,
"command %s failed\n", command
);
return -2;
}
while (fgets(single_line, 1024, fp)) {
char pathname[1024];
char *fname_at_end=NULL;
int nchars=strlen(single_line);
struct stat statbuf;
const char *err=NULL;
FILE_RECORD fr;
// We can interrupt this at any point.
// pclose() is called when process exits.
check_stop_daemons();
// Do serious sanity checking on the path before
// adding the file!!
//
if (!err && nchars > 1022) err="line too long";
if (!err && nchars < dirlen + 1) err="path shorter than upload directory name";
if (!err && single_line[nchars-1] != '\n') err="no newline terminator in line";
if (!err && strncmp(config.upload_dir, single_line, dirlen)) err="upload directory not in path";
if (!err && single_line[dirlen] != '/') err="no slash separator in path";
if (!err) single_line[nchars-1]='\0';
if (!err && stat(single_line, &statbuf)) err="stat failed";
if (!err && statbuf.st_mtime > del_time) err="file too recent";
if (!err && apache_info->pw_uid != statbuf.st_uid) err="file not owned by httpd user";
if (!err && !(fname_at_end=rindex(single_line+dirlen, '/'))) err="no trailing filename";
if (!err) fname_at_end++;
if (!err && !strlen(fname_at_end)) err="trailing filename too short";
// skip NFS file system markers of form .nfs*
//
if (!err && !strncmp(fname_at_end, ".nfs", 4)) {
log_messages.printf(MSG_CRITICAL,
"Ignoring antique (stale) NFS lockfile %s\n", single_line
);
continue;
}
if (!err && get_file_path(fname_at_end, config.upload_dir, config.uldl_dir_fanout, pathname)) err="get_file_path() failed";
if (!err && strcmp(pathname, single_line)) err="file in wrong hierarchical upload subdirectory";
if (err) {
log_messages.printf(MSG_CRITICAL,
"Can't list %s for deletion: %s\n",
single_line, err
);
// This file deleting business is SERIOUS. Give up at the
// first sign of ANYTHING amiss.
//
pclose(fp);
return -3;
}
// insert this file onto the list
fr.date_modified = statbuf.st_mtime;
fr.name = fname_at_end;
files_to_delete.push_back(fr);
nfiles++;
} // while (fgets(single_line, 1024, fp)) {
pclose(fp);
log_messages.printf(MSG_DEBUG,
"Found %d antique files to delete\n",
nfiles
);
files_to_delete.sort();
files_to_delete.unique();
return nfiles;
}
示例4: remove_duplicate
void removesingle::remove_duplicate(std::list<production>& plist)
{
plist.unique(p_equal());
}
示例5: triangulate
//------------------------------------------------------------
//------------------------------------------------------------
//------------------------------------------------------------
void triangulate(std::list<Point> &pts, std::vector<Triangle> &tri, bool clockwise = false, double tol=.001){
pts.unique();
while ( !pts.empty() && pts.front() == pts.back() ){ pts.pop_back(); }
if ( pts.size() < 3 ) return;
//cycle by 1 to have a better looking output...
pts.push_back(pts.front()); pts.pop_front();
std::list<Point>::iterator a,b,c,m;
int sign = (clockwise ? -1 : 1 );
a = pts.end(); --a;
b = pts.begin();
c = b; ++c;
//now a,b,c are 3 consecutive points.
if ( pts.size() == 3 ) {
Triangle abc;
abc.a = (*a);
abc.b = (*b);
abc.c = (*c);
abc.area = sign *( cross((*b) - (*a),(*c) - (*b))/2) ;
if ( abc.area >0 ){
tri.push_back(abc);
pts.clear();
}
return;
}
bool found = false;
while( c != pts.end() ){
double abac = cross((*b)-(*a),(*c)-(*a));
if ( fabs(abac)<tol && dot( *b-*a, *c-*b ) <= 0) {
//this is a degenerated triangle. Remove it and continue.
pts.erase(b);
triangulate(pts,tri,clockwise);
return;
}
m = c;
++m;
while ( m != pts.end() && !found && m!=a){
bool pointing_inside;
double abam = cross((*b)-(*a),(*m)-(*a));
double bcbm = cross((*c)-(*b),(*m)-(*b));
if ( sign * abac > 0 ){
pointing_inside = ( sign * abam >= 0 ) && ( sign * bcbm >= 0 );
}else {
pointing_inside = ( sign * abam >=0 ) || ( sign * bcbm >=0);
}
if ( pointing_inside ){
std::list<Point>::iterator p=c,q=++p;
Point inter;
while ( q != pts.end() && !intersect(*b,*m,*p,*q,inter) ){
p=q;
++q;
}
if ( q == pts.end() ){
found = true;
}else{
++m;
}
}else{
++m;
}
}
if ( found ){
std::list<Point>pts_beg;
pts.insert(b,*b);
pts.insert(m,*m);
pts_beg.splice(pts_beg.begin(), pts, b, m);
triangulate(pts_beg,tri,clockwise);
triangulate(pts,tri,clockwise);
return;
}else{
a = b;
b = c;
++c;
}
}
//we should never reach this point.
}