コード例 #1
0
ファイル: Dictionary.hpp プロジェクト: angelog/Scratch
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;
}
コード例 #2
0
ファイル: CDictionary.cpp プロジェクト: Bromvlieg/Scratch
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];
}
コード例 #3
0
void ComboBox::SetSelectedKey(const String &newSelecetedKey)
{
    SetSelectedIndex(IndexByKey(newSelecetedKey), true);
}
コード例 #4
0
ファイル: Dictionary.hpp プロジェクト: angelog/Scratch
DictionaryPair<TKey, TValue> &Dictionary<TKey, TValue>::PopByKey(const TKey &key)
{
	return PopByIndex(IndexByKey(key));
}
コード例 #5
0
ファイル: Dictionary.hpp プロジェクト: angelog/Scratch
void Dictionary<TKey, TValue>::RemoveByKey(const TKey &key)
{
	// remove by index
	RemoveByIndex(IndexByKey(key));
}
コード例 #6
0
ファイル: Dictionary.hpp プロジェクト: angelog/Scratch
bool Dictionary<TKey, TValue>::HasKey(const TKey &key)
{
	return IndexByKey(key) != -1;
}