![]() |
|
|
|||||||
| Home | Forums | Register | Rules & FAQ | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here. |
Other UNIX.COM Threads You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Traversing Pascal/Delphi code using GVim | SankarV | UNIX for Dummies Questions & Answers | 0 | 02-22-2008 01:24 AM |
| Traversing thru dirs and deleting files based on date | ravi2082 | Shell Programming and Scripting | 5 | 07-18-2007 01:28 PM |
| Traversing a file system | hooj | UNIX for Dummies Questions & Answers | 1 | 02-09-2006 11:47 AM |
| vector<string> with insert cmd | photon | High Level Programming | 1 | 09-10-2004 02:51 PM |
| Saving a vector to a file | J.P | High Level Programming | 1 | 04-27-2002 11:28 PM |
![]() |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
|||
|
Vector Traversing
Hi
i have the following structure struct S { char Mod_num[5]; char val[31]; char chr_nm_cd[11]; } I am reading a 2GB file and inserting into the structure and writing into a vector. I feel like only vector will be a right option. I tried with multimap but it is memory intensive and hence i dropped multimap. I have the scenario 1st record 7285 GROZ788Y SIZE 00513 2nd record 7286 GROZ720Y SIZEA00678 3rd record 7455 GROZ788Y SIZE 00565 4th record 7286 GROZ788Y SIZE 00513 You can observe that 1st and 4th records are the same except for the MOd_num field where the values are 7285 and 7286, they are differing so i will have the output as SIZE 00513 GROZ788Y 2 7286 7285 SIZEA00678 GROZ720Y 1 7286 SIZE 00565 GROZ788Y 1 7455 Can you give me a sample program or some directions to solve this. |
| Forum Sponsor | ||
|
|
|
|||
|
Are you trying to eliminate duplicates, sort or what?
Using search.h and maybe lsearch() or hsearch() will do what you need. If the data is redundant, hsearch() is not the best choice. I personally deal with stuff like this by creating an array of pointers, then sorting the array using qsort, which allows one to access an element with bsearch() using a key. Sorting an array of structs is too expensive. But it is not clear what you need. |
|||
| Google UNIX.COM |