473,665 Members | 2,774 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

33 New Member
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 1933
gpraghuram
1,275 Recognized Expert Top Contributor
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 Recognized Expert Moderator Expert
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
44098
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 scott/tiger@common control=/full_path/test.ctl log=/full_path/adhoc/test.log SQL*Loader: Release 9.2.0.1.0 - Production on Tue Sep 2 10:49:27 2003 Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
1
6466
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 Grouping by Person Wise) Total Number of Records = 30 (I am using count("*") funtion to get this and
0
2655
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 count automatically import and count records prompt for number of records imported import count auto-import records autoimport records count records before and after
2
7820
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 to do is display the total of the number of unique properties in the report footer, not just a count of the number of records. I have experimented with grouping on the property field and using running sums but to no avail. I have also tried to...
2
4268
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 key of CustomerID and is joined to CustomerID in the customer table. The order details table has a foreign key of OrderID and is joined to OrderID in the orders table. The number of records in the query is determined by the total number of items...
9
2768
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 skipped number. Hmmm??? If I'd had a boolean field named , I could-a-check-marked it and they would-a-been much easier to count. How could I determine that 3 numbers were missing from the following sequence: 1 2 4 5 7 9 and record those...
3
1556
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 how many records are in this 2nd table that apply to what we're doing on that first table. I can't just "show" that number though...it's got to be a variable or something that I can manipulate from there...like automatically add records to the...
1
2596
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 . There is then a table which records absences for each employee, it records the date of the absence etc and also holds the number of days absent . Each time the employee is absent they will have an entry in this table linked by . I have created a query...
4
1612
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 Balance. What I want to do is run the query to count the number of Companies within a country. As there are thousands of records one company may be in the table up to a couple hundred times and will be named a few times overs for each country. I use the...
0
8438
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8348
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8779
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8549
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8636
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7376
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4186
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4356
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2004
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.