本文整理汇总了C++中LList::IterStart方法的典型用法代码示例。如果您正苦于以下问题:C++ LList::IterStart方法的具体用法?C++ LList::IterStart怎么用?C++ LList::IterStart使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LList
的用法示例。
在下文中一共展示了LList::IterStart方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: findFriendsOfFriends
/*
2. За избран човек, да се изведат приятели на неговите приятели, които имат поне 2 общи интереса с него. Хората да се изведат по брой общи интереси в низходящ ред.
*/
LList<Person> findFriendsOfFriends(graph<Person> g, Person person) {
LList<Person> result;
LList<Person> friends = neighbours<Person>(g, person);
elem<Person> * pFriend;
friends.IterStart();
while ((pFriend = friends.Iter())) {
LList<Person> friendsFriends = neighbours(g, pFriend->inf);
elem<Person> * pf;
friendsFriends.IterStart();
while ((pf = friendsFriends.Iter())) {
if (pf->inf == person) {
continue;
}
if (contains(friends, pf->inf)) {
continue;
}
result.ToEnd(pf->inf);
}
}
return result;
}
示例2: toGraph
// Подточка a)
graph<int> toGraph(LList<Connections> conn, LList<City> cities)
{
LList<int> uniqueCities = citiesToInt(cities);
graph<int> g;
addTops(g, uniqueCities);
uniqueCities.IterStart();
elem<int>* e = uniqueCities.Iter();
while (e)
{
elem<Connections>* p;
conn.IterStart();
p = conn.Iter();
while (p)
{
Connections a = p->inf;
if (e->inf == a.StartCity)
{
g.addRib(e->inf, a.EndCity);
// + g.addRib(a.EndCity, e->inf);
}
p = p->link;
}
e = e->link;
}
return g;
}
示例3: firstKTowns
//Подточка в)
LList<int> firstKTowns(LList<City> cities, LList<int> filteredCitiesByDistance, int k)
{
int currentCities = 0; // not used ???
int MaxNumberOfFamousPlaces = 0; // not used ???
int CurrNumbOfFamousPlaces = 0; // not used ???
int* arr = new arr[filteredCitiesByDistance.len()]; // ???
int i = 0;
cities.IterStart();
LList<int> temp;
elem<City>* e = cities.Iter();
City a;
while (e)
{
filteredCitiesByDistance.IterStart();
elem<int>* p = filteredCitiesByDistance.Iter();
while (p)
{
a = e->inf;
if (a.ID == p->inf)
{
arr[i] = a.FamousPlaces;
i++;
}
p = p->link;
}
e = e->link;
}
for (size_t j = 0; j < filteredCitiesByDistance.len(); j++)
{
for (size_t p = 0; p < filteredCitiesByDistance.len() - 1; p++)
{
if (arr[j] < arr[p + 1]) swap(arr[j], arr[p + 1]);
}
}
for (size_t q = 0; q < k; q++)
{
cities.iterStart();
elem<City>* p = cities.Iter();
while (p)
{
City b = p->inf;
if (arr[q] == b.FamousPlaces)
{
temp.ToEnd(b.ID);
}
}
}
delete[]arr;
return temp;
}
示例4: contains
bool contains(LList<T> list, T& e) {
list.IterStart();
elem<T> * p;
while ((p = list.Iter())) {
if (p->inf == e) {
return true;
}
}
return false;
}
示例5: problem_1
void problem_1(graph<Person> g, Person person) {
LList<Person> n = neighbours<Person>(g, person);
n.IterStart();
elem<Person> * aFriend;
while ((aFriend = n.Iter())) {
if ((aFriend->inf).age == person.age) {
cout << (aFriend->inf) << endl;
}
}
}
示例6: contains
//Подточка б)
bool contains(LList<int> l,LList<int> c)
{
if (l.empty()) return false;
l.IterStart();
elem<int>* e = l.Iter();
while (e)
{
c.IterStart();
elem<int>* p = c.Iter();
while (p)
{
if (e->inf == p->inf) return true;
p = p->link;
}
e = e->link;
}
return false;
}
示例7: addTops
void addTops(graph<int>& g, LList<int> l)
{
if (l.empty()) return;
l.IterStart();
elem<int>* e = l.Iter();
while (e)
{
g.addTop(e->inf);
e = e->link;
}
}
示例8: filterByCommonInterests
LList<Person> filterByCommonInterests(LList<Person>& people, Person person, int minCommonInterests) {
LList<Person> result;
people.IterStart();
elem<Person> * pff;
while ((pff = people.Iter())) {
if (numberOfCommonInterests(person, pff->inf) >= minCommonInterests) {
result.ToEnd(pff->inf);
}
}
return result;
}
示例9: citiesToInt
LList<int> citiesToInt(LList<City> c)
{
if (c.empty()) return LList<int>();
LList<int> temp;
elem<City>* e;
c.IterStart();
e = c.Iter();
while (e)
{
City a = e->inf;
temp.ToEnd(a.ID);
e = e->link;
}
return temp;
}