本文整理汇总了C++中LList::toEnd方法的典型用法代码示例。如果您正苦于以下问题:C++ LList::toEnd方法的具体用法?C++ LList::toEnd怎么用?C++ LList::toEnd使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LList
的用法示例。
在下文中一共展示了LList::toEnd方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: path
void path(town start, graph<town>& g, int p, LList<town> &visited){
if (g.empty())return;
int count = 0;
queue<town> q;
q.push(start);
visited.toEnd(start);
elem_link1<town> * f = g.point(start);
f = f->link;
while (!q.empty()){
town t;
q.pop(t);
while (f){
if (p == count)return;
else if (!member(visited, f->inf)){
q.push(f->inf);
visited.toEnd(f->inf);
count++;
}
f = f->link;
}
}
}
示例2: findCities
void findCities(graph<int>& g, LList<int>& cities, int cityId, int p){
elem_link1<int>* start = g.point(cityId);
int dist[100]; // 100???
bool visited[100]; // 100??? - nikoi ne garantira, che id-tata na cities shte sa posledovatelni chisla pod 100
memset(dist, -1, 100);
memset(visited, 0, 100);
if (start){
visited[start->inf] = true;
dist[start->inf] = 0;
queue<int> q;
q.push(start->inf);
while (!q.empty()){
int current = q.front();
q.pop();
elem_link1<int>* p = g.point(current);
p = p->link;
while (p){
if (!visited[p->inf]){
visited[p->inf] = true;
dist[p->inf] = dist[current] + 1;
q.push(p->inf);
}
p = p->link;
}
}
for (int i = 0; i < 100; i++){
if (dist[i] >= 0 && dist[i] <= p){
cities.toEnd(i);
}
}
}
}
示例3:
void graph<T>::addTop(const T& a)
{ // създаване на линеен списък, съдържащ елемента a
LList<T> l;
l.toEnd(a);
// включване на върха a към графа
g.toEnd(l);
}
示例4: townLessThan
LList<int> townLessThan(int start, graph<int> towns, LList<int> &visited, int p)
{
LList<int> vert = towns.vertexes();
int n = vert.length();
//masiv, v koito shte pazim razstoianiata ot s da vs dr grad
int dist[100]; // Защо 100?
//inicializirame s -1 (ako niama put si ostava)
for (int i = 0; i < n; i++)
{
dist[i] = -1;
}
//BFS
queue<int> q;
visited.toEnd(start);
dist[start] = 0;
q.push(start);
while (!q.empty())
{
int x;
q.pop(x);
elem_link1<int> * p = towns.point(x);
p = p->link;
while (p)
{
if (!member(p->inf, visited))
{
visited.toEnd(p->inf);
q.push(p->inf);
dist[x] += 1; // vsichki stoinosti shte badat 0!
}
p = p->link;
}
}
//v masiva dist imame razstoianiata ot start do vs gradove
LList<int> result;
for (int i = 0; i < n; i++)
{
if (dist[i] <= p && dist[i] != -1)
result.toEnd(i);
}
return result;
}
示例5: orderCities
void orderCities(LList<int>& ord, graph<int>& g, LList<City>& all, int cityId, int p){ // OK
LList<int> cities;
findCities(g, cities, cityId, p);
LList<int> ordered;
while (!cities.empty()){
int max = getMaxCity(cities, all);
deleteCity(cities, max);
ordered.toEnd(max);
}
ord = ordered;
}
示例6: iter
void LList<T>::reverse()
{
LList<T> r;
iterStart();
elem_link1<T>* p = iter();
if (p)
{
r.toEnd(p->inf);
p = p->link;
while (p)
{
r.insertBefore(r.start, p->inf);
p = p->link;
}
}
*this = r;
}
示例7: firstk
//v
void firstk(LList<town> &visited, LList<town>& firstk, int k){
visited.iterStart();
elem_link1<town> * p = visited.iter();
int count = 0;
while (p){
town max(0, 0);
max.sites = p->inf.sites;
while (count != k){
elem_link1<town>*q = p->link;
while (q){
if (max.sites < q->inf.sites)
max.sites = q->inf.sites;
q = q->link;
}
count++;
firstk.toEnd(p->inf);
p = p->link;
}
}
}
示例8: zad
LList<int> zad(int k, LList<int> towns, LList<town> zabelejitelnosti)
{
LList<int> result;
towns.iterStart();
elem_link1<int> * p = towns.iter();
elem_link1<int> * mp; //pointer to max
while (p)
{
int max = p->inf;
mp = p;
elem_link1<int> * q = p->link;
while (q)
{
//namirame broi zabelejitelnosti na stoinostta na p
int pzab = findCount(zabelejitelnosti, p->inf);
//namirame broi zabelejitelnost na stoinostta na q
int qzab = findCount(zabelejitelnosti, q->inf);
if (pzab < qzab)
{
max = q->inf;
mp = q;
}
q = q->link;
}
mp->inf = p->inf;
p->inf = max;
p = p->link;
}
//v towns imame sortirani gradovete po broi zabelejitelnosti
towns.iterStart();
elem_link1<int> * m = towns.iter();
for (int i = 0; i < k; i++)
{
if (!m) break;
result.toEnd(m->inf);
m = m->link;
}
return result;
}