NanoByte.Common  2.9.0
NanoByte.Common.Collections.MonitoredCollection< T > Class Template Reference

A collection that can easily be monitored for changes via events. More...

Inheritance diagram for NanoByte.Common.Collections.MonitoredCollection< T >:

Public Member Functions

 MonitoredCollection ()
 Creates a new monitored collection. More...
 
 MonitoredCollection (int maxElements)
 Creates a new monitored collection with an upper limit to the number of elements. More...
 
void AddMany ([InstantHandle] IEnumerable< T > collection)
 Adds all the items in collection to the collection that weren't already there. More...
 
void SetMany ([InstantHandle] IEnumerable< T > enumeration)
 Adds all the items in enumeration to the collection that weren't already there and removes all items in the collection that are not in enumeration . More...
 

Protected Member Functions

override void InsertItem (int index, T item)
 
override void SetItem (int index, T item)
 
override void RemoveItem (int index)
 
override void ClearItems ()
 

Properties

int MaxElements [get]
 The maximum number of elements; 0 for no limit. More...
 

Events

Action? Changed
 Occurs whenever something in the collection changes. More...
 
Action< T >? Added
 Occurs when a new item has just been added to the collection. More...
 
Action< T >? Removing
 Occurs when an item is just about to be removed from the collection. More...
 
Action< T >? Removed
 Occurs when an item has just been removed from the collection. More...
 

Detailed Description

A collection that can easily be monitored for changes via events.

Template Parameters
TThe type of elements in the collection.

Constructor & Destructor Documentation

◆ MonitoredCollection() [1/2]

Creates a new monitored collection.

◆ MonitoredCollection() [2/2]

Creates a new monitored collection with an upper limit to the number of elements.

Parameters
maxElementsThe maximum number of elements; 0 for no limit.

Member Function Documentation

◆ AddMany()

void NanoByte.Common.Collections.MonitoredCollection< T >.AddMany ( [InstantHandle] IEnumerable< T >  collection)
inline

Adds all the items in collection to the collection that weren't already there.

Parameters
collectionA collection of items to add to the collection.

All events are raised en bloc after the items have been added.

After calling this method this collection will contain a superset of the items in collection , but not necessarily in the same order.

◆ SetMany()

void NanoByte.Common.Collections.MonitoredCollection< T >.SetMany ( [InstantHandle] IEnumerable< T >  enumeration)
inline

Adds all the items in enumeration to the collection that weren't already there and removes all items in the collection that are not in enumeration .

Parameters
enumerationAn enumeration with items to add to the collection.

All events are raised en bloc after the items have been added.

After calling this method this collection will contain the same items as enumeration , but not necessarily in the same order.

Property Documentation

◆ MaxElements

The maximum number of elements; 0 for no limit.

Event Documentation

◆ Added

Occurs when a new item has just been added to the collection.

◆ Changed

Occurs whenever something in the collection changes.

◆ Removed

Occurs when an item has just been removed from the collection.

◆ Removing

Occurs when an item is just about to be removed from the collection.


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