CSCI 3342 Submission 10
Implementing a HashTable Class
Supplied file(s) |
$sup10/demo_hashtable_main (the demo executable) $sup10/hashtable.txt (the TextItems file) $sup10/famous_names.txt (a sample input file)$sup10/hashtable.h (the specification file for the
HashTable class)$sup10/hashtable_main.o (the precompiled main driver) $sup10/build.sh (a shell script for creating/building your
executable)
|
---|---|
Files to submit |
hashtable.cpp (your class source code file)hashtable_main (your executable)my_tests.log (your testing log)
|
Where to put them | Copy them to the submissions/s10 subdirectory of your
uxx account.
|
When they're due | Sunday, April 6, 2025 @11:59pm |
For this submission you will implement a HashTable
class
(according to the specifications in hashtable.h
) that compiles
separately and links with the supplied pre-compiled driver
hashtable_main.o
, and behaves like the supplied demo executable
demo_hashtable_main
. By now you will recognize this as being
pretty much "business as usual".
The data items to be stored in the HashTable
object (the "hash
table") are birthdate/name pairs in which the birthdates are the keys and
the names are the corresponding information associated with the keys. The
names are those of allegedly "famous" people.
Once the data is loaded into the hash table, and after the user has chosen the table capacity and a probe increment size to use for collision resolution via open addressing, the user may perform searching, insertion, deletion and updates.
demo_hashtable_main
, along with its
required TextItems file hashtable.txt
and the sample input
file famous_names.txt
. Then run the program, first choosing
Option 2 from the menu, and reading carefully the program description
displayed. Of course, you can also print off a hard copy of the file
hashtable.txt
and study it off-line, and you may want to do
that as well, since there are several screens if you read it on-line.
hashtable.txt
.
hashLog
file after each attempt. Be
sure to use values that fail to put all the data in the hash table, as
well as ones that succeed in placing all the data in the hash table.
HashTable
class implementation, as
specified in hashtable.h
, and be sure to call your
implementation file hashtable.cpp
.
.o
file, you need to insert a line like
extern const string MY_ID_INFO = "\t\tLastname:Firstname:A00123456:u00";in the global namespace of your class implementation file, with your own identification information replacing the generic information shown here.
size_t
typedef, as seen in various places
in the file hashtable.h
. This is a typedef similar to the
STL's size_type
, since it too provides a convenient built-in
alias for a non-negative integer type. To quote Danny Kalev, of InformIT:
... it was introduced to ensure portability of code. Consider the DOS days, whensize_t
was actuallyunsigned long
. Old code that ran on DOS and which usedsize_t
can compile on 32 bit systems without forcing the programmer to change everyunsigned long
in function prototypes and variable declarations tounsigned int
. Instead,size_t
is automatically mapped to the correct datatype used for storingsizeof()
values on the target system. In fact, it's not much different from using a symbolic constant, sayconst int MAX=1024;to ease future maintenance of the code.
Bottom line ... it's a very convenient type to use when you need a
non-negative integer type here and there throughout your code, as you do
here. It apparently lives in a number of different headers, including
<cstddef>
, <cstdlib>
and
<cstring>
.
birthDate
field, and the value in the second column
is
in the name
field):
0 empty -1 empty date nameThe first state is the state of each location after the user has set the capacity and probe increment, but before the table (and that location in particular) has received any data. The second state is the state of a location that once held data but is now empty. The third state is the state of a location that currently holds data.
my_tests.log
). Because the
program is menu driven, with quite a few menu options, writing a testing
script would be quite time consuming. But a "testing log" is quite easy to
create. If you execute the Linux script
command everything
you do at the terminal from then onward will be captured in a file called
typescript
. This makes it very easy to run a program and
capture the user interaction. The typescript
file will also
capture many strange-looking control characters, but the text will be very
readable even without removing those extraneous characters. Terminating
the script
capture process is done with a
Ctrl + D
. The final step before submitting would be to rename
the typescript
file to my_tests.log
.