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

Using hashing in collectionbase

Hi all,

I am having class which is derived from collectionbase class.

I am adding some string elements to this collection.

What i want is to add support of hashing into class which i have
derived from collectionbase.

Because currently i am adding strings to my collection and at a time of
removing it is allowing me to removing only according to index and i
want to add functionality of removing through particular key which
should be unique.

Does any one have any idea about this.

Any help will be truely appreciated.

Thanks in advance.

Jan 9 '06 #1
3 1529
My answer would be not to re-invent the wheel; rather than deriving from
CollectionBase, I tend to use encapsulation, i.e. I would have an
instance-field which holds either a Dictionary<string,string> (2.0 onwards)
or a NameValueCollection, which I would then expose through whichever
interfaces and indexers I choose.

If you really want to inherit, neither of these is sealed - but I'd struggle
to see much of a reason (without more info). You might even find that
Dictionary<string,string> or NameValueCollection are enough for your needs
without writing your own class.

Any use?

Marc

"myPosts" <tr**************@yahoo.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
Hi all,

I am having class which is derived from collectionbase class.

I am adding some string elements to this collection.

What i want is to add support of hashing into class which i have
derived from collectionbase.

Because currently i am adding strings to my collection and at a time of
removing it is allowing me to removing only according to index and i
want to add functionality of removing through particular key which
should be unique.

Does any one have any idea about this.

Any help will be truely appreciated.

Thanks in advance.

Jan 9 '06 #2
Hi,

Because currently i am adding strings to my collection and at a time of
removing it is allowing me to removing only according to index and i
want to add functionality of removing through particular key which
should be unique.


How do you associate this key to the string?

You can use any kind of internal storage inside your collection, by default
CollectionBase use an ArrayList , but you can change it as you need.
In your case I would use a HashTable.
Just note that if you do so you will lose the indexing capabilities as a
Hashtable do not assure it.


--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
Jan 9 '06 #3
You really don't want a CollectionBase here. What you want to use is a
DictionaryBase, which is used for a map (key/value). A collection is
indexed, and not appropriate here.

Of course, in .NET 2.0, you would use the Dictionary class, and not have
to worry about this.

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

"myPosts" <tr**************@yahoo.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
Hi all,

I am having class which is derived from collectionbase class.

I am adding some string elements to this collection.

What i want is to add support of hashing into class which i have
derived from collectionbase.

Because currently i am adding strings to my collection and at a time of
removing it is allowing me to removing only according to index and i
want to add functionality of removing through particular key which
should be unique.

Does any one have any idea about this.

Any help will be truely appreciated.

Thanks in advance.

Jan 9 '06 #4

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

Similar topics

5
by: Steve M | last post by:
I have subclassed CollectionBase. I have also implemented GetEnumerator(). I have tried to set the DataSource of a DataGrid to an instance of my subclass. However, the items in the grid are not...
1
by: alanrn | last post by:
I've implemented a number of strongly-typed collections that inherit from CollectionBase and recently noticed something that I don't fully understand. CollectionBase defines method RemoveAt(). ...
14
by: Clint Olsen | last post by:
I was wondering if it's considered undefined behavior to use a member of a union when it wasn't initialized with that member. Example: typedef unsigned long hval_t; hval_t hval_init(void) {...
0
by: Mike Pollett | last post by:
Hi, I have used the ISerializable interface before and the code below worked fine. Until I derived it from CollectionBase. The code will still serialize and deserialize the properties in this class...
5
by: Eric Johannsen | last post by:
I have a simple object that inherits from CollectionBase and overrides the Count property: namespace MyTest { public class CollTest : System.Collections.CollectionBase { public override int...
11
by: Wm. Scott Miller | last post by:
Hello all! We are building applications here and have hashing algorithms to secure secrets (e.g passwords) by producing one way hashes. Now, I've read alot and I've followed most of the advice...
1
by: Kyle Novak | last post by:
I have a question about strongly typed objects when looping through a collection based on the CollectionBase object and using a For..Each loop. I have 2 objects: -Invoice: Holds all properties...
1
by: Tinku | last post by:
Hi friends I know Static Hashing and i know about Dynamic Hashing, still i have problem to make program with Dynamic Hashing I am new in "C" world, please help me, my problem is: i have to...
3
by: Tony | last post by:
Hello! I just wonder in .NET 2.0 Generics was added. Before generics existed it was an advantage to get strongly typed methods so we derived collection classes from CollectionBase where we had...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
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...

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.