Download the free trial version
Basic4android Video
Features
Tutorials and manuals
Showcase
Screenshots

Go Back   Android Development Forum - Basic4android > Basic4ppc (Windows Mobile) > Questions (Windows Mobile)
Documentation Wiki Register Members List B4P Search Today's Posts Mark Forums Read

Questions (Windows Mobile) Post any question regarding Basic4ppc.

Check for duplicates

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 09-06-2008, 07:37 PM
Basic4ppc Expert
 
Join Date: May 2008
Location: Italy
Posts: 599
Awards Showcase
Beta Tester 
Total Awards: 1
Default Check for duplicates

I need to verify in a text-file (a word-list which might contain thousands of items) that there are no duplicates therein.

To verify if there are any duplicates, I am using the Hashtable-object from Agraham's Collection-library as follows:

Code:
FileOpen(c2,"MyTextFile.txt",cRead)
        s=FileRead(c2)
        
Do Until s=EOF
             
If hash.ContainsKey(s) Then
            
'take note of the key (word) and do something
                           s=FileRead(C2)
                      
Else         
               hash.Add(s, strAt(s,
0))
             
End If
        s=FileRead(c2)
        
Loop
        FileClose(c2)
Above works since the key must be unique and if I would try to add a duplicate key to the hashtable, then I would get an error.

Do you have any other suggestions, which are faster, to check for duplicates. I thought about loading the text file into two separate arrays and then check one array's words against the other array's words but I think that would be slower.

As mentioned above, I am talking about a lot of words, could be 80000-90000 items.

Any advice would be appreciated.

rgds,
moster67

Last edited by moster67 : 09-07-2008 at 07:00 AM. Reason: spelling
Reply With Quote
  #2 (permalink)  
Old 09-06-2008, 07:49 PM
Cableguy's Avatar
Basic4ppc Expert
 
Join Date: Apr 2007
Location: N 41º11'30.30" W 8º39'46.60"
Posts: 2,344
Awards Showcase
Forum Contributer 
Total Awards: 1
Default

Although I'm not familiar with it, I think regex would be faster....
__________________
Paulo Gomes - Porto, Portugal - Living/Working in France
Mobile Device: Samsung Galaxy S, Android 2.3.4 CUstom ROM
Laptop: Toshiba NB100-130 (running on Win7Ultimate)

My Posts helped you? Consider Buying me a Porto Glass!
Reply With Quote
  #3 (permalink)  
Old 09-07-2008, 06:58 AM
Basic4ppc Expert
 
Join Date: May 2008
Location: Italy
Posts: 599
Awards Showcase
Beta Tester 
Total Awards: 1
Default

Thank you.

I have heard a lot about RegEx but like yourself I am not familiar with it (to be honest it looks teriibly complicated).

So for the time being, I will probably stick to the Hashtable but I will keep your suggestion in mind.

rgds,
moster67


Quote:
Originally Posted by Cableguy View Post
Although I'm not familiar with it, I think regex would be faster....
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to control duplicates jchal Questions (Windows Mobile) 1 10-06-2008 09:21 AM
How can I check database is opened? fishworld2006 Questions (Windows Mobile) 2 08-29-2008 09:18 AM
How to check if Form is active Mr_Gee Questions (Windows Mobile) 5 05-07-2008 03:00 PM
Check for Sub existance Scubaticus Questions (Windows Mobile) 4 11-04-2007 09:54 PM
How to check whether .Net CF 2.0 is installed correctly Erel Code Samples & Tips 3 05-18-2007 02:59 PM


All times are GMT. The time now is 02:15 AM.


Powered by vBulletin® Version 3.6.12
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0