New topic: 

Preventing Duplicates in a Class

<http://forums.realsoftware.com/viewtopic.php?t=45228>

         Page 1 of 1
   [ 2 posts ]                 Previous topic | Next topic          Author  
Message        tseyfarth          Post subject: Preventing Duplicates in a 
ClassPosted: Mon Sep 03, 2012 12:24 am                         
Joined: Sat Dec 04, 2010 9:14 pm
Posts: 680                Hello All,

I have a class that is uses to buffer data.

Properties:
Cmd As Integer
Data As String
iCmdID As Integer
Idata As Integer
SocketHandle As Integer


Private CmdQueue(0) As clsCommand

CmdQueue(0)  = New clsCommand

Data is added using the Append Method.

My question is, how can I quickly and easily find out if at least one of the 
elements contain the data that is about to be added - thereby avoiding 
duplicating data in the queue? The only way I can think of is to search element 
0 to Ubound.  But this might take quite a while.  Since this task is taking 
away from other parts of the program (it is active, not a passive desktop user 
type application) I don't want to waste time.  However having multiple elements 
of the same data slows down operation too - the data is sent via TCPIP.

Also, when the data is sent, the elements sent are destroyed.
For i = n downto 1 //Remove the index
  CmdQueue.Remove(i)
Next


Any ideas would be appreciated!
Thanks
Tim   
                             Top                charonn0          Post subject: 
Re: Preventing Duplicates in a ClassPosted: Mon Sep 03, 2012 2:13 am            
                     
Joined: Mon Apr 02, 2007 2:08 am
Posts: 893
Location: San Francisco, CA, USA                You could use a Dictionary 
instead of an array.      
_________________
Boredom Software  
                             Top             Display posts from previous: All 
posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost 
timeSubject AscendingDescending          Page 1 of 1
   [ 2 posts ]      
-- 
Over 1500 classes with 29000 functions in one REALbasic plug-in collection. 
The Monkeybread Software Realbasic Plugin v9.3. 
http://www.monkeybreadsoftware.de/realbasic/plugins.shtml

rbforumnotifier@monkeybreadsoftware.de

Reply via email to