本文整理汇总了C++中PathVector::begin方法的典型用法代码示例。如果您正苦于以下问题:C++ PathVector::begin方法的具体用法?C++ PathVector::begin怎么用?C++ PathVector::begin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PathVector
的用法示例。
在下文中一共展示了PathVector::begin方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: split_vec
static void split_vec(PathVector &full_vec, PathVector &new_vec,
const Path &split_path){
PathVector old_full;
old_full.insert(old_full.begin(),full_vec.begin(),full_vec.end());
full_vec.erase(full_vec.begin(),full_vec.end());
for( PathVector::const_iterator path=old_full.begin() ; path!=old_full.end()
; path++ ){
if(starts_with(*path,split_path))
new_vec.push_back(*path);
else
full_vec.push_back(*path);
}
}
示例2: contains
static bool contains(const PathVector &vec, const Path &path){
for( PathVector::const_iterator comp_path=vec.begin() ; comp_path!=vec.end() ;comp_path++ ){
if(compPath(*comp_path,path)==compPath(path,*comp_path))
return true;
}
return false;
}
示例3: merge
QList<QPoint> ValidPathCreator::createPath(PathVector const & components)
{
if (components.size() == 0) {
return QList<QPoint>();
}
PathVector paths;
foreach (PointVector component, components)
{
int j = 0;
while (j < paths.size())
{
if (getDistance(paths[j], component) == 0) {
component = merge(paths[j], component, 0);
paths.erase(paths.begin() + j);
} else {
j++;
}
}
paths.push_back(component);
}
示例4: CleanupPaths
/**
* Clean up paths that lead nowhere and the root path.
* @param source_id ID of the root node.
* @param paths Paths to be cleaned up.
*/
void MultiCommodityFlow::CleanupPaths(NodeID source_id, PathVector &paths)
{
Path *source = paths[source_id];
paths[source_id] = NULL;
for (PathVector::iterator i = paths.begin(); i != paths.end(); ++i) {
Path *path = *i;
if (path == NULL) continue;
if (path->GetParent() == source) path->Detach();
while (path != source && path != NULL && path->GetFlow() == 0) {
Path *parent = path->GetParent();
path->Detach();
if (path->GetNumChildren() == 0) {
paths[path->GetNode()] = NULL;
delete path;
}
path = parent;
}
}
delete source;
paths.clear();
}
示例5: printable
std::string ContextGen::printable(const PathVector& val)
{
std::string res;
if(val.empty())
return "(empty vector)";
else
res = "(vector)";
Color col(getColorMode());
for(PathVector::const_iterator it = val.begin(); it != val.end(); ++it)
{
res.append(col.red("\n * "));
if(it->isNative()) res.append(col.yellow("[NATIVE] "));
else if(it->isForeign()) res.append(col.yellow("[FOREIGN] "));
else res.append(col.yellow("[NEITHER] ")); // is ok, if windows parity build and unix path with windows backend
res.append(it->get());
}
return res;
}
示例6: BuildPackage
void BuildPackage( const std::string& FolderName, std::string FileName )
{
if( FileName.empty() )
{
fs::path Path( FolderName );
FileName = Path.filename().string() + ".pkg";
}
AutoFile f( new OsFile( FileName, std::ios_base::out | std::ios_base::trunc ) );
PackageWriter writer( f );
PathVector Paths;
fs::path Dir( FolderName );
BuildFilesList( Dir, Paths );
fs::path BasePath = Dir.is_absolute() ? Dir : fs::current_path() / FolderName;
for( PathVector::const_iterator i = Paths.begin(), e = Paths.end(); i != e; ++i )
{
const fs::path& RelPath = *i;
const fs::path PathInPack = RelativePath( BasePath, RelPath );
LOG( "Adding %s as %s\n", RelPath.string().c_str(), PathInPack.string().c_str() );
writer.Add( RelPath, PathInPack );
}
writer.Save();
LOG( "All done." );
}
示例7: findPath
void Algorithm::findPath(const Location& start, const Location& end,
PathVector& output) {
NodeMap l_open;
NodeMap l_closed;
std::priority_queue<Node> l_priority;
// Create Start Node
Location origin;
Node startNode(start, 0, 0, origin);
// Add start to priority queue and open set
l_priority.push(startNode);
l_open[start] = startNode;
while (!l_priority.empty()) {
Node l_current = l_priority.top();
l_priority.pop();
l_open.erase(l_current.location);
l_closed[l_current.location] = l_current;
// Check whether this is the target node
if (l_current.location == end) {
Location current = l_current.location;
while (current != start) {
// output.push_back (index);
output.insert(output.begin(), current);
NodeMapIter open_iter = l_closed.find(current);
current = open_iter->second.origin;
if (current.x == UINT_MAX)
break;
}
return;
}
// Process neighbours
Location* neighbours = new Location[m_numNeighbours];
unsigned int validNeighbours =
m_neighbourFunction(l_current.location, neighbours, m_customData);
for (size_t ii = 0; ii < validNeighbours; ii++) {
// TODO: not needed? if (neighbours[ii] < 0) continue; // Not a
// valid neighbour
int cost = m_costFunction(neighbours[ii], m_customData);
// If cost is -ve, we will close the node
unsigned int path = l_current.distance + cost;
unsigned int priority =
path + m_distanceFunction(neighbours[ii], end, m_customData) +
1;
Node neighbour(neighbours[ii], path, priority, l_current.location);
// Is it closed?
NodeMapIter closed_iter = l_closed.find(neighbours[ii]);
if (closed_iter != l_closed.end()) {
// But dow we now have a better path?
if (cost > 0 && path < closed_iter->second.distance) {
l_closed.erase(closed_iter);
} else {
continue; // It's closed and there's no better path
}
}
NodeMapIter open_iter = l_open.find(neighbours[ii]);
if (open_iter != l_open.end()) {
// Remove it from open if there's a better path now
l_open.erase(open_iter);
} else if (cost >= 0) {
// Neighbour not in open
l_open[neighbours[ii]] = neighbour;
l_priority.push(neighbour);
}
}
delete[] neighbours;
}
}
示例8: fill_data
static void fill_data(NXhandle handle, Data &data, PathVector &data_tree,
const PrintConfig &config){
// local variables to put stuff in
Path units_path;
Path signal_path;
PathVector attr_paths;
// sort out everything
for( PathVector::const_iterator path=data_tree.begin() ; path!=data_tree.end() ; path++ ){
Node end_node=*((*path).rbegin());
if(end_node.type==ATTR){
if(end_node.name=="units"){
units_path=*path;
}else if(end_node.name=="signal"){
signal_path=*path;
}else{
attr_paths.push_back(*path);
}
}else{
data.path=*path;
data.name=end_node.name;
//data.type=end_node.type;
}
}
// get the attributes and fill the structure
data.units=read_attr_as_string(handle,units_path,config);
data.signal=read_int_attr(handle,signal_path);
// get the unknown attributes
for( PathVector::const_iterator path=attr_paths.begin() ; path!=attr_paths.end() ; path++ ){
string value=read_attr_as_string(handle,*path,config);
string key=(*path).rbegin()->name;
data.unknown[key]=value;
}
// ----- from here down gets the data
// open up to the right place
open_path(handle,data.path);
// get the rank, dimensions and type
if(NXgetinfo(handle,&data.rank,data.dims,&data.type)!=NX_OK){
close_path(handle,data.path);
throw "NXgetinfo failed";
}
// allocate space for the data
if(NXmalloc(&data.data,data.rank,data.dims,data.type)!=NX_OK){
close_path(handle,data.path);
throw "NXmalloc failed";
}
// retrieve the data from the file
if(NXgetdata(handle,data.data)!=NX_OK){
close_path(handle,data.path);
throw "NXgetdata failed";
}
// close the path
close_path(handle,data.path);
}
示例9: fill_axis
static void fill_axis(NXhandle handle, Axis &axis, PathVector &tree,
const PrintConfig &config){
axis.name=(axis.path.rbegin())->name;
axis.type=-1;
axis.dims[0]=-1;
Path units_path;
Path primary_path;
Path axis_path;
PathVector attr_paths;
// sort out everything
for( PathVector::const_iterator path=tree.begin() ; path!=tree.end() ;
path++ ){
Node end_node=*((*path).rbegin());
if(end_node.type==ATTR){
if(end_node.name=="units"){
units_path=*path;
}else if(end_node.name=="primary"){
primary_path=*path;
}else if(end_node.name=="axis"){
axis_path=*path;
}else{
attr_paths.push_back(*path);
}
}
}
// get the attributes and fill the structure
if(units_path.size()>0)
axis.units=read_attr_as_string(handle,units_path,config);
if(axis_path.size()>0)
axis.axis=read_int_attr(handle,axis_path);
if(primary_path.size()>0)
axis.primary=read_int_attr(handle,primary_path);
else
axis.primary=-1;
// get the unknown attributes
for( PathVector::const_iterator path=attr_paths.begin() ; path!=attr_paths.end() ; path++ ){
string value=read_attr_as_string(handle,*path,config);
string key=(*path).rbegin()->name;
axis.unknown[key]=value;
}
// -- from here down gets the data
open_path(handle,axis.path);
// get the rank, dimensions and type
int rank;
if(NXgetinfo(handle,&rank,axis.dims,&axis.type)!=NX_OK){
close_path(handle,axis.path);
throw "NXgetinfo failed";
}
if(rank>1){
close_path(handle,axis.path);
throw "RANK>1";
}
// allocate space for the data
if(NXmalloc(&axis.data,rank,axis.dims,axis.type)!=NX_OK){
close_path(handle,axis.path);
throw "NXmalloc failed";
}
// retrieve the data from the file
if(NXgetdata(handle,axis.data)!=NX_OK){
close_path(handle,axis.path);
throw "NXgetdata failed";
}
// close the path
close_path(handle,axis.path);
}