473,406 Members | 2,894 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.

HashTable implementation

I need help in how to implement a HashTable but specific the method
getKeys(); anyone could help.?

Mar 3 '06 #1
7 3947
"Eduardo F. Sandino" <ed*************@gmail.com> writes:
I need help in how to implement a HashTable but specific the method
getKeys(); anyone could help.?


Why? Do you have a specific use for it, or is it for a library?

How do you plan to calculate the hash value?

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
Mar 3 '06 #2
Eduardo F. Sandino wrote:
I need help in how to implement a HashTable but specific the method
getKeys(); anyone could help.?


You need to be more specific.
If all you want is a "hashtable" or objects, with the ability to get the
"keys" then a simple Object works fine.

var o = new Object();
o["a"] = 1;
o["b"] = 2;
for (key in o) {
alert(o + " = " + o[key]);
}

--
Matt Kruse
http://www.JavascriptToolbox.com
http://www.AjaxToolbox.com
Mar 3 '06 #3
Thanks i will try it... I be writing from here until have a nice
HashTable implementation... optimized to solve any needs...

Mar 3 '06 #4
In article <fy**********@hotpop.com>, Lasse Reichstein Nielsen
<lr*@hotpop.com> writes
"Eduardo F. Sandino" <ed*************@gmail.com> writes:
I need help in how to implement a HashTable but specific the method
getKeys(); anyone could help.?


Why? Do you have a specific use for it, or is it for a library?

How do you plan to calculate the hash value?


Just as important, how do you plan to allocate the raw storage that must
be allocated when a Hash Table is created?

John
--
John Harris
Mar 3 '06 #5
VK

Eduardo F. Sandino wrote:
Thanks i will try it... I be writing from here until have a nice
HashTable implementation... optimized to solve any needs...


You may want to write it for non-IE UA's then, as JScript has native
Dictionary object (=== Perl hash) and Enumerator wrapper for
HTMLCollection (see MSDN for details). These objects are not
replaceable by custom made equivalents: say no way you can emulate real
hashtable baskets structure w/o Dictionary. And in many situations (say
file collections returned by fso) JScript wants Enumerator and
Enumerator only.

So the task would be then to write an unifiormed interface atop
Dictionary/Enumerator (IE) and custom emulators (others).

Mar 4 '06 #6
"Eduardo F. Sandino" <ed*************@gmail.com> writes:
Thanks i will try it... I be writing from here until have a nice
HashTable implementation... optimized to solve any needs...


I doubt one thing can solve all needs. That's why it's good to have
several solutions to choose from.

I'm not sure why you need a hash table.

A hash table is a specific implementation of an associative array
(aka. dictionaray, aka. map), an updateable data structure thatm aps
key values keys into other values.

There are many ways to implement an assocative array, each with
different time/memory behavior.

A hash table creates a hash value of the keys, i.e., a number, and
uses that to index into an array - the bucket for that hash
value. Then it goes through the list of key/value pairs in that
bucket, all the ones with a key that hashes to the same value.
This gives, for a reasonable table size, an expected constant time
for insert, lookup and delete operations.

If you are just trying to implement an associative array, then it's
not necessarily a hash table that is the best choice of implementation
in Javascript. You could use the language's own implementation of
properties on objects instead, suitably wrapped. That will not
guarantee the time complexity, as different Javascript implementations
do object properties differently (some might use a hash table
internally, others might not).

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
Mar 4 '06 #7
I am planing to make that HashTable to have a good one collection in
where to store the values from some clases, and the posibility to
export them to other formats i am saying imaging you are working in a
JavaScript program and the user want to stop the session... getAll the
info in the hashtable for example in a hidden control compacted to be
stored in da DB server when the user plan to return other day to
continue using the JavaScript program... thats the Way... Order and
Simplicity... i know there are good choices but i need to scale one
level up of common structures.. so i am looking for optimization of the
hash and things like that...

Mar 5 '06 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Gary Davis | last post by:
Once a day or so, I receive an error on a fairly active website that calls this StrMixed.cs method constructor. 99% of the time there is no exception: System.Web.HttpUnhandledException:...
3
by: A. Burch | last post by:
I posted early about Hashtable use and the shallow/deep copy and storing a reference answered that question. I've got a larger implementation of this, but am not sure why I'm getting this error....
33
by: Ken | last post by:
I have a C# Program where multiple threads will operate on a same Hashtable. This Hashtable is synchronized by using Hashtable.Synchronized(myHashtable) method, so no further Lock statements are...
16
by: Sreekanth | last post by:
Hello, Is there any better collection than HashTable in terms of performance, when the type of the key is integer? Regards, Sreekanth.
6
by: Steven Wolf | last post by:
Hi guys, can a hashtable be faster than a sql server?? i made my own O/R mapping with an "entity cache" (caching all mapped objects). So, when i get some data from my sql server, i map that data...
7
by: Naveen Mukkelli | last post by:
Hi, I'm working on a Client/Server application. Server application needs to keep track of all the clients. I'm planning to use a Hashtable for this purpose. There would be thousands of...
1
by: oDDskOOL | last post by:
I realized today that the Hashtable.Clone only produces a shallow copy... that makes me go mad that M$ doesn't even provide a deep copy ctor for the Hashtable class ! mighty tech ducks might...
5
by: Victor Paraschiv | last post by:
I need to serialize into an XML file a hashtable. From MSDN at XmlSerializer:...
3
by: jw56578 | last post by:
I have an object that inherits from hashtable and is serializable to be stored in the viewstate, but when I retrieve it from viewstate, it is converted into a hashtable, why won't it stay as the...
10
by: chrisben | last post by:
Hi, Here is the scenario. I have a list of IDs and there are multiple threads trying to add/remove/read from this list. I can do in C# 1. create Hashtable hList = Hashtable.Synchronized(new...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...
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...

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.