473,796 Members | 2,520 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1543
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<stri ng,string> (2.0 onwards)
or a NameValueCollec tion, 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<stri ng,string> or NameValueCollec tion are enough for your needs
without writing your own class.

Any use?

Marc

"myPosts" <tr************ **@yahoo.com> wrote in message
news:11******** **************@ f14g2000cwb.goo glegroups.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.co m

"myPosts" <tr************ **@yahoo.com> wrote in message
news:11******** **************@ f14g2000cwb.goo glegroups.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
3543
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 obtained via the Enumerator that I create in the GetEnumerator() method. I have tried elplicitly implementing IEnumerable on my sublass as well. Can anyone help on this? Thanks in advance.
1
2111
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(). However, CollectionBase implements IList which also defines method RemoveAt(). In my collection when I code my own RemoveAt() method, the compiler issued a warning indicating that my RemoveAt() must be defined with a "new" keyword. So, to keep...
14
2190
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) { union hval_init_u { double dbl; hval_t hval; }; union hval_init_u phi = { (sqrt(5) + 1) / 2 }; /* golden ratio */
0
2174
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 and properties derived from this class but will not serialize or deserialize the properties in CollectionBase. Like InnerList, which is a read only property of CollectionBase. How can I serialize and deserialize the InnerList property of...
5
5919
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 Count { get { return 0; }
11
3438
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 that made sense. One comment I've seen alot about is "securing the hashing routine" but no-one explains how to accomplish this. So how do I secure my hashing routine? Do I use code access security, role based security, ACLs, etc or combination?...
1
2905
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 related to an invoice -InvoiceCollection: Inherited from Collectionbase class and holds Invoice objects The InvoiceCollection class is as follows:
1
4418
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 make program in Dynamic hashing i have to store int value in nodes user only enter int value by this value i have to find hash key and make symbol table my struct are
3
950
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 to implement add remove and so on. But now when generic classes can be used I can't see any point in ever using this CollectionBase any more.
0
9683
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
9529
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
10457
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10013
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
9054
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
6792
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
5443
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...
1
4119
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3733
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.