本文整理汇总了C++中LList::iter方法的典型用法代码示例。如果您正苦于以下问题:C++ LList::iter方法的具体用法?C++ LList::iter怎么用?C++ LList::iter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LList
的用法示例。
在下文中一共展示了LList::iter方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: deleteCity
void deleteCity(LList<int>& cities, int id){
cities.iterStart();
elem_link1<int>* p = cities.iter();
while ((p != NULL) && p->inf != id) p = p->link;
int temp;
cities.deleteElem(p, temp);
}
示例2: recreate
//1a преобразуват текущото представяне на графа до списък от наследници;
void recreate(LList<rib> ribs) // Трябва да се добавят върховете от towns!
{
graph<int> g;
ribs.iterStart();
elem_link1<rib>* p = ribs.iter();
while (p)
{
if (!g.top(p->inf.start)) g.addTop(p->inf.start);
if (!g.top(p->inf.end)) g.addTop(p->inf.end);
if (!g.rib(p->inf.start, p->inf.end)) g.addRib(p->inf.start, p->inf.end);
if (!g.rib(p->inf.end, p->inf.start)) g.addRib(p->inf.end, p->inf.start);
p = ribs.iter();
}
// return g
}
示例3: map
//a
void map(LList<town>& l, LList<connections>& c){
graph<town> g;
l.iterStart();
elem_link1<town>*p = l.iter();
while (p->link){
g.addTop(p->inf);
}
c.iterStart();
elem_link1<connections>*q = c.iter();
while (q->link){
g.addRib(town(q->inf.id1),town( q->inf.id2));
g.addRib(town(q->inf.id2),town( q->inf.id1));
}
}
示例4: getSites
int getSites(int id, LList<City>& cities){
cities.iterStart();
elem_link1<City>* p = cities.iter();
while (p){
if (p->inf.id == id) return p->inf.numSites;
p = p->link;
}
return 0;
}
示例5: member
bool member(LList<town>&L, town t){
L.iterStart();
elem_link1<town> * p = L.iter();
while (p->link){
if (p->inf.name = t.name)
return true;
p = p->link;
}
return false;
}
示例6: findCount
//1v да се намерят първите k града записани в списъка, намерен в б), с най-много забележителности
//около тях, подредени по брой на забележителностите.
//namira br zabelejitelnosti po dadeno ID
int findCount(LList<town> zabelejitelnosti, int ID)
{
zabelejitelnosti.iterStart();
elem_link1<town> * p = zabelejitelnosti.iter();
while (p)
{
if (p->inf.id == ID) return p->inf.count;
p = p->link;
}
return 0;
}
示例7: member
bool member(int x, LList <int> l)
{
l.iterStart();
elem_link1<int> * p = l.iter();
while (p)
{
if (x == p->inf) return true;
p = p->link;
}
return false;
}
示例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;
}
示例9: getMaxCity
int getMaxCity(LList<int>& cities, LList<City>& all){
cities.iterStart();
elem_link1<int>* p = cities.iter();
int max = p->inf;
p = p->link;
while (p){
if (getSites(p->inf, all) > getSites(max, all)){
max = p->inf;
}
p = p->link;
}
return max;
}
示例10: 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;
}
}
}