| | |
C++ list.
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Mar 2008
Posts: 56
Reputation:
Solved Threads: 1
Hi all,
I am playing around with list and I figure out how to merge two lists and all. But I have no idea how can I integrate one list onto another. For example A = {1,2,3,4,10,11} and B = { 5,6,7} Then my integrated list should be
{1,5,2,6,3,7,4,10}. I would have figured out of two lists are of the same length but they aren't. Two lists can be varied in terms of size.
I am writing a free function so here is my approach :
Thank you for any help.
I am playing around with list and I figure out how to merge two lists and all. But I have no idea how can I integrate one list onto another. For example A = {1,2,3,4,10,11} and B = { 5,6,7} Then my integrated list should be
{1,5,2,6,3,7,4,10}. I would have figured out of two lists are of the same length but they aren't. Two lists can be varied in terms of size.
I am writing a free function so here is my approach :
C++ Syntax (Toggle Plain Text)
#include <iostream> #include <list> using namespace std; template <class T> T integrateList(const& list<T> i, const& list<T> m) { list<T>::const_iterator iter; what exactly do I need to do here?I know how I Can merge the two list? But how can I integrate or collate them? }
C++ Syntax (Toggle Plain Text)
int main() { list<int> listA; list<int> listB; list<int> newList; listA.push_back(1); listA.push_back(2); listA.push_back(3); listA.push_back(4); listA.push_back(10); listA.push_back(11) listB.push_back(5); listB.push_back(6); listB.push_back(7); newList = integrateList(listA, listB); cout<<newList <<endl; return 0; }
Thank you for any help.
0
#4 Oct 26th, 2009
Something like this : ?
1) Create a result list
2) Merge list A and list B
3) copy result list to list A, while making sure that list A has enough add at each insertion.
1) Create a result list
2) Merge list A and list B
3) copy result list to list A, while making sure that list A has enough add at each insertion.
I give up! 1) What word becomes shorter if you add a letter to it? [ Solved by : niek_e ] 2) What does this sequence equal to : (.5u - .5a)(.5u-.5b)(.5u-.5c) ... 3) What is the 123456789 prime numer? Ask4Answer
•
•
Join Date: Mar 2008
Posts: 56
Reputation:
Solved Threads: 1
0
#5 Oct 26th, 2009
•
•
•
•
Something like this : ?
1) Create a result list
2) Merge list A and list BC++ Syntax (Toggle Plain Text)
T inteGrateList(const list<T> i, const list<T> m) { list<T>::const_iterator p; list<T> resultingList; i.merge(m) // merge list m in i; now m is empty }
3) copy result list to list A, while making sure that list A has enough add at each insertion.
0
#7 Oct 26th, 2009
>>But I have no idea how can I integrate one list onto another.
What requirements comes to mind when you think this?
What requirements comes to mind when you think this?
I give up! 1) What word becomes shorter if you add a letter to it? [ Solved by : niek_e ] 2) What does this sequence equal to : (.5u - .5a)(.5u-.5b)(.5u-.5c) ... 3) What is the 123456789 prime numer? Ask4Answer
![]() |
Similar Threads
- Problem with extracting file names from the file names returned by FTP LIST command (C#)
- Update element in list (C++)
- Help with adding to an empty list (Python)
- Simple Linked List with user input (C)
- How to recursively find a value in a linked list (Java)
- A List Script? (PHP)
- Help with list 'subtraction' (Python)
Other Threads in the C++ Forum
- Previous Thread: Extra Paramaters
- Next Thread: I don't know how to make this float function work correctly.
| Thread Tools | Search this Thread |
api array arrays based beginner binary bitmap c++ c/c++ calculator char class classes code compile compiler console conversion count delete deploy desktop directshow dll download dynamic dynamiccharacterarray encryption error file forms fstream function functions game getline givemetehcodez google graph gui homeworkhelp homeworkhelper iamthwee ifstream input int integer java lib linkedlist linker linux list loop looping loops map math matrix memory news node output parameter pointer problem program programming project proxy python read recursion recursive reference return rpg string strings struct temperature template templates test text text-file tree unix url variable vector video visual visualstudio win32 windows winsock word wordfrequency wxwidgets






