TValue& Dictionary<TKey, TValue>::operator[](const TKey &key) { // get the index int32_t iIndex = IndexByKey(key); // if the key doesn't exist if (iIndex == -1) { // make a new pair auto &ret = Push(key); // and return the (empty) value return ret.value; } // return the value return dic_saPairs[iIndex].value; }
TValue& Dictionary<TKey, TValue>::operator[](const TKey &key) { // get the index INDEX iIndex = IndexByKey(key); // if the key doesn't exist if(iIndex == -1) { // make a new key dic_saKeys.Push() = key; // and make a new value which we'll return return dic_saValues.Push(); } // return the value return dic_saValues[iIndex]; }
void ComboBox::SetSelectedKey(const String &newSelecetedKey) { SetSelectedIndex(IndexByKey(newSelecetedKey), true); }
DictionaryPair<TKey, TValue> &Dictionary<TKey, TValue>::PopByKey(const TKey &key) { return PopByIndex(IndexByKey(key)); }
void Dictionary<TKey, TValue>::RemoveByKey(const TKey &key) { // remove by index RemoveByIndex(IndexByKey(key)); }
bool Dictionary<TKey, TValue>::HasKey(const TKey &key) { return IndexByKey(key) != -1; }