Sponsored Content
Top Forums Programming How to evaluate which coding approach is best? Post 302380220 by Corona688 on Monday 14th of December 2009 02:37:28 PM
Old 12-14-2009
It's very hard to give a general answer without knowing what methods are being considered.

"Best for what" is often a good question... As an example, hash tables can be very fast to read best-case, but used badly they can be no better than a linear search. They're also space-inefficient, strewing information thinly by design... You wouldn't want to use them to store huge amounts of data. Trees are slower to read than a hash table's best, but a balanced tree's worst case time is smaller than a poorly hashed table -- but adding to or changing a tree can be complicated and slow since it may need balancing. Not all data is really suitable for either anyway...

So, more information's needed.
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

how to get variable to re-evaluate itself?

Probably a simple one. Basically I am retrieving a number from a file - setting a variable against it and then incrementing this by 1 and using this as an entry number in a log file for messages. I need the variable to re-evalute itself each time I call it so I get the latest number in the file -... (1 Reply)
Discussion started by: frustrated1
1 Replies

2. Shell Programming and Scripting

How to evaluate the value read from a file?

Hi, Could someone please help me with how to do the following? Say I have a flat file test.lst and the content of the file is: Report Date - `date '+%m%d%Y'` I'm trying the following while read myLine do echo ${myLine} done<test.lst This prints Report Date - `date... (1 Reply)
Discussion started by: arunsoman80
1 Replies

3. Shell Programming and Scripting

Evaluate the value of a variable?

I have variables: FOO="Text" BAR="FOO" I'd like to be able to evaluate the variable named as the value of $BAR. echo $FOO Text echo $BAR FOO This is what I'd like to do: echo ${$BAR} (this won't work) Text (3 Replies)
Discussion started by: Ilja
3 Replies

4. Shell Programming and Scripting

cron does not evaluate the quotes

Hi all, I have a script that runs perfectly from cmd, but in the cron it gives a strange ':::::::::::::::' output instead of evaluating the part inside the quotes. this is the script: bash-3.00# more test #!/bin/ksh #-----swap--- TEMP_FILE=/HealthCheck/test/file.txt swap -s | tee... (1 Reply)
Discussion started by: kerrygold
1 Replies

5. Shell Programming and Scripting

How to evaluate the value of a variable ?

How to evaluate the value of a variable ? For example: a=var $a=value !!!error happens!!! I want to evaluate var=value, how to realize it? Thanks! ---------- Post updated at 03:37 AM ---------- Previous update was at 02:22 AM ---------- I am using linux bash. a=var $a=value... (4 Replies)
Discussion started by: 915086731
4 Replies

6. UNIX for Dummies Questions & Answers

How does ||: evaluate?

In BASH, how does ||: get interpreted. I know || is logical or. And I believe : evaluates to true. Can someone give a thorough explanation for this usage? Example for i in $IGGY do && skipdb=1 || : (6 Replies)
Discussion started by: glev2005
6 Replies

7. Red Hat

What would be the best approach?

I have a table in one of my DB. The DB is about 300 gig - of that 249 gig is in this table. The data is somewhat important but even if we delete half of it won't affect anybody. I would like to reclaim some space back so my question is what would be the best approach to accomplish this task.... (6 Replies)
Discussion started by: newborndba
6 Replies

8. Shell Programming and Scripting

Evaluate Expression within awk

I want to create a conditional expression string and pass in an awk script. My script is as below... comm="\$3 == "hello"" awk -F "^T" -v command="${comm}" ' { if ( command ) { print "hye" } }' testBut the statement "if ( command )" always evaluates to true which is not... (5 Replies)
Discussion started by: Saikat123
5 Replies

9. UNIX for Beginners Questions & Answers

What is the right approach to take?

Hello every one, I will love to know what is the best approach to take in obtaining books online. I find it disturbing just googling a book online and downloading it without actually paying for it. I strongly believe that this is wrong and that i may not be able to unlock the key contents and... (2 Replies)
Discussion started by: despiragado
2 Replies
hsearch(3)						     Library Functions Manual							hsearch(3)

Name
       hsearch, hcreate, hdestroy - manage hash search tables

Syntax
       #include <search.h>

       ENTRY *hsearch (item, action)
       ENTRY item;
       ACTION action;

       int hcreate (nel)
       unsigned nel;

       void hdestroy ( )

Description
       The  subroutine is a hash-table search routine generalized from Knuth (6.4) Algorithm D.  It returns a pointer into a hash table indicating
       the location at which an entry can be found.  The item is a structure of type ENTRY (defined in the <search.h> header file) containing  two
       pointers: item.key points to the comparison key, and item.data points to any other data to be associated with that key.	(Pointers to types
       other than character should be cast to pointer-to-character.)  The action is a member of an enumeration type ACTION indicating the disposi-
       tion  of  the  entry  if  it cannot be found in the table.  ENTER indicates that the item should be inserted in the table at an appropriate
       point.  FIND indicates that no entry should be made.  Unsuccessful resolution is indicated by the return of a NULL pointer.

       The subroutine allocates sufficient space for the table, and must be called before is used.  The nel is an estimate of the  maximum  number
       of  entries  that  the  table  will contain.  This number may be adjusted upward by the algorithm in order to obtain certain mathematically
       favorable circumstances.

       The subroutine destroys the search table, and may be followed by another call to

Restrictions
       Only one hash search table may be active at any given time.

Diagnostics
       The subroutine returns a NULL pointer if either the action is FIND and the item could not be found or the action is ENTER and the table	is
       full.

       The subroutine returns zero if it cannot allocate sufficient space for the table.

See Also
       bsearch(3), lsearch(3), string(3), tsearch(3)

																	hsearch(3)
All times are GMT -4. The time now is 12:46 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy