本文整理汇总了C++中Contact::getFirstLast方法的典型用法代码示例。如果您正苦于以下问题:C++ Contact::getFirstLast方法的具体用法?C++ Contact::getFirstLast怎么用?C++ Contact::getFirstLast使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Contact
的用法示例。
在下文中一共展示了Contact::getFirstLast方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: viewContactList
/*viewContactList(ContactController &controller)
* *********************************************
* An unsorted view of the list being used by the controller
* This function isn't used in the current main program.
*/
void ContactViewer::viewContactList(ContactController &controller){
Contact *curr;
std::string temp;
std::cout<< "list length in viewer="<< controller.list->getLength()<< "\n";
for (int i=1; i<= controller.list->getLength(); i++){
curr = controller.list->retrieve(i);
temp = curr->getFirstLast();
std::cout << "list at pos:" << i << " is :" << temp << "\n";
}
std::cout << "End of Viewing List\n";
}
示例2: viewSortedContacts
/*
* viewSortedContacts(ContactController &controller):
* ****************************************************
* creates a vector of Contact* from the controller referenced by argument
* then implements a linear sort of the vector by first name and then by
* last name (to hopefully sort same last names by first name)
*/
void ContactViewer::viewSortedContacts(ContactController &controller){
Contact *curr;
std::string temp;
//std::cout<< "list length in viewer="<< controller.list->getLength()<< "\n";
std::vector<Contact*> sorted;//
for (int b = 1; b <= controller.list->getLength(); b++){
sorted.push_back(controller.list->retrieve(b));
}
//std::cout<< "sorted size = "<< sorted.size()<< "\n";
for(size_t i = 0; i < sorted.size(); i++){
for (size_t j=i+1; j < sorted.size(); j++){
if (sorted[i]->getFirst()> sorted[j]->getFirst()){
//std::cout<< "sorted " << i<< " = " << sorted[i]->getFirst()
// << "sorted " << j << " = " << sorted[j]->getFirst() << std::endl;
curr = sorted[i];
sorted[i]= sorted[j];
sorted[j]= curr;
}
}
}
for(size_t k = 0; k < sorted.size(); k++){
for (size_t m=k+1; m< sorted.size(); m++){
if (sorted[k]->getLast()> sorted[m]->getLast()){
//std::cout<< "sorted " << k<< " = " << sorted[k]->getLast()
// << "sorted " << m << " = " << sorted[m]->getLast() << std::endl;
curr = sorted[k];
sorted[k]= sorted[m];
sorted[m]= curr;
}
}
}
for (size_t j = 0; j < sorted.size(); j++){
curr = sorted[j];
temp = curr->getFirstLast();
std::cout << "Sorted List at pos:" << j << " is :" << temp << "\n";
}
std::cout<< "Number of Contacts in List ="<< controller.list->getLength()<< "\n";
}