User:Gwideman/Generics TDictionary
Additional docs for TDictionary and TObjectDictionary
Target pages:
(And also an exercise in wikimedia tables)
Note: links in the content prepared below probably don't work from User space because they should be relative to Libraries space.
Access methods
This section summarizes methods for reading and writing TDictionary or TObjectDictionary, including the effect of duplicate keys when writing, or key not found when reading.
Write
Method | Index type | Value type | If duplicate key |
---|---|---|---|
Add | TKey | TValue | Exception |
AddOrSetValue | TKey | TValue | Overwrite |
Items | TKey | TValue | Overwrite |
Read
Method | Index/input type | Result type | If key not found | Notes |
---|---|---|---|---|
ContainsKey | TKey | Boolean | false | True = found |
ContainsValue | TValue | Boolean | n/a | True = found |
ExtractPair | TKey | TPair | Default pair | Returns TPair, removes item from dictionary |
Items | TKey | TValue | Exception | Use TryGetValue to avoid exception |
operator [] | TKey | TValue | Exc | C++ only |
Keys | n/a | TKeyCollection | n/a | |
ToArray | n/a | TArray<TPair<TKey,TValue>> | n/a | |
TryGetValue | TKey | TValue, Boolean | default,false | Like Items[] without exception |
Values | n/a | TValueCollection | n/a |
---
---