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

Home Posts Topics Members FAQ

Intern Strings - am I using them right? Please help!

Intern Strings - am I usingthem right.
I have heard a lot about intern string - so I wanted to use them to
increas e speed of processing.

I have a hastable that I am using to parse a string of the form:

wordA wordB wordC wordD etc etc

I want to de-duplicate the string - that is, remove any repeated words
so that only 1 occurance of the word exists.

Its working fine - takes about 25 mins to do all the strings that I
have for it so I intriduced the line:

String.Intern(s )

in an effort in incrase spped of processing. My question is though -
am I using intern string correctly? Am I msiing anything or using them
incorrectly? Any comments/suggestions/code-samples much appreciated.

Al.

******** CODE AS FOLLOWS ********
Public Function DeDuplicate(ByV al str As String) As String
Dim ht As New Hashtable

Dim s As String
For Each s In str.Split(" "c)
Try
String.Intern(s )
If Not ht.ContainsKey( s) Then
ht.Add(s, s)
End If
Catch ex As Exception
Debug.WriteLine (ex.ToString)
End Try
Next

'Convert hashtable -> string
Dim deDupStr As String
Dim Item As DictionaryEntry
For Each Item In ht
'String.Intern( deDupStr)
'Trace.WriteLin e(Item.Value)
deDupStr += Item.Value.ToSt ring + " "
Next

Return deDupStr.Trim()

End Function

Jan 23 '06 #1
2 1135
> I have heard a lot about intern string - so I wanted to use them to
increas e speed of processing.
I think you could gain more by using a StringBuilder when recreating
the stirng instead of the += operator.

String.Intern( s)

in an effort in incrase spped of processing. My question is though -
am I using intern string correctly?


Why do you think interning ths string would make your processing
faster? Did you see any performance increase?
Mattias

--
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Jan 23 '06 #2

Mattias Sjögren wrote:
I have heard a lot about intern string - so I wanted to use them to
increas e speed of processing.


I think you could gain more by using a StringBuilder when recreating
the stirng instead of the += operator.


Thanks. I'll try this and see does it imporve speed of processing.
String.Intern( s)

in an effort in incrase spped of processing. My question is though -
am I using intern string correctly?


Why do you think interning ths string would make your processing
faster? Did you see any performance increase?


No - afraid not. Nothing amazing to make me sit up.

Hope I used them right...

Thank for your help Mattias.
A.

Jan 24 '06 #3

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

Similar topics

4
1312
by: Alistair | last post by:
I should just get a hat with a big D on it and then everyone would recognise me.. anyway... I have a DB full of people and their details.. I'm trying to perform a query based on age. so I have a form with two values..upperlimit and lowerlimit ( eg aged
3
1462
by: Steve | last post by:
Hi all I am using the following code to draw strings onto a Form: ---------------------------- Dim tabGraphics As System.Drawing.Graphics = Me.CreateGraphics() Dim labelFont As New Font("Verdana", 12, FontStyle.Regular, GraphicsUnit.Pixel) Dim solidBrush As New SolidBrush(Color.DarkSlateBlue) ---------------------------
5
1777
by: Charles Law | last post by:
Hi folks Not really a .NET question, but I always think this is a good place to ask. Does anyone have a favourite algorithm for determining the similarity of, or difference between two strings? I'm looking for something that could be considered to be quite reliable. I have Googled quite extensively, and there is a lot on this subject, but I am interested in people's practical experience and use of such algorithms to
7
3607
by: MeganTSU | last post by:
Hey yall! I am trying to get this program finished for class.... It says that you are suppposed to write a program that will display a check formatted out put (the output looks like a check). I got everything to work and it will compile and run...... BUT.... I dont know how to turn the 'Amount' into a charater string that puts the number into words.... It is supposed to show the name, then the amount, and then on the next line write out...
9
2208
by: Diane | last post by:
Could you please explain me how can I output nested strings? Here is an example: "adsd{rfkm}xcv" The output should start from the inner parentheses, such as: dfF rfkm
5
515
by: Twinkle | last post by:
HI guys i have two strings .in first string a word file is there and the second string a html file is there.now i want to compare to both string if some word missing in second string then it should be highlight by color change.becaz it's a testing purpose tool plz somebody help me.and send the code at my id hemendraagrawal@gmail.com it will be very appriciated Thank's & Regards
16
1880
by: InDepth | last post by:
Now that .NET is at it's fourth release (3.5 is coming soon), my very humble question to the gurus is: "What have we won with the decision to have string objects immutable? Or did we won?" Ok. It's a broad, and maybe a very silly question to ask, but still. I mean, what good has it brought to us? What advantages immutable strings have against mutable ones?
4
1687
sumittyagi
by: sumittyagi | last post by:
Hi All! I am confused in the functioning of String.intern() function. public class StringTest { public static void main(String args) { String test2 = new String("ABC"); test2.intern();
19
2060
by: bowlderyu | last post by:
Hello, all. If a struct contains a character strings, there are two methods to define the struct, one by character array, another by character pointer. E.g, //Program for struct includeing character strings, test1.c #include <stdio.h> #define LEN 20 struct info {
0
9528
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
10455
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
10228
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...
0
10006
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
9052
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
5441
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
5573
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3731
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2925
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.