Sponsored Content
Top Forums Programming Search attributes in one structure using the values from another structure Post 302179120 by ramen_noodle on Thursday 27th of March 2008 03:37:05 AM
Old 03-27-2008
The idea of a chained hash table is simple.
Given a key (character array) compute in a 'table' the location to which
the character string hashes using a hash value derived from the key.
Code:
void placenode(void **arr, void *node, char *key, int arrsz) {
int p = 0;
struct typewhatever *datum;

                   while (*key != '\0') {p += (31 + *key); key++;}
                   datum = arr[p % arrsz];
                   append_node(datum,node); 
}

From this one can search the array and 'bucket' for matches based on a restricted
subset of identically hashed values.

HTH.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

if then else structure

echo name the file that you want to read read answer if then echo you must enter a file name fi cat $answer im trying to catch the error if user forget to enter the name of the file anyone can help me ? thanks:confused: (4 Replies)
Discussion started by: props
4 Replies

2. UNIX for Dummies Questions & Answers

Copying a Directory Structure to a new structure

Hi all Is it possible to copy a structure of a directory only. e.g. I have a file with the following entries that is a result of a find :- /dir1/dir2/file.dbf /dir1/dir2/dir3/file1.dbf /dir1/file.dbf I want to copy these to a directory and keep the structure however starting at a new dir... (8 Replies)
Discussion started by: jhansrod
8 Replies

3. UNIX for Advanced & Expert Users

MV files from one directory structure(multiple level) to other directory structure

Hi, I am trying to write a script that will move all the files from source directory structure(multiple levels might exist) to destination directory structure. If a sub folder is source doesnot exist in destination then I have to skip and goto next level. I also need to delete the files in... (4 Replies)
Discussion started by: srmadab
4 Replies

4. UNIX for Dummies Questions & Answers

Size of Structure

How can we find size of a structure with out using sizeof operator? Thanks, Harika (2 Replies)
Discussion started by: harikamamidala
2 Replies

5. UNIX for Dummies Questions & Answers

Directory Structure

Hi... I have a directory which has multiple directories and sub directories inside... what command should i use to get a list of all these directories, without the filenames.... (2 Replies)
Discussion started by: saharookiedba
2 Replies

6. Shell Programming and Scripting

Perl Data Structure - Non unique values

I have the perl data structure and what i need to do is find all values in @{$extractColumns{'2'}{'D'}} which are not there in @{$extractColumns{'2'}{'M'}} but seems like i need to put a flag somewhere and i messed up foreach my $order (keys %extractColumns) { foreach my $value... (2 Replies)
Discussion started by: dinjo_jo
2 Replies

7. Shell Programming and Scripting

Script to search specific folders dates /mm/dd/ structure

Hi, I have a script that handles a huge amount of log files from many machines and copies it into a SAN location with the following directory structure: /SAN/machinenames/yyyy/m/d so for example /SAN/hosta/2011/3/12/files* Now I am writing a bash script to search for files between to date... (4 Replies)
Discussion started by: GermanJulian
4 Replies

8. Shell Programming and Scripting

Wget structure

Im reading a lot about wget and have really enjoyed using it. However I see a lot of tutorials that will show several ways. I want to be able to write scripts in gedit so I was wondering what is the best process to do this instead of just running them in the terminal?? (3 Replies)
Discussion started by: graphicsman
3 Replies

9. Shell Programming and Scripting

Running a program multiple times to search pattern and assign structure

Hi all, I have a big file (n.txt) with following pattern: ATOM 1 N SER A 1 122.392 152.261 138.190 1.00 0.00 N ATOM 2 CA SER A 1 122.726 151.241 139.183 1.00 0.00 C TER ENDMDL ATOM 1 N SER A 1 114.207 142.287 135.439 1.00 0.00 ... (3 Replies)
Discussion started by: bioinfo
3 Replies

10. Programming

Sctp api name to retrieve the values of structure sctpassoctable

Hi i want a sctp (lksctp) api which can retrieve the values of the sctp structure "sctpAssocTable" It is sctpassoctable or sctpassocentry. SctpAssocEntry ::= SEQUENCE { sctpAssocId Unsigned32, sctpAssocRemHostName OCTET STRING, sctpAssocLocalPort ... (1 Reply)
Discussion started by: harioum
1 Replies
tsearch(3)						     Library Functions Manual							tsearch(3)

Name
       tsearch, tfind, tdelete, twalk - manage binary search trees

Syntax
       #include <search.h>

       void *tsearch (key, rootp, compar)
       void *key;
       void **rootp;
       int (*compar)( );

       void *tfind (key, rootp, compar)
       void *key;
       void **rootp;
       int (*compar)( );

       void *tdelete (key, rootp, compar)
       void *key;
       void **rootp;
       int (*compar)( );

       void twalk (root, action)
       void * root;
       void (*action)( );

Description
       The  subroutine	is  a  binary tree search routine generalized from Knuth (6.2.2) Algorithm T.  It returns a pointer into a tree indicating
       where a datum may be found.  If the datum does not occur, it is added at an appropriate point in the tree.  The key points to the datum	to
       be  sought in the tree.	The rootp points to a variable that points to the root of the tree.  A NULL pointer value for the variable denotes
       an empty tree; in this case, the variable will be set to point to the datum at the root of the new tree.  The compar is	the  name  of  the
       comparison  function.  It is called with two arguments that point to the elements being compared.  The function must return an integer less
       than, equal to, or greater than zero according as the first argument is to be considered less than, equal to, or greater than the second.

       Like will search for a datum in the tree, returning a pointer to it if found.  However, if it is not found, will  return  a  NULL  pointer.
       The arguments for are the same as for

       The  subroutine deletes a node from a binary search tree.  It is generalized from Knuth (6.2.2) algorithm D.  The arguments are the same as
       for The variable pointed to by rootp will be changed if the deleted node was the root of the tree.  The subroutine returns a pointer to the
       parent of the deleted node, or a NULL pointer if the node is not found.

       The  subroutine	traverses a binary search tree.  The root is the root of the tree to be traversed.  (Any node in a tree may be used as the
       root for a walk below that node.)  The action is the name of a routine to be invoked at each node.  This routine is, in turn,  called  with
       three  arguments.   The	first  argument is the address of the node being visited.  The second argument is a value from an enumeration data
       type typedef enum { preorder, postorder, endorder, leaf } VISIT; (defined in the <search.h> header file), depending on whether this is  the
       first, second or third time that the node has been visited (during a depth-first, left-to-right traversal of the tree), or whether the node
       is a leaf.  The third argument is the level of the node in the tree, with the root being level zero.  The pointers to the key and the  root
       of the tree should be of type pointer-to-element, and cast to type pointer-to-character.

       The  comparison	function  need	not compare every byte, so arbitrary data may be contained in the elements in addition to the values being
       compared.

       Although declared as type pointer-to-character, the value returned should be cast into type pointer-to-element.

       Note that the root argument to is one level of indirection less than the rootp arguments to and

Return Values
       A NULL pointer is returned by if there is not enough space available to create a new node.
       A NULL pointer is returned by and if rootp is NULL on entry.
       If the datum is found, both and return a pointer to it.	If not, returns NULL, and returns a pointer to the inserted item.

Restrictions
       Results are unpredictable if the calling function alters the pointer to the root.

Diagnostics
       A NULL pointer is returned by and if rootp is NULL on entry.

See Also
       bsearch(3), hsearch(3), lsearch(3)

																	tsearch(3)
All times are GMT -4. The time now is 11:34 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy