Class GuardedCollection<T>

A read-only wrapper for an ICollection<T>,

Suitable for wrapping hash tables, HashSet<T> and HashBag<T>

Implements

IEnumerable<T>, System.Collections.IEnumerable, System.IFormattable, System.ICloneable, System.Collections.Generic.ICollection<T>, ICollection<T>, ICollectionValue<T>, IExtensible<T>, IShowable

Bases

object, GuardedEnumerable<T>, GuardedCollectionValue<T>

Base of

GuardedIndexedSorted<T>, GuardedList<T>, GuardedSequenced<T>, GuardedSorted<T>

Event overview

CollectionChanged, Inherited from GuardedCollectionValue<T> ,
CollectionCleared, Inherited from GuardedCollectionValue<T> ,
ItemInserted, Inherited from GuardedCollectionValue<T> ,
ItemRemovedAt, Inherited from GuardedCollectionValue<T> ,
ItemsAdded, Inherited from GuardedCollectionValue<T> ,
ItemsRemoved, Inherited from GuardedCollectionValue<T>

Property overview

ActiveEvents, Inherited from GuardedCollectionValue<T> ,
AllowsDuplicates ,
ContainsSpeed ,
Count, Inherited from GuardedCollectionValue<T> ,
CountSpeed, Inherited from GuardedCollectionValue<T> ,
DuplicatesByCounting ,
EqualityComparer ,
IsEmpty ,
IsReadOnly ,
ListenableEvents, Inherited from GuardedCollectionValue<T>

Constructor overview

GuardedCollection<T>(ICollection<T> collection)

Method overview

Add(T item) ,
AddAll<U>(IEnumerable<U> items) ,
All(Fun<T,bool> filter), Inherited from GuardedCollectionValue<T> ,
Apply(Act<T> a), Inherited from GuardedCollectionValue<T> ,
Check() ,
Choose(), Inherited from GuardedCollectionValue<T> ,
Clear() ,
Clone() ,
Contains(T item) ,
ContainsAll<U>(IEnumerable<U> items) ,
ContainsCount(T item) ,
CopyTo(T[] a, int i), Inherited from GuardedCollectionValue<T> ,
Equals(object obj), Inherited from object ,
Exists(Fun<T,bool> filter), Inherited from GuardedCollectionValue<T> ,
Filter(Fun<T,bool> filter), Inherited from GuardedCollectionValue<T> ,
Finalize(), Inherited from object ,
Find(ref T item) ,
Find(Fun<T,bool> filter, out T item), Inherited from GuardedCollectionValue<T> ,
FindOrAdd(ref T item) ,
GetEnumerator(), Inherited from GuardedEnumerable<T> ,
GetHashCode(), Inherited from object ,
GetType(), Inherited from object ,
GetUnsequencedHashCode() ,
ItemMultiplicities() ,
MemberwiseClone(), Inherited from object ,
Remove(T item) ,
Remove(T item, out T removeditem) ,
RemoveAll<U>(IEnumerable<U> items) ,
RemoveAllCopies(T item) ,
RetainAll<U>(IEnumerable<U> items) ,
Show(System.Text.StringBuilder stringbuilder, ref int rest, System.IFormatProvider formatProvider), Inherited from GuardedCollectionValue<T> ,
ToArray(), Inherited from GuardedCollectionValue<T> ,
ToString(string format, System.IFormatProvider formatProvider), Inherited from GuardedCollectionValue<T> ,
ToString(), Inherited from object ,
UniqueItems() ,
UnsequencedEquals(ICollection<T> that) ,
Update(T item) ,
Update(T item, out T olditem) ,
UpdateOrAdd(T item) ,
UpdateOrAdd(T item, out T olditem)

Property details

bool AllowsDuplicatesAccess: Read-Only

Value:False if wrapped collection has set semantics

Speed ContainsSpeedAccess: Read-Only

Value:Speed of wrapped collection

bool DuplicatesByCountingAccess: Read-Only

Value:True if only one representative of a group of equal items is kept in the collection together with the total count.

By convention this is true for any collection with set semantics.
System.Collections.Generic.IEqualityComparer<T> EqualityComparerAccess: Read-Only

Value:

bool IsEmptyAccess: Read-Only

Value:True if wrapped collection is empty

bool IsReadOnlyAccess: Read-Only

Value:True

(This is a read-only wrapper)

Constructor details

GuardedCollection<T>(ICollection<T> collection) Wrap an ICollection<T> in a read-only wrapper
Parameters:
collection:the collection to wrap

Method details

bool Add(T item)
Throws
ReadOnlyCollectionException since this is a read-only wrappper
Returns:
Parameters:
item:
void AddAll<U>(IEnumerable<U> items)
Throws
ReadOnlyCollectionException since this is a read-only wrappper
Type parameters:
U
Constraints:
U : T
Parameters:
items:
bool Check() Check wrapped collection for internal consistency
Returns:True if check passed
void Clear()
Throws
ReadOnlyCollectionException since this is a read-only wrappper
object Clone()
Returns:
bool Contains(T item) Check if an item is in the wrapped collection
Returns:True if found
Parameters:
item:The item
bool ContainsAll<U>(IEnumerable<U> items) Check if all items in the argument is in the wrapped collection
Type parameters:
U
Constraints:
U : T
Returns:True if so
Parameters:
items:The items
int ContainsCount(T item) Count the number of times an item appears in the wrapped collection
Returns:The number of copies
Parameters:
item:The item
bool Find(ref T item) Search for an item in the wrapped collection
Returns:
Parameters:
item:On entry the item to look for, on exit the equivalent item found (if any)
bool FindOrAdd(ref T item)
Throws
ReadOnlyCollectionException since this is a read-only wrappper
Returns:
Parameters:
item:
int GetUnsequencedHashCode()
Returns:
ICollectionValue<KeyValuePair<T,int>> ItemMultiplicities()
Returns:
bool Remove(T item)
Throws
ReadOnlyCollectionException since this is a read-only wrappper
Returns:
Parameters:
item:
bool Remove(T item, out T removeditem)
Throws
ReadOnlyCollectionException since this is a read-only wrappper
Returns:
Parameters:
item:The value to remove.
removeditem:The removed value.
void RemoveAll<U>(IEnumerable<U> items)
Throws
ReadOnlyCollectionException since this is a read-only wrappper
Type parameters:
U
Constraints:
U : T
Parameters:
items:
void RemoveAllCopies(T item)
Throws
ReadOnlyCollectionException since this is a read-only wrappper
Parameters:
item:
void RetainAll<U>(IEnumerable<U> items)
Throws
ReadOnlyCollectionException since this is a read-only wrappper
Type parameters:
U
Constraints:
U : T
Parameters:
items:
ICollectionValue<T> UniqueItems()
Returns:
bool UnsequencedEquals(ICollection<T> that)
Returns:
Parameters:
that:
bool Update(T item)
Throws
ReadOnlyCollectionException since this is a read-only wrappper
Returns:
Parameters:
item:
bool Update(T item, out T olditem)
Throws
ReadOnlyCollectionException since this is a read-only wrappper
Returns:
Parameters:
item:
olditem:
bool UpdateOrAdd(T item)
Throws
ReadOnlyCollectionException since this is a read-only wrappper
Returns:
Parameters:
item:
bool UpdateOrAdd(T item, out T olditem)
Throws
ReadOnlyCollectionException since this is a read-only wrappper
Returns:
Parameters:
item:
olditem: