Lines Matching defs:key

62     /// This implementation does not generally prohibit the use of key/value types which are not

63 /// supported by Protocol Buffers (e.g. using a key type of <code>byte</code>) but nor does it guarantee
110 /// Adds the specified key/value pair to the map.
113 /// This operation fails if the key already exists in the map. To replace an existing entry, use the indexer.
115 /// <param name="key">The key to add</param>
117 /// <exception cref="System.ArgumentException">The given key already exists in map.</exception>
118 public void Add(TKey key, TValue value)
121 if (ContainsKey(key))
123 throw new ArgumentException("Key already exists in map", nameof(key));
125 this[key] = value;
129 /// Determines whether the specified key is present in the map.
131 /// <param name="key">The key to check.</param>
132 /// <returns><c>true</c> if the map contains the given key; <c>false</c> otherwise.</returns>
133 public bool ContainsKey(TKey key)
135 ProtoPreconditions.CheckNotNullUnconstrained(key, nameof(key));
136 return map.ContainsKey(key);
143 /// Removes the entry identified by the given key from the map.
145 /// <param name="key">The key indicating the entry to remove from the map.</param>
146 /// <returns><c>true</c> if the map contained the given key before the entry was removed; <c>false</c> otherwise.</returns>
147 public bool Remove(TKey key)
149 ProtoPreconditions.CheckNotNullUnconstrained(key, nameof(key));
151 if (map.TryGetValue(key, out node))
153 map.Remove(key);
164 /// Gets the value associated with the specified key.
166 /// <param name="key">The key whose value to get.</param>
167 /// <param name="value">When this method returns, the value associated with the specified key, if the key is found;
170 /// <returns><c>true</c> if the map contains an element with the specified key; otherwise, <c>false</c>.</returns>
171 public bool TryGetValue(TKey key, out TValue value)
174 if (map.TryGetValue(key, out node))
187 /// Gets or sets the value associated with the specified key.
189 /// <param name="key">The key of the value to get or set.</param>
190 /// <exception cref="KeyNotFoundException">The property is retrieved and key does not exist in the collection.</exception>
191 /// <returns>The value associated with the specified key. If the specified key is not found,
192 /// a get operation throws a <see cref="KeyNotFoundException"/>, and a set operation creates a new element with the specified key.</returns>
193 public TValue this[TKey key]
197 ProtoPreconditions.CheckNotNullUnconstrained(key, nameof(key));
199 if (TryGetValue(key, out value))
207 ProtoPreconditions.CheckNotNullUnconstrained(key, nameof(key));
214 var pair = new KeyValuePair<TKey, TValue>(key, value);
215 if (map.TryGetValue(key, out node))
222 map[key] = node;
291 /// Determines whether map contains an entry equivalent to the given key/value pair.
293 /// <param name="item">The key/value pair to find.</param>
302 /// Copies the key/value pairs in this map to an array.
312 /// Removes the specified key/value pair from the map.
314 /// <remarks>Both the key and the value must be found for the entry to be removed.</remarks>
315 /// <param name="item">The key/value pair to remove.</param>
316 /// <returns><c>true</c> if the key/value pair was found and removed; <c>false</c> otherwise.</returns>
381 /// The order of the key/value pairs in the maps is not deemed significant in this comparison.
424 /// <param name="codec">Codec describing how the key/value pairs are encoded</param>
447 /// <param name="codec">Codec describing how the key/value pairs are encoded</param>
533 void IDictionary.Add(object key, object value)
535 Add((TKey)key, (TValue)value);
538 bool IDictionary.Contains(object key)
540 if (!(key is TKey))
544 return ContainsKey((TKey)key);
552 void IDictionary.Remove(object key)
554 ProtoPreconditions.CheckNotNull(key, nameof(key));
555 if (!(key is TKey))
559 Remove((TKey)key);
579 object IDictionary.this[object key]
583 ProtoPreconditions.CheckNotNull(key, nameof(key));
584 if (!(key is TKey))
589 TryGetValue((TKey)key, out value);
595 this[(TKey)key] = (TValue)value;
644 /// Creates a new entry codec based on a separate key codec and value codec,
647 /// <param name="keyCodec">The key codec.</param>
714 // Corner case: a map entry with a key but no value, where the value type is a message.