Advertisement
jsbsan

mejoracoleccion

Jul 31st, 2014
3,885
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
GAMBAS 1.45 KB | None | 0 0
  1. ' Gambas class file
  2.  
  3. Private $dato As New Collection
  4. Private arrayKey As New String[]
  5. Private contador As Integer = 0
  6.  
  7. Property count As Integer
  8. Property Length As Integer
  9.  
  10. Private Function count_Read() As Integer
  11.  
  12.   Dim c As Integer
  13.  
  14.   c = $dato.Count
  15.   Return c
  16.  
  17. End
  18.  
  19. Private Sub count_write(v As Integer)
  20.  
  21. End
  22.  
  23. Public Sub add(valor As Variant, key As String)
  24.  
  25.   $dato.Add(valor, key)
  26.  
  27.   arrayKey.add(key)
  28.  
  29. End
  30.  
  31. Public Sub Clear()
  32.  
  33.   $dato.Clear()
  34.   arrayKey.Clear()
  35.  
  36. End
  37.  
  38. Public Sub Copy() As MejoraColeccion
  39.  
  40.   Dim m As New MejoraColeccion
  41.   Dim a As Integer
  42.  
  43.   For a = 0 To Me.count - 1
  44.     m.add(Me[a], Me.Key(a))
  45.   Next
  46.  
  47.   Return m
  48.  
  49. End
  50.  
  51. Public Function Exist(key As String) As Boolean
  52.  
  53.   Return $dato.Exist(key)
  54.  
  55. End
  56.  
  57. Public Sub Remove(key As Integer)
  58.  
  59.   Try $dato.Remove(key)
  60.  
  61.   Try arrayKey.Remove(arrayKey.Find(key))
  62.  
  63. End
  64.  
  65. Public Function _get(v As Variant) As String
  66.  
  67.   Dim c As String
  68.  
  69.   c = Str$(v)
  70.   If IsNumber(c) Then
  71.     Try Return $dato[arrayKey[v]]
  72.     If Error Then
  73.       Return Null 'por si se produce un error
  74.     Endif
  75.  
  76.   Else
  77.     Try Return $dato[v]
  78.     If Error Then
  79.       Return Null 'por si se produce un error
  80.     Endif
  81.  
  82.   Endif
  83.  
  84. End
  85.  
  86. Public Function Key(v As Integer) As String
  87.  
  88.   Return arrayKey[v]
  89.  
  90. End
  91.  
  92. Private Function Length_Read() As Integer
  93.  
  94.   Dim c As String
  95.  
  96.   c = $dato.Length
  97.   Return c
  98.  
  99. End
  100.  
  101. Private Sub Length_Write(Value As Integer)
  102.  
  103. End
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement