Ooops
January 19, 2021, 06:00:41 AM

Author Topic: [bb] Delete similar types by Shambler [ 1+ years ago ]  (Read 451 times)

Offline BlitzBot

  • Jr. Member
  • **
  • Posts: 1
[bb] Delete similar types by Shambler [ 1+ years ago ]
« on: June 29, 2017, 12:28:41 AM »
Title : Delete similar types
Author : Shambler
Posted : 1+ years ago

Description : Deletes type 'copies' leaving a unique set of types that all have different values.

Code :
Code: BlitzBasic
  1. Type mytype
  2.   Field xfactor
  3. End Type
  4.  
  5. somany=1000
  6.  
  7. For some=1 To somany
  8.   m.mytype=New mytype
  9.   mxfactor=Rnd(100)
  10. Next
  11.  
  12. For m.mytype=Each mytype
  13.   Print mxfactor
  14. Next
  15.  
  16. start=MilliSecs()
  17.  
  18. For a.mytype=Each mytype
  19.  
  20.   For b.mytype=Each mytype
  21.  
  22.   If Handle(a)<>Handle(b)
  23.  
  24.     If axfactor=bxfactor
  25.  
  26.     Delete b
  27.  
  28.     EndIf
  29.  
  30.   EndIf
  31.  
  32.  
  33.   Next
  34.  
  35. Next
  36.  
  37. time=MilliSecs()-start
  38.  
  39. For m.mytype=Each mytype
  40.   Print mxfactor
  41. Next
  42.  
  43. Print "Search took "+time+" millisecs for "+somany+" types"
  44.  
  45.  
  46. While Not KeyHit(1)
  47. Wend


Comments : none...

 

SimplePortal 2.3.6 © 2008-2014, SimplePortal