Realm Xamarin  v0.80.0
Realm for Xamarin
Public Member Functions | Public Attributes | Properties | List of all members
RealmList< T > Class Template Reference

Return type for a managed object property when you declare a to-many relationship with IList. More...

Inherits IList< T >, IRealmList, and IDynamicMetaObjectProvider.

Public Member Functions

void Add (T item)
 Makes a relationship to an item, appending it at the end of the sorted relationship. More...
 
void Clear ()
 Breaks the relationship to all related items, without deleting the items. More...
 
bool Contains (T item)
 Tests if an item exists in the related set. More...
 
void CopyTo (T[] array, int arrayIndex)
 Copies all the elements to a portion of an array. More...
 
Enumerator GetEnumerator ()
 Related RealmObject enumerator factory for an iterator to be called explicitly or used in a foreach loop. More...
 
int IndexOf (T item)
 Finds an ordinal index for an item in a relationship. More...
 
void Insert (int index, T item)
 Makes a relationship to an item, inserting at a specified location ahead of whatever else was in that location. More...
 
bool Remove (T item)
 Breaks the relationship to the specified item, without deleting the item. More...
 
void RemoveAt (int index)
 Breaks the relationship to the item at the ordinal index, without deleting the item. More...
 

Public Attributes

bool IsFixedSize => false
 Standard IList property. More...
 
bool IsReadOnly => false
 Standard IList property. More...
 
bool IsSynchronized => true
 Standard IList property. More...
 
const int ITEM_NOT_FOUND = -1
 Value returned by IndexOf if an item is not found. More...
 

Properties

int Count [get]
 Gets the number of related items. More...
 
this[int index] [get, set]
 Returns the item at the ordinal index. More...
 

Detailed Description

Return type for a managed object property when you declare a to-many relationship with IList.

Relationships are ordered and preserve their order, hence the ability to use ordinal indexes in calls such as Insert and RemoveAt.

Although originally used in declarations, whilst that still compiles, it is not recommended as the IList approach both supports standalone objects and is implemented with a faster binding.

Template Parameters
TType of the RealmObject which is the target of the relationship.
Type Constraints
T :RealmObject 

Member Function Documentation

§ Add()

void Add ( item)

Makes a relationship to an item, appending it at the end of the sorted relationship.

Parameters
itemRealmObject being added to the relationship.

§ Clear()

void Clear ( )

Breaks the relationship to all related items, without deleting the items.

§ Contains()

bool Contains ( item)

Tests if an item exists in the related set.

Parameters
itemObject to be searched for in the related items.
Returns
True if found, false if not found.

References RealmList< T >.IndexOf(), and RealmList< T >.ITEM_NOT_FOUND.

§ CopyTo()

void CopyTo ( T []  array,
int  arrayIndex 
)

Copies all the elements to a portion of an array.

Parameters
arrayPre-allocated destination into which we copy.
arrayIndexOrdinal zero-based starting index of the destination of the related items being copied.
Exceptions
ArgumentNullExceptionThrown if array is null.
ArgumentOutOfRangeExceptionThrown if arrayIndex is less than 0.
ArgumentExceptionThrown if there is not enough room in array from arrayIndex onward.

References RealmList< T >.Count.

§ GetEnumerator()

Enumerator GetEnumerator ( )

Related RealmObject enumerator factory for an iterator to be called explicitly or used in a foreach loop.

Returns
A RealmListEnumerator as the generic IEnumerator<T>.

Referenced by RealmList< T >.RemoveAt().

§ IndexOf()

int IndexOf ( item)

Finds an ordinal index for an item in a relationship.

Parameters
itemRealmObject being removed from the relationship.
Returns
0-based index if the item was found in the related set, or RealmList.ITEM_NOT_FOUND.

Referenced by RealmList< T >.Contains(), and RealmList< T >.Remove().

§ Insert()

void Insert ( int  index,
item 
)

Makes a relationship to an item, inserting at a specified location ahead of whatever else was in that location.

Parameters
indexOrdinal zero-based index at which to insert the related items.
itemRealmObject being inserted into the relationship.
Exceptions
ArgumentOutOfRangeExceptionWhen the index is out of range for the related items.

§ Remove()

bool Remove ( item)

Breaks the relationship to the specified item, without deleting the item.

Parameters
itemRealmObject being removed from the relationship.
Returns
True if the item was found and removed, false if it is not in the related set.

References RealmList< T >.IndexOf(), and RealmList< T >.RemoveAt().

§ RemoveAt()

void RemoveAt ( int  index)

Breaks the relationship to the item at the ordinal index, without deleting the item.

Parameters
indexOrdinal zero-based index of the related item.
Exceptions
ArgumentOutOfRangeExceptionWhen the index is out of range for the related items.

References RealmList< T >.GetEnumerator().

Referenced by RealmList< T >.Remove().

Member Data Documentation

§ IsFixedSize

bool IsFixedSize => false

Standard IList property.

false at all times as the set of related objects may be changed.

§ IsReadOnly

bool IsReadOnly => false

Standard IList property.

false at all times.

§ IsSynchronized

bool IsSynchronized => true

Standard IList property.

true at all times.

§ ITEM_NOT_FOUND

const int ITEM_NOT_FOUND = -1

Value returned by IndexOf if an item is not found.

Referenced by RealmList< T >.Contains().

Property Documentation

§ Count

int Count
get

Gets the number of related items.

Returns
0 if there are no related items, including a "null" relationship never established, or the count of items.

Referenced by RealmList< T >.CopyTo().

§ this[int index]

T this[int index]
getset

Returns the item at the ordinal index.

Parameters
indexOrdinal zero-based index of the related items.
Template Parameters
TType of the RealmObject which is the target of the relationship.
Returns
A related item, if exception not thrown.
Exceptions
ArgumentOutOfRangeExceptionWhen the index is out of range for the related items.