Skip to content

Commit

Permalink
update ArrayDictionary TryGetValue
Browse files Browse the repository at this point in the history
  • Loading branch information
yanghuan committed May 18, 2020
1 parent 3ed34ca commit 76ae326
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions CSharp.lua/CoreSystem.Lua/CoreSystem/Collections/Dictionary.lua
Original file line number Diff line number Diff line change
Expand Up @@ -618,10 +618,16 @@ local ArrayDictionary = (function ()
return false
end,
TryGetValue = function (this, key)
for i = 1, #this do
local pair = this[i]
if pair.Key:EqualsObj(key) then
return true, pair.Value
if key == nil then throw(ArgumentNullException("key")) end
local len = #this
if len > 0 then
local comparer = this.comparer
local equals = comparer.EqualsOf
for i = 1, len do
local pair = this[i]
if equals(comparer, pair.Key, key) then
return true, pair.Value
end
end
end
return false, this.__genericTValue__:default()
Expand Down

0 comments on commit 76ae326

Please sign in to comment.