webkit  2cdf99a9e3038c7e01b3c37e8ad903ecbe5eecf1
https://github.com/WebKit/webkit
Classes | Public Member Functions | Properties | List of all members
Google.Protobuf.Collections.MapField< TKey, TValue > Class Template Reference

Representation of a map field in a Protocol Buffer message. More...

Inheritance diagram for Google.Protobuf.Collections.MapField< TKey, TValue >:

Classes

class  Codec
 A codec for a specific map field. This contains all the information required to encode and decode the nested messages. More...
 

Public Member Functions

MapField< TKey, TValue > Clone ()
 Creates a deep clone of this object. More...
 
void Add (TKey key, TValue value)
 Adds the specified key/value pair to the map. More...
 
bool ContainsKey (TKey key)
 Determines whether the specified key is present in the map. More...
 
bool Remove (TKey key)
 Removes the entry identified by the given key from the map. More...
 
bool TryGetValue (TKey key, out TValue value)
 Gets the value associated with the specified key. More...
 
void Add (IDictionary< TKey, TValue > entries)
 Adds the specified entries to the map. The keys and values are not automatically cloned. More...
 
IEnumerator< KeyValuePair< TKey, TValue > > GetEnumerator ()
 Returns an enumerator that iterates through the collection. More...
 
void Clear ()
 Removes all items from the map. More...
 
override bool Equals (object other)
 Determines whether the specified System.Object, is equal to this instance. More...
 
override int GetHashCode ()
 Returns a hash code for this instance. More...
 
bool Equals (MapField< TKey, TValue > other)
 Compares this map with another for equality. More...
 
void AddEntriesFrom (CodedInputStream input, Codec codec)
 Adds entries to the map from the given stream. More...
 
void WriteTo (CodedOutputStream output, Codec codec)
 Writes the contents of this map to the given coded output stream, using the specified codec to encode each entry. More...
 
int CalculateSize (Codec codec)
 Calculates the size of this map based on the given entry codec. More...
 
override string ToString ()
 Returns a string representation of this repeated field, in the same way as it would be represented by the default JSON formatter. More...
 

Properties

TValue this[TKey key] [get, set]
 Gets or sets the value associated with the specified key. More...
 
ICollection< TKey > Keys [get]
 Gets a collection containing the keys in the map. More...
 
ICollection< TValue > Values [get]
 Gets a collection containing the values in the map. More...
 
int Count [get]
 Gets the number of elements contained in the map. More...
 
bool IsReadOnly [get]
 Gets a value indicating whether the map is read-only. More...
 

Detailed Description

Representation of a map field in a Protocol Buffer message.

Template Parameters
TKeyKey type in the map. Must be a type supported by Protocol Buffer map keys.
TValueValue type in the map. Must be a type supported by Protocol Buffers.

This implementation preserves insertion order for simplicity of testing code using maps fields. Overwriting an existing entry does not change the position of that entry within the map. Equality is not order-sensitive. For string keys, the equality comparison is provided by StringComparer.Ordinal.

Null values are not permitted in the map, either for wrapper types or regular messages. If a map is deserialized from a data stream and the value is missing from an entry, a default value is created instead. For primitive types, that is the regular default value (0, the empty string and so on); for message types, an empty instance of the message is created, as if the map entry contained a 0-length encoded value for the field.

This implementation does not generally prohibit the use of key/value types which are not supported by Protocol Buffers (e.g. using a key type of

byte

) but nor does it guarantee that all operations will work in such cases.

Member Function Documentation

◆ Add() [1/2]

void Google.Protobuf.Collections.MapField< TKey, TValue >.Add ( TKey  key,
TValue  value 
)
inline

Adds the specified key/value pair to the map.

This operation fails if the key already exists in the map. To replace an existing entry, use the indexer.

Parameters
keyThe key to add
valueThe value to add.
Exceptions
System.ArgumentExceptionThe given key already exists in map.

◆ Add() [2/2]

void Google.Protobuf.Collections.MapField< TKey, TValue >.Add ( IDictionary< TKey, TValue >  entries)
inline

Adds the specified entries to the map. The keys and values are not automatically cloned.

Parameters
entriesThe entries to add to the map.

◆ AddEntriesFrom()

void Google.Protobuf.Collections.MapField< TKey, TValue >.AddEntriesFrom ( CodedInputStream  input,
Codec  codec 
)
inline

Adds entries to the map from the given stream.

It is assumed that the stream is initially positioned after the tag specified by the codec. This method will continue reading entries from the stream until the end is reached, or a different tag is encountered.

Parameters
inputStream to read from
codecCodec describing how the key/value pairs are encoded

◆ CalculateSize()

int Google.Protobuf.Collections.MapField< TKey, TValue >.CalculateSize ( Codec  codec)
inline

Calculates the size of this map based on the given entry codec.

Parameters
codecThe codec to use to encode each entry.
Returns

◆ Clear()

void Google.Protobuf.Collections.MapField< TKey, TValue >.Clear ( )
inline

Removes all items from the map.

◆ Clone()

MapField<TKey, TValue> Google.Protobuf.Collections.MapField< TKey, TValue >.Clone ( )
inline

Creates a deep clone of this object.

Returns
A deep clone of this object.

◆ ContainsKey()

bool Google.Protobuf.Collections.MapField< TKey, TValue >.ContainsKey ( TKey  key)
inline

Determines whether the specified key is present in the map.

Parameters
keyThe key to check.
Returns
true if the map contains the given key; false otherwise.

◆ Equals() [1/2]

override bool Google.Protobuf.Collections.MapField< TKey, TValue >.Equals ( object  other)
inline

Determines whether the specified System.Object, is equal to this instance.

Parameters
otherThe System.Object to compare with this instance.
Returns
true if the specified System.Object is equal to this instance; otherwise, false.

◆ Equals() [2/2]

bool Google.Protobuf.Collections.MapField< TKey, TValue >.Equals ( MapField< TKey, TValue >  other)
inline

Compares this map with another for equality.

The order of the key/value pairs in the maps is not deemed significant in this comparison.

Parameters
otherThe map to compare this with.
Returns
true if other refers to an equal map; false otherwise.

◆ GetEnumerator()

IEnumerator<KeyValuePair<TKey, TValue> > Google.Protobuf.Collections.MapField< TKey, TValue >.GetEnumerator ( )
inline

Returns an enumerator that iterates through the collection.

Returns
An enumerator that can be used to iterate through the collection.

◆ GetHashCode()

override int Google.Protobuf.Collections.MapField< TKey, TValue >.GetHashCode ( )
inline

Returns a hash code for this instance.

Returns
A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table.

◆ Remove()

bool Google.Protobuf.Collections.MapField< TKey, TValue >.Remove ( TKey  key)
inline

Removes the entry identified by the given key from the map.

Parameters
keyThe key indicating the entry to remove from the map.
Returns
true if the map contained the given key before the entry was removed; false otherwise.

◆ ToString()

override string Google.Protobuf.Collections.MapField< TKey, TValue >.ToString ( )
inline

Returns a string representation of this repeated field, in the same way as it would be represented by the default JSON formatter.

◆ TryGetValue()

bool Google.Protobuf.Collections.MapField< TKey, TValue >.TryGetValue ( TKey  key,
out TValue  value 
)
inline

Gets the value associated with the specified key.

Parameters
keyThe key whose value to get.
valueWhen this method returns, the value associated with the specified key, if the key is found; otherwise, the default value for the type of the value parameter. This parameter is passed uninitialized.
Returns
true if the map contains an element with the specified key; otherwise, false.

◆ WriteTo()

void Google.Protobuf.Collections.MapField< TKey, TValue >.WriteTo ( CodedOutputStream  output,
Codec  codec 
)
inline

Writes the contents of this map to the given coded output stream, using the specified codec to encode each entry.

Parameters
outputThe output stream to write to.
codecThe codec to use for each entry.

Property Documentation

◆ Count

int Google.Protobuf.Collections.MapField< TKey, TValue >.Count
get

Gets the number of elements contained in the map.

◆ IsReadOnly

bool Google.Protobuf.Collections.MapField< TKey, TValue >.IsReadOnly
get

Gets a value indicating whether the map is read-only.

◆ Keys

ICollection<TKey> Google.Protobuf.Collections.MapField< TKey, TValue >.Keys
get

Gets a collection containing the keys in the map.

◆ this[TKey key]

TValue Google.Protobuf.Collections.MapField< TKey, TValue >.this[TKey key]
getset

Gets or sets the value associated with the specified key.

Parameters
keyThe key of the value to get or set.
Exceptions
KeyNotFoundExceptionThe property is retrieved and key does not exist in the collection.
Returns
The value associated with the specified key. If the specified key is not found, a get operation throws a KeyNotFoundException, and a set operation creates a new element with the specified key.

◆ Values

ICollection<TValue> Google.Protobuf.Collections.MapField< TKey, TValue >.Values
get

Gets a collection containing the values in the map.


The documentation for this class was generated from the following file: