本文整理汇总了C++中LList::ToEnd方法的典型用法代码示例。如果您正苦于以下问题:C++ LList::ToEnd方法的具体用法?C++ LList::ToEnd怎么用?C++ LList::ToEnd使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LList
的用法示例。
在下文中一共展示了LList::ToEnd方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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:
void graph<T>::addTop(const T& a)
{ // създаване на линеен списък, съдържащ елемента a
LList<T> l;
l.ToEnd(a);
// включване на върха a към графа
g.ToEnd(l);
}
示例3: main
int main() {
graph<Person> g;
LList<string> peshoLikes;
peshoLikes.ToEnd("rakia");
peshoLikes.ToEnd("salata");
peshoLikes.ToEnd("musaka");
peshoLikes.ToEnd("bob");
LList<string> pepaLikes;
pepaLikes.ToEnd("nutela");
pepaLikes.ToEnd("vino");
pepaLikes.ToEnd("musaka");
LList<string> draganLikes;
draganLikes.ToEnd("rakia");
draganLikes.ToEnd("nutela");
draganLikes.ToEnd("bob");
Person pesho("Pesho", 20, peshoLikes);
Person ivan("Ivan", 25, LList<string>());
Person petkan("Petkan", 22, LList<string>());
Person mimi("Mimi", 20, LList<string>());
Person mariika("Mariika", 22, LList<string>());
Person pepa("Pepa", 20, pepaLikes);
Person dragan("Dragan", 20, draganLikes);
g.addTop(pesho);
g.addTop(ivan);
g.addTop(petkan);
g.addTop(mimi);
g.addTop(mariika);
g.addTop(pepa);
g.addTop(dragan);
g.addRib(pesho, ivan);
g.addRib(pesho, petkan);
g.addRib(pesho, mimi); // result
g.addRib(pesho, mariika);
g.addRib(petkan, mimi);
g.addRib(petkan, mariika);
g.addRib(petkan, pepa);
g.addRib(mimi, dragan);
// neighbours(g, pesho).print();
// problem_1(g, pesho);
problem_2(g, pesho);
return 0;
}
示例4: notFurtherThan
void notFurtherThan(int& dist, int& start, graph<int>& g, LList<int>& visited, LList<int>& cities)
{
if (contains(visited, cities)) return; // ??? should be contains(visited, start)
if (dist < 0) return;
if (!g.top(start)) return;
visited.ToEnd(start);
cities.ToEnd(start);
elem<int>* q = g.point(start);
q = q->link;
while (q)
{
int distance = dist - 1;
notFurtherThan(distance, q->inf, g, visited, cities);
q = q->link;
}
}
示例5: 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;
}
示例6: neighbours
LList<T> neighbours(graph<T> g, T e) {
if (!g.top(e)) {
return LList<T>();
}
elem<T> * glist = g.point(e);
LList<T> neighbours;
while (glist->link != NULL) {
neighbours.ToEnd(glist->link->inf);
glist = glist->link;
}
return neighbours;
}
示例7: 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;
}
示例8: IterStart
void LList<T>::reverse()
{
LList<T> l;
IterStart();
elem_link1<T> *p = Iter();
if(p)
{
l.ToEnd(p->inf);
p = p->link;
while(p)
{
l.InsertBefore(l.Start, p->inf);
p = p->link;
}
}
*this = l;
}
示例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;
}
示例10: Find
LList<Node<string>*> Find(Node<string>* r, string query, bool isRecursive)
{
//Node<string>* r = tree.GetRootNode();
LList<string> result;
if(IsMatch(query, r->data))
{
result.ToEnd(r);
}
//result.Concat(Find(r->links, query));
if(IsRecursive)
{
Elem<Node<string>*>* iter;
r->links.IterStart();
while(iter = r->links.Iter())
{
result.Concat(Find(Iter->data, query, IsRecursive));
}
}
return result;
}