hsearch_r for multiple with same key


 
Thread Tools Search this Thread
Top Forums Programming hsearch_r for multiple with same key
# 1  
Old 11-03-2011
hsearch_r for multiple with same key

Folks,

I have a problem with using the hashtable. my hash table will have to store 2 entries with different data values and same key.

key data
-----------
steps 34
steps 1024

Code:
hsearch_r(entry, FIND, &found, &hashtable);

the problem is whenever I do search(hsearch_r) for key "steps" it returns 34 only. Please tell me how to retrieve the date value for the second entry i.e, 1024

Thanks,
Tamil
# 2  
Old 11-03-2011
Hash tables store one value per key. When you put in a second value with the same key, it overwrites the first.

You could store linked lists instead of individual numbers inside your hash table. You'd try to find the existing key and, if found, append to the list; otherwise, add a new list...
# 3  
Old 11-03-2011
Thanks Corona688,

In my case, It does not overwrite the entry. Either it is ignored or stored as new one with the same key.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Join and merge multiple files with duplicate key and fill void columns

Join and merge multiple files with duplicate key and fill void columns Hi guys, I have many files that I want to merge: file1.csv: 1|abc 1|def 2|ghi 2|jkl 3|mno 3|pqr file2.csv: (5 Replies)
Discussion started by: yjacknewton
5 Replies

2. Solaris

DH key size must be multiple of 64, and can only range from 512 to 2048 (inclusive).

Hello, I have a set-up in which I am executing a build from Jenkins on a Solaris 10 Server connecting via sshexec task in ANT. On triggering the build, it is throwing below error: com.jcraft.jsch.JSchException: Session.connect: java.security.InvalidAlgorithmParameterException: DH key size... (2 Replies)
Discussion started by: nishant.kansal@
2 Replies

3. Shell Programming and Scripting

Removing duplicates in fixed width file which has multiple key columns

Hi All , I have a requirement where I need to remove duplicates from a fixed width file which has multiple key columns .Also , need to capture the duplicate records into another file . File has 8 columns. Key columns are col1 and col2. Col1 has the length of 8 col 2 has the length of 3. ... (5 Replies)
Discussion started by: saj
5 Replies

4. Shell Programming and Scripting

Merge multiple lines in same file with common key using awk

I've been a Unix admin for nearly 30 years and never learned AWK. I've seen several similar posts here, but haven't been able to adapt the answers to my situation. AWK is so damn cryptic! ;) I have a single file with ~900 lines (CSV list). Each line starts with an ID, but with different stuff... (6 Replies)
Discussion started by: protosd
6 Replies

5. Shell Programming and Scripting

grep - Extracting multiple key words from stdout

Hello. From command line, the command zypper info nxclient return a bloc of data : linux local # zypper info nxclient Loading repository data... Reading installed packages... Information for package nxclient: Repository: zypper_local Name: nxclient Version: 3.5.0-7 Arch: x86_64... (7 Replies)
Discussion started by: jcdole
7 Replies

6. Shell Programming and Scripting

Extracting Max date for multiple same key

Can any one help me to sort and extract the max date row from multiple same key ? example of input file kEY DATE(YYY-MM-DD) 10 2011-08-01 20 2011-09-02 20 2011-10-01 20 2011-08-02 30 2010-01-20 30 2011-01-20 Out put : 10 2011-08-01co 20 2011-10-01 30 2011-01-20 ... (5 Replies)
Discussion started by: jambesh
5 Replies

7. Shell Programming and Scripting

awk - splitting 1 large file into multiple based on same key records

Hello gurus, I am new to "awk" and trying to break a large file having 4 million records into several output files each having half million but at the same time I want to keep the similar key records in the same output file, not to exist accross the files. e.g. my data is like: Row_Num,... (6 Replies)
Discussion started by: kam66
6 Replies

8. Solaris

Multiple private key to be uploaded

I would like to ask if you have a procedure on how to upload multiple private key for multiple users in solaris? I was only able to add one but when I tried to add several key, it fails. example: a. user1: user1.ppk b. user2: user2.ppk Each with different password on the server. Pls advise (6 Replies)
Discussion started by: lhareigh890
6 Replies

9. OS X (Apple)

Multiple hosts SSH NO PASSWORD - each time it overrides the last key gen

Hello, here is my problem: I have 20 machines that need to SSH into 1 machine throughout the day. The issue is every time I go through the process of putting my keys from one of the computers that needs to SSH to the server that needs to accept all the incoming SSH's it overrides the last one. ... (6 Replies)
Discussion started by: yoyoyo777
6 Replies

10. Solaris

multiple displays of characters with one push of the key.

Hi, I have a Ultra5 440MHz system running Solaris 2.6 (Rev 5.6) and have a problem with the keyboard. When I push a key it prints characters very quickly. If I push a key very fast I get maybe 3 characters. So, I am thinking bad keyboard. I borrow a known good keyboard, samething and the... (3 Replies)
Discussion started by: mndavies
3 Replies
Login or Register to Ask a Question