473,698 Members | 2,410 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Size of Dictionary Object

Hi All,

I have to make multiple dictionary objects(Diction ary<string key, int
value>) with same set of string keys, and that really eats up lot of
space. I am trying to find a solution where I can save space- In my
current implementation all dictionary objects store the same keys
repetitively and that eats up lot of space. Does .net framework comes
to help in such situation?

The best I can think of is having a separate dictionary object which
maps given set of string keys to set of unique integers, and then use
that unique integers to map to value - this way I don;t have to store
string keys multiple times. Can someone suggest me a better solution.

Thanks,
Shrish

Jun 1 '06 #1
3 11392
Shrish,

I'm not exactly sure what you're trying to accomplish, but is each
Dictionary storing integers for the values (but using the same keys)?

If so, you could use an int[] as the value. If not, maybe you can use
another type of array or collection.

Also, if you need some sort of identifier for the values you are
storing, you could use Dictionary<stri ng, Dictionary<stri ng, int>> which
would give you just 1 key, and then a dictionary for that key with
strings and integers.

Hope this helps.

Dan Manges
Jun 1 '06 #2
Why not just use a structure as the value, which has fields which store
the possible values.

For example, if one Dictionary is a Dictionary<stri ng, MyObject> and
another is Dictionary<stri ng, MyObject2>, then you could do this:

public struct MyObjects
{
public MyObject MyObject;
public MyObject2 MyObject2;
}

And then use a Dictionary<stri ng, MyObjects>, setting the appropriate
fields, and using only one set of keys.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"Dan Manges" <da***********@ gmail.com> wrote in message
news:0X******** **********@torn ado.ohiordc.rr. com...
Shrish,

I'm not exactly sure what you're trying to accomplish, but is each
Dictionary storing integers for the values (but using the same keys)?

If so, you could use an int[] as the value. If not, maybe you can use
another type of array or collection.

Also, if you need some sort of identifier for the values you are storing,
you could use Dictionary<stri ng, Dictionary<stri ng, int>> which would give
you just 1 key, and then a dictionary for that key with strings and
integers.

Hope this helps.

Dan Manges

Jun 1 '06 #3
Would this kind of approach help:

//(using System.Collecti ons)

SortedList sortedList = new SortedList();
ArrayList arrayList1 = new ArrayList();
ArrayList arrayList2 = new ArrayList();

arrayList1.Add( 1);
arrayList1.Add( 3);
arrayList1.Add( 5);

arrayList2.Add( 0);
arrayList2.Add( 2);
arrayList2.Add( 4);

string strKey1 = "int collection one";
string strKey2 = "int collection two";

sortedList.Add( strKey1, arrayList1);
sortedList.Add( strKey2, arrayList2);

IDictionaryEnum erator oIDictionaryEnu merator =
sortedList.GetE numerator();

while (oIDictionaryEn umerator.MoveNe xt())
{
Console.WriteLi ne("key = {0}",
oIDictionaryEnu merator.Key);

ArrayList arrayList = oIDictionaryEnu merator.Value as
ArrayList;
IEnumerator oIEnumerator = arrayList.GetEn umerator();
while (oIEnumerator.M oveNext())
{
Console.WriteLi ne("value = {0}",
oIEnumerator.Cu rrent);
}
}

Jun 2 '06 #4

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

Similar topics

6
6328
by: Johnny Klunk | last post by:
Wondering if someone can give me a hand with something that I'm sure is really easy - but damned if I know what I'm doing wrong. I'm trying to read the contents of a database into an ASP dictionary object. However I'm getting the error Microsoft VBScript runtime error '800a01c9' This key is already associated with an element of this collection /test.asp, line 21 There's definately no repeated data in either column, it's currently...
8
5585
by: Rodd Snook | last post by:
I have an application which makes extensive use of the Scripting.Dictionary object. I'm not doing anything silly like putting them outside the page scope -- just creating quite a few of them and stuffing quite a lot of data (from and MS SQL database) into them. On Windows 2000 server, everything is fine. If the data structures get really big it slows down, but for normal operation it's no problem. Recently our hosting provider moved to...
1
2946
by: boohoo | last post by:
I can't seem to do this: I want to take a query string and place two halves of the querystring into two separate dictionary objects. So... I loop through the collection of querystring items, right? When I get to a certain item in the querystring, all items after that are to be put into the SECOND dictionary object.
5
2088
by: TWiSTeD ViBE | last post by:
Hi, While pouring over some code I've discovered a previous developer heavily uses the "dictionary" object. Whilst I see some of the advantages of using this system It's something I've not used myself so am not sure of the limitations. We are about to widen the scope of the website it's being used on to a WorldWide system - greatly increasing the number of users that will be using the website.
26
4055
by: Alan Silver | last post by:
Hello, I have a server running Windows Server 2003, on which two of the web sites use the MegaBBS ASP forum software. Both sites suddenly developed the same error, which seems to be connected to the dictionary object. After some tinkering, I whittled it down to the following (complete) ASP... <%@ CodePage=65001 Language="VBScript"%>
4
1606
by: CharlesEF | last post by:
Hi All, This has me stumped. I have used a VBScript dictionary object to load column names and their values so I can use them when I build the web page. When I do this, I get the correct value printed on the page: <%Response.Write("Company Name is: " & objDict.Item("companyname"))%> But, when I try to use it in an HTML tag, like this, I get a runtime
1
9250
by: john wright | last post by:
I have a dictionary oject I created and I want to bind a listbox to it. I am including the code for the dictionary object. Here is the error I am getting: "System.Exception: Complex DataBinding accepts as a data source either an IList or an IListSource at System.Windows.Forms.ListControl.set_DataSource(Object value)
4
2321
by: Betina Andersen | last post by:
I have a dictionary object, then I create a new dictionary object and sets it equal to my original, then I pass the new dictionary object to a function that changes some of my values - but then my original dictionary also gets changed and that was not the intention, can someone explain to me why it behaves that way and how do I avoid it, så I van have different dictionary objects? Thanks Betina
15
7935
by: Dave Young | last post by:
I'm trying to replicate the behaviour of the Commerce.Dictionary object that was found in Commerce Server 3.0 By using a hashtable or creating a custom class that implements IDictionary, you have to add elements by using the following syntax. DictionaryObject.Add("key","value"); However, the old Commerce Server Dictionary object used the following syntax.
0
8676
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
9029
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
8898
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
7734
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
5860
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4370
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
4619
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2332
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2006
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.