473,406 Members | 2,816 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

how can I count the total number of records in a Hash table.

33
HI
I am trying to find out the total number of recoreds in a Hash Table.
I am trying to write a function to calculate the total number of the recored in the Hash Table
here is what I figure out, but I am confused now ( my code in incomplete)
would you please guid me?
Thanks

Expand|Select|Wrap|Line Numbers
  1. template <typename T,typename K>
  2. int HashTable<T,K>::countRecords(HashTable<T,K> myHash){ //The number of records in the table: countRecords()
  3.     int num_recored=0;
  4.     T temp;
  5.     for(int i=0; i<myHash.table.size(); i++)
  6.         if(myHash.table[i].size()>1)
  7.             for(int j=0; j<myHash.table[i][j].size(); j++){
  8.  
  9.  
  10.  
  11.             }
  12.  
  13.  
  14.                 if(myHash.table[i][j]!=myHash.table[i][j+1]){ //check for error
  15.                     num_record++;
  16.                 }
  17.  
  18.         num_record++;
  19.     return num_record;
  20. }
Mar 13 '08 #1
2 1920
gpraghuram
1,275 Expert 1GB
How are you storing the data inside the has table?
Usually the data will be stored in single or douly-linked list.
What i mean is its an arry of single or doubly linked list.
So to find the number of elements go to each array and from there traverse till you reach end of the list.
And Usually number of records will be mainttained in the hash

Raghuram
Mar 14 '08 #2
weaknessforcats
9,208 Expert Mod 8TB
Have you considered using accumulates() rather than write a loop?
Mar 14 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Hari Om | last post by:
Here are the details of my error log files: I execute the command and get following message at console: ---------------------------------------------------------------------- ../sqlldr...
1
by: Irfan | last post by:
Hello, I am having some problem with count function. I have a report in which has grouping by a person wise and sub grouping in invoied status e.g.. the output will be Irfan Records (First...
0
by: DataFreakFromUtah | last post by:
Hello! No question here, just a procedure for the archive. Search critera: count records imported count data imported count number of rows imported count number of records imported record import...
2
by: SJM | last post by:
I have a report that displays records of real estate properties. It is possible for each property to appear a number of times for various reasons. Each record however is unique. What I would like...
2
by: Paula | last post by:
A query contains the fields CustomerID, CustomerName, OrderID, OrderDate and ItemID. The query is based on a customers table, orders table, and order details table. The orders table has a foreign...
9
by: MLH | last post by:
A mailing list table in its virgin state contained sequential, consecutive integers in an autonumber field (A97). I've deleted records throughout the table. Now I would like to identify each...
3
by: Ron | last post by:
Hi all, I've got a form (frmOne) based on a query (qryOnFirstTable). On this form is a button that when pressed, needs to total the records in another query (qryOnSecondTable) and then shows...
1
by: muld | last post by:
I've inherited a database system designed to calculate sickness absence statistics. There is a main table with an employee ID which also holds the number of days worked by that person in a year ....
4
by: Sharkiness | last post by:
Hi, I'm new to using queries in Access and am stuck on trying to run a query from a table. I have thousands of records with fields such as customer name, Company Name, Company Country and...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.