Google.Protobuf.Collections.RepeatedField< T >

The contents of a repeated field: essentially, a collection with some extra restrictions (no null values) and capabilities (deep cloning).

Summary

This implementation does not generally prohibit the use of types which are not supported by Protocol Buffers but nor does it guarantee that all operations will work in such cases.

Details
Template Parameters
T
The element type of the repeated field.

Inheritance

Inherits from: IList< T >, IList, Google.Protobuf.IDeepCloneable< T >, IEquatable< RepeatedField< T >>

Public attributes

Count => count
int
Gets the number of elements contained in the collection.
IsReadOnly => false
bool
Gets a value indicating whether the collection is read-only.

Properties

this[int index]
T
Gets or sets the item at the specified index.
this[int index]
object IList.

Public functions

Add(T item)
void
Adds the specified item to the collection.
Add(IEnumerable< T > values)
void
Adds all of the specified values into this collection.
AddEntriesFrom(CodedInputStream input, FieldCodec< T > codec)
void
Adds the entries from the given input stream, decoding them with the specified codec.
AddRange(IEnumerable< T > values)
void
Adds all of the specified values into this collection.
CalculateSize(FieldCodec< T > codec)
int
Calculates the size of this collection based on the given codec.
Clear()
void
Removes all items from the collection.
Clone()
RepeatedField< T >
Creates a deep clone of this repeated field.
Contains(T item)
bool
Determines whether this collection contains the given item.
CopyTo(T[] array, int arrayIndex)
void
Copies this collection to the given array.
Equals(object obj)
override bool
Determines whether the specified System.Object, is equal to this instance.
Equals(RepeatedField< T > other)
bool
Compares this repeated field with another for equality.
GetEnumerator()
IEnumerator< T >
Returns an enumerator that iterates through the collection.
GetHashCode()
override int
Returns a hash code for this instance.
IndexOf(T item)
int
Returns the index of the given item within the collection, or -1 if the item is not present.
Insert(int index, T item)
void
Inserts the given item at the specified index.
Remove(T item)
bool
Removes the specified item from the collection
RemoveAt(int index)
void
Removes the item at the given index.
ToString()
override string
Returns a string representation of this repeated field, in the same way as it would be represented by the default JSON formatter.
WriteTo(CodedOutputStream output, FieldCodec< T > codec)
void
Writes the contents of this collection to the given CodedOutputStream, encoding each value using the specified codec.

Public attributes

Count

int Count => count

Gets the number of elements contained in the collection.

IsReadOnly

bool IsReadOnly => false

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

Properties

this[int index]

T this[int index]

Gets or sets the item at the specified index.

The element at the specified index.

Details
Parameters
index
The zero-based index of the element to get or set.
Returns
The item at the specified index.

this[int index]

object IList. this[int index]

Public functions

Add

void Add(
  T item
)

Adds the specified item to the collection.

Details
Parameters
item
The item to add.

Add

void Add(
  IEnumerable< T > values
)

Adds all of the specified values into this collection.

This method is present to allow repeated fields to be constructed from queries within collection initializers. Within non-collection-initializer code, consider using the equivalent AddRange method instead for clarity.

Details
Parameters
values
The values to add to this collection.

AddEntriesFrom

void AddEntriesFrom(
  CodedInputStream input,
  FieldCodec< T > codec
)

Adds the entries from the given input stream, decoding them with the specified codec.

Details
Parameters
input
The input stream to read from.
codec
The codec to use in order to read each entry.

AddRange

void AddRange(
  IEnumerable< T > values
)

Adds all of the specified values into this collection.

Details
Parameters
values
The values to add to this collection.

CalculateSize

int CalculateSize(
  FieldCodec< T > codec
)

Calculates the size of this collection based on the given codec.

Details
Parameters
codec
The codec to use when encoding each field.
Returns
The number of bytes that would be written to a CodedOutputStream by WriteTo, using the same codec.

Clear

void Clear()

Removes all items from the collection.

Clone

RepeatedField< T > Clone()

Creates a deep clone of this repeated field.

If the field type is a message type, each element is also cloned; otherwise, it is assumed that the field type is primitive (including string and bytes, both of which are immutable) and so a simple copy is equivalent to a deep clone.

Details
Returns
A deep clone of this repeated field.

Contains

bool Contains(
  T item
)

Determines whether this collection contains the given item.

Details
Parameters
item
The item to find.
Returns
true if this collection contains the given item; false otherwise.

CopyTo

void CopyTo(
  T[] array,
  int arrayIndex
)

Copies this collection to the given array.

Details
Parameters
array
The array to copy to.
arrayIndex
The first index of the array to copy to.

Equals

override bool Equals(
  object obj
)

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

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

Equals

bool Equals(
  RepeatedField< T > other
)

Compares this repeated field with another for equality.

Details
Parameters
other
The repeated field to compare this with.
Returns
true if other refers to an equal repeated field; false otherwise.

GetEnumerator

IEnumerator< T > GetEnumerator()

Returns an enumerator that iterates through the collection.

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

GetHashCode

override int GetHashCode()

Returns a hash code for this instance.

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

IndexOf

int IndexOf(
  T item
)

Returns the index of the given item within the collection, or -1 if the item is not present.

Details
Parameters
item
The item to find in the collection.
Returns
The zero-based index of the item, or -1 if it is not found.

Insert

void Insert(
  int index,
  T item
)

Inserts the given item at the specified index.

Details
Parameters
index
The index at which to insert the item.
item
The item to insert.

Remove

bool Remove(
  T item
)

Removes the specified item from the collection

Details
Parameters
item
The item to remove.
Returns
true if the item was found and removed; false otherwise.

RemoveAt

void RemoveAt(
  int index
)

Removes the item at the given index.

Details
Parameters
index
The zero-based index of the item to remove.

ToString

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.

WriteTo

void WriteTo(
  CodedOutputStream output,
  FieldCodec< T > codec
)

Writes the contents of this collection to the given CodedOutputStream, encoding each value using the specified codec.

Details
Parameters
output
The output stream to write to.
codec
The codec to use when encoding each value.