473,378 Members | 1,407 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,378 software developers and data experts.

which will be more efficient Stdlib MAP or Array /w sequential search for may be 50-1000 times?

Hi was contemplating the use of either MAP or Hashtable for keeping a
cache of objects with name as the key to object. I would be searching
the MAP/Array/Hashtable often now for such a small number, which would
be quicker and how exactly does MAP search?

Thanks
Ankur

Jul 28 '06 #1
4 1711
To be clearer, the data size could be anywhere from 50-1000 objects and
access could be around 1-10 times a sec.

Thanks
Ankur

Jul 28 '06 #2
g3******@gmail.com wrote:
Hi was contemplating the use of either MAP or Hashtable for keeping a
cache of objects with name as the key to object. I would be searching
the MAP/Array/Hashtable often now for such a small number, which would
be quicker and how exactly does MAP search?

Thanks
Ankur
First of all the standard library provides "map" not "MAP".

To answer your last question, it's implementation dependent but
typically it's a binary search on a red-black tree.

As to your original question, there's not enough information here to
provide a useful answer. How many objects? How many searches? Will
the contents of the container change between searches (insertions or
deletions?)? If you can better define the parameters we may be able to
take an educated guess but the best idea is to try each and see which is
faster (if you can observe any difference at all... 1000 searches is
really very little on modern hardware).

Mark
Jul 28 '06 #3
In article <11**********************@m79g2000cwm.googlegroups .com>,
g3******@gmail.com says...
To be clearer, the data size could be anywhere from 50-1000 objects and
access could be around 1-10 times a sec.
With only a few objects like this, it's unlikely to make any
difference at all. A hash table or a sorted vector should be at least
as fast to search as an std::map. Even in that worst case, searching
1000 items should take on the order of microseconds or so (unless
comparing two items is _incredibly_ slow).

--
Later,
Jerry.

The universe is a figment of its own imagination.
Jul 28 '06 #4
In article <MP************************@news.sunsite.dk>,
jc*****@taeus.com says...
In article <11**********************@m79g2000cwm.googlegroups .com>,
g3******@gmail.com says...
To be clearer, the data size could be anywhere from 50-1000 objects and
access could be around 1-10 times a sec.

With only a few objects like this, it's unlikely to make any
difference at all. A hash table or a sorted vector should be at least
as fast to search as an std::map. Even in that worst case, searching
1000 items should take on the order of microseconds or so (unless
comparing two items is _incredibly_ slow).
Thinking about it, it seemed relevant to add one more detail here:
the "microseconds or so" is based on an assumption that the computer
is busy doing other things between the queries, so most (if not all)
of the data will usually have to be read in from main memory. If the
computer is sitting idle between queries so the data stays in cache,
then a query is more likely to finish in somewhere on the order of
nanoseconds.

--
Later,
Jerry.

The universe is a figment of its own imagination.
Jul 28 '06 #5

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

Similar topics

3
by: Edward | last post by:
ASP.NET / VB.NET SQL Server 7.0 Our client has insisted that we change our established practice of building SQL in-line and move it all to SPROCs. Not a problem for 80% of the app. However,...
25
by: CodeCracker | last post by:
Problem details below: I have few items(simple values or objects) to be put into an array and I implement it through a set rather than just an array of items. This is because every time I get a...
18
by: junky_fellow | last post by:
which of the following is faster and why ? if ( x == 1 ) { } or if ( x != 0 ) {
3
by: Ted Miller | last post by:
Hi folks, I've got an unmanaged routine I'm pinvoking to. It takes a pointer to an array of 3 pointers to bytes, typed as byte**. public static extern void foo(byte **p3pb); unsafe {...
3
by: ttan | last post by:
in c I had this structure; typedef struct _TABLE_LIST { UCHAR ValidEntries; STATUS_PACKET Status; } TABLE_LIST, *P_TABLE_LIST; How do I do the same way in c# with the structures I had...
3
by: squeek | last post by:
what i need help with determining functions how to word them and variables to consider A resistor is a circuit device designed to have a specific resistance value between its ends. Resistance...
11
by: January Weiner | last post by:
Hello, I need to use a hashing function for relatively short strings (roughly 16 characters or less). The data that needs to be accessed via hash is just a simple int. I just need to look up...
10
by: DoB | last post by:
Hi, Given the following declaration: object a = new object; which code is faster? 1. foreach ( object o in a )
3
by: pedalpete | last post by:
I'm building a calendar site, and am wondering if I've gone wrong in the way I have structured it. Right now, I take the date of each cell, and pass it as a query to mysql and put the response in...
1
by: stevedub | last post by:
I am having some trouble configuring my array to read from a sequential file, and then calling on that to fill an array of interests. I think I have the class set up to read the file, but when I run...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

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.