// //ORIGINAL LINE: List<std::pair<uint, uint> > getNoIntersectionParts(uint pathIndex) const /// <summary> /// 获取非交集 /// </summary> /// <param name="pathIndex"></param> /// <returns></returns> public std_vector <std_pair <uint, uint> > getNoIntersectionParts(uint pathIndex) { Path path = mPaths[(int)pathIndex]; std_vector <std_pair <uint, uint> > result = new std_vector <std_pair <uint, uint> >(); std_vector <int> intersections = new std_vector <int>(); //for (std.map<PathCoordinate, List<PathCoordinate>>.Enumerator it = mIntersectionsMap.begin(); it != mIntersectionsMap.end(); ++it) { foreach (var it in mIntersectionsMap) { if (it.Key.pathIndex == pathIndex) { intersections.push_back((int)it.Key.pointIndex); } } //std.sort(intersections.GetEnumerator(), intersections.end()); intersections.Sort((x, y) => { return(x - y);//正序排序(重写int比较器,|x|>|y|返回正数,|x|=|y|返回0,|x|<|y|返回负数) }); //Array.Sort(intersections.ToArray()); int begin = 0; //for (std::vector<int>::iterator it = intersections.begin(); it!= intersections.end(); ++it) //{ // if (*it-1>begin) // result.push_back(std::pair<unsigned int, unsigned int>(begin, *it-1)); // begin = *it+1; //} //if (path.getSegCount() > begin) // result.push_back(std::pair<unsigned int, unsigned int>(begin, path.getSegCount())); //for (List<int>.Enumerator it = intersections.GetEnumerator(); it.MoveNext(); ++it) foreach (var it in intersections) { if (it - 1 > begin) { result.push_back(new std_pair <uint, uint>((uint)begin, (uint)it - 1)); } begin = it + 1; } if (path.getSegCount() > begin) { result.push_back(new std_pair <uint, uint>((uint)begin, (uint)path.getSegCount())); } return(result); }
// //ORIGINAL LINE: List<std::pair<uint, uint> > getNoIntersectionParts(uint pathIndex) const /// <summary> /// 获取非交集 /// </summary> /// <param name="pathIndex"></param> /// <returns></returns> public std_vector<std_pair<uint, uint>> getNoIntersectionParts(uint pathIndex) { Path path = mPaths[(int)pathIndex]; std_vector<std_pair<uint, uint>> result = new std_vector<std_pair<uint, uint>>(); std_vector<int> intersections = new std_vector<int>(); //for (std.map<PathCoordinate, List<PathCoordinate>>.Enumerator it = mIntersectionsMap.begin(); it != mIntersectionsMap.end(); ++it) { foreach (var it in mIntersectionsMap) { if (it.Key.pathIndex == pathIndex) { intersections.push_back((int)it.Key.pointIndex); } } //std.sort(intersections.GetEnumerator(), intersections.end()); intersections.Sort((x, y) => { return x - y;//正序排序(重写int比较器,|x|>|y|返回正数,|x|=|y|返回0,|x|<|y|返回负数) }); //Array.Sort(intersections.ToArray()); int begin = 0; //for (std::vector<int>::iterator it = intersections.begin(); it!= intersections.end(); ++it) //{ // if (*it-1>begin) // result.push_back(std::pair<unsigned int, unsigned int>(begin, *it-1)); // begin = *it+1; //} //if (path.getSegCount() > begin) // result.push_back(std::pair<unsigned int, unsigned int>(begin, path.getSegCount())); //for (List<int>.Enumerator it = intersections.GetEnumerator(); it.MoveNext(); ++it) foreach (var it in intersections) { if (it - 1 > begin) result.push_back(new std_pair<uint, uint>((uint)begin, (uint)it - 1)); begin = it + 1; } if (path.getSegCount() > begin) result.push_back(new std_pair<uint, uint>((uint)begin, (uint)path.getSegCount())); return result; }