The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > High Level Programming
Google UNIX.COM
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

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 04-29-2008
Read Only
 

Join Date: Jun 2006
Posts: 105
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiReddit! Stumble this Post!Spurl this Post!
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.
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 04-30-2008
...@...
 

Join Date: Feb 2004
Location: NM
Posts: 3,240
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiReddit! Stumble this Post!Spurl this Post!
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.
Reply With Quote
Google UNIX.COM
Reply



Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -7. The time now is 07:53 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger

Search Engine Optimization by vBSEO 3.1.0

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102