Skip to content

Commit

Permalink
Added: Object parameter to Dictionary IndexOfKey And ContainsOfKey fu…
Browse files Browse the repository at this point in the history
…nctions
  • Loading branch information
XusinboyBekchanov committed Mar 17, 2022
1 parent a1af773 commit f752c52
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
20 changes: 14 additions & 6 deletions mff/Dictionary.bas
Expand Up @@ -217,10 +217,18 @@ Private Function Dictionary.IndexOf(ByRef wText As WString) As Integer
Return -1
End Function

Private Function Dictionary.IndexOfKey(ByRef Key As WString) As Integer
For i As Integer = 0 To Count - 1
If QDictionaryItem(FItems.Items[i]).Key = Key Then Return i
Next i
Private Function Dictionary.IndexOfKey(ByRef Key As WString, Object As Any Ptr = 0) As Integer
If Object = 0 Then
For i As Integer = 0 To Count - 1
If QDictionaryItem(FItems.Items[i]).Key = Key Then Return i
Next i
Else
For i As Integer = 0 To Count - 1
With QDictionaryItem(FItems.Items[i])
If .Key = Key AndAlso .Object = Object Then Return i
End With
Next i
End If
Return -1
End Function

Expand Down Expand Up @@ -301,8 +309,8 @@ Private Function Dictionary.Contains(ByRef wText As WString) As Boolean
Return IndexOf(wText) <> -1
End Function

Private Function Dictionary.ContainsKey(ByRef Key As WString) As Boolean
Return IndexOfKey(Key) <> -1
Private Function Dictionary.ContainsKey(ByRef Key As WString, Object As Any Ptr = 0) As Boolean
Return IndexOfKey(Key, Object) <> -1
End Function

Private Function Dictionary.ContainsObject(Object As Any Ptr) As Boolean
Expand Down
4 changes: 2 additions & 2 deletions mff/Dictionary.bi
Expand Up @@ -55,7 +55,7 @@ Public:
Declare Sub SortKeys
Declare Sub Clear
Declare Function IndexOf(ByRef wText As WString) As Integer
Declare Function IndexOfKey(ByRef Key As WString) As Integer
Declare Function IndexOfKey(ByRef Key As WString, Object As Any Ptr = 0) As Integer
Declare Function IndexOfObject(FObj As Any Ptr) As Integer
Declare Sub Set(ByRef Key As WString, ByRef wText As WString = "", Object As Any Ptr = 0)
Declare Function Get(Index As Integer, ByRef DefaultText As WString = "") ByRef As WString
Expand All @@ -65,7 +65,7 @@ Public:
Declare Function GetText(ByRef Key As WString) ByRef As WString
Declare Function GetObject(ByRef Key As WString) As Any Ptr
Declare Function Contains(ByRef wText As WString) As Boolean
Declare Function ContainsKey(ByRef Key As WString) As Boolean
Declare Function ContainsKey(ByRef Key As WString, Object As Any Ptr = 0) As Boolean
Declare Function ContainsObject(Object As Any Ptr) As Boolean
Declare Sub SaveToFile(ByRef FileName As WString)
Declare Sub LoadFromFile(ByRef FileName As WString)
Expand Down

0 comments on commit f752c52

Please sign in to comment.