C5  2.4
The C5 Generic Collection Library for C# and CLI is a comprehensive collection library supporting lists, sets, bags, dictionaries, priority queues, (FIFO) queues, and (LIFO) stacks. C5 runs on .NET 3.5+, Silverlight 5, Windows Phone 8, Xamarin.iOS, Xamarin.Android, and Mono.
C5.ICollection< T > Interface Template Reference

The simplest interface of a main stream generic collection with lookup, insertion and removal operations. More...

Inheritance diagram for C5.ICollection< T >:
C5.IExtensible< T > C5.ICollectionValue< T > C5.IShowable C5.GuardedCollection< T > C5.HashBag< T > C5.HashSet< T > C5.ISequenced< T > C5.GuardedSequenced< T > C5.GuardedSequenced< T > C5.IIndexed< T > C5.ISorted< T > C5.GuardedList< T > C5.GuardedSorted< T > C5.GuardedList< T > C5.GuardedSorted< T > C5.IIndexedSorted< T > C5.IList< T > C5.GuardedSorted< T > C5.IIndexedSorted< T > C5.IPersistentSorted< T >

Public Member Functions

new bool Add (T item)
 Add an item to this collection if possible. If this collection has set semantics, the item will be added if not already in the collection. If bag semantics, the item will always be added. More...
 
new void CopyTo (T[] array, int index)
 Copy the items of this collection to a contiguous part of an array. More...
 
int GetUnsequencedHashCode ()
 The unordered collection hashcode is defined as the sum of More...
 
bool UnsequencedEquals (ICollection< T > otherCollection)
 Compare the contents of this collection to another one without regards to the sequence order. The comparison will use this collection's itemequalityComparer to compare individual items. More...
 
new bool Contains (T item)
 Check if this collection contains (an item equivalent to according to the itemequalityComparer) a particular value. More...
 
int ContainsCount (T item)
 Count the number of items of the collection equal to a particular value. Returns 0 if and only if the value is not in the collection. More...
 
ICollectionValue< T > UniqueItems ()
 
ICollectionValue< KeyValuePair< T, int > > ItemMultiplicities ()
 
bool ContainsAll (SCG.IEnumerable< T > items)
 Check whether this collection contains all the values in another collection. If this collection has bag semantics ( More...
 
bool Find (ref T item)
 Check if this collection contains an item equivalent according to the itemequalityComparer to a particular value. If so, return in the ref argument (a binary copy of) the actual value found. More...
 
bool FindOrAdd (ref T item)
 Check if this collection contains an item equivalent according to the itemequalityComparer to a particular value. If so, return in the ref argument (a binary copy of) the actual value found. Else, add the item to the collection. More...
 
bool Update (T item)
 Check if this collection contains an item equivalent according to the itemequalityComparer to a particular value. If so, update the item in the collection with a (binary copy of) the supplied value. If the collection has bag semantics, it depends on the value of DuplicatesByCounting if this updates all equivalent copies in the collection or just one. More...
 
bool Update (T item, out T olditem)
 Check if this collection contains an item equivalent according to the itemequalityComparer to a particular value. If so, update the item in the collection with a (binary copy of) the supplied value. If the collection has bag semantics, it depends on the value of DuplicatesByCounting if this updates all equivalent copies in the collection or just one. More...
 
bool UpdateOrAdd (T item)
 Check if this collection contains an item equivalent according to the itemequalityComparer to a particular value. If so, update the item in the collection to with a binary copy of the supplied value; else add the value to the collection. More...
 
bool UpdateOrAdd (T item, out T olditem)
 Check if this collection contains an item equivalent according to the itemequalityComparer to a particular value. If so, update the item in the collection to with a binary copy of the supplied value; else add the value to the collection. More...
 
new bool Remove (T item)
 Remove a particular item from this collection. If the collection has bag semantics only one copy equivalent to the supplied item is removed. More...
 
bool Remove (T item, out T removeditem)
 Remove a particular item from this collection if found. If the collection has bag semantics only one copy equivalent to the supplied item is removed, which one is implementation dependent. If an item was removed, report a binary copy of the actual item removed in the argument. More...
 
void RemoveAllCopies (T item)
 Remove all items equivalent to a given value. More...
 
void RemoveAll (SCG.IEnumerable< T > items)
 Remove all items in another collection from this one. If this collection has bag semantics, take multiplicities into account. More...
 
new void Clear ()
 Remove all items from this collection. More...
 
void RetainAll (SCG.IEnumerable< T > items)
 Remove all items not in some other collection from this one. If this collection has bag semantics, take multiplicities into account. More...
 
- Public Member Functions inherited from C5.IExtensible< T >
void AddAll (SCG.IEnumerable< T > items)
 Add the elements from another collection with a more specialized item type to this collection. If this collection has set semantics, only items not already in the collection will be added. More...
 
bool Check ()
 Check the integrity of the internal data structures of this collection. This is only relevant for developers of the library More...
 
- Public Member Functions inherited from C5.ICollectionValue< T >
T[] ToArray ()
 Create an array with the items of this collection (in the same order as an enumerator would output them). More...
 
void Apply (Action< T > action)
 Apply a delegate to all items of this collection. More...
 
bool Exists (Func< T, bool > predicate)
 Check if there exists an item that satisfies a specific predicate in this collection. More...
 
bool Find (Func< T, bool > predicate, out T item)
 Check if there exists an item that satisfies a specific predicate in this collection and return the first one in enumeration order. More...
 
bool All (Func< T, bool > predicate)
 Check if all items in this collection satisfies a specific predicate. More...
 
Choose ()
 Choose some item of this collection. More...
 
SCG.IEnumerable< T > Filter (Func< T, bool > filter)
 Create an enumerable, enumerating the items of this collection that satisfies a certain condition. More...
 
- Public Member Functions inherited from C5.IShowable
bool Show (StringBuilder stringbuilder, ref int rest, IFormatProvider formatProvider)
 Format More...
 

Properties

Speed ContainsSpeed [get]
 The value is symbolic indicating the type of asymptotic complexity in terms of the size of this collection (worst-case or amortized as relevant). More...
 
new int Count [get]
 
new bool IsReadOnly [get]
 If true any call of an updating operation will throw an More...
 
- Properties inherited from C5.IExtensible< T >
bool IsReadOnly [get]
 If true any call of an updating operation will throw an More...
 
bool AllowsDuplicates [get]
 
SCG.IEqualityComparer< T > EqualityComparer [get]
 (Here should be a discussion of the role of equalityComparers. Any ). More...
 
bool DuplicatesByCounting [get]
 By convention this is true for any collection with set semantics. More...
 
- Properties inherited from C5.ICollectionValue< T >
EventTypeEnum ListenableEvents [get]
 A flag bitmap of the events subscribable to by this collection. More...
 
EventTypeEnum ActiveEvents [get]
 A flag bitmap of the events currently subscribed to by this collection. More...
 
bool IsEmpty [get]
 
int Count [get]
 
Speed CountSpeed [get]
 The value is symbolic indicating the type of asymptotic complexity in terms of the size of this collection (worst-case or amortized as relevant). More...
 

Additional Inherited Members

- Events inherited from C5.ICollectionValue< T >
CollectionChangedHandler< T > CollectionChanged
 The change event. Will be raised for every change operation on the collection. More...
 
CollectionClearedHandler< T > CollectionCleared
 The change event. Will be raised for every clear operation on the collection. More...
 
ItemsAddedHandler< T > ItemsAdded
 The item added event. Will be raised for every individual addition to the collection. More...
 
ItemInsertedHandler< T > ItemInserted
 The item inserted event. Will be raised for every individual insertion to the collection. More...
 
ItemsRemovedHandler< T > ItemsRemoved
 The item removed event. Will be raised for every individual removal from the collection. More...
 
ItemRemovedAtHandler< T > ItemRemovedAt
 The item removed at event. Will be raised for every individual removal at from the collection. More...
 

Detailed Description

The simplest interface of a main stream generic collection with lookup, insertion and removal operations.

Member Function Documentation

new bool C5.ICollection< T >.Add ( item)

Add an item to this collection if possible. If this collection has set semantics, the item will be added if not already in the collection. If bag semantics, the item will always be added.

Parameters
itemThe item to add.
Returns
True if item was added.

Implements C5.IExtensible< T >.

Implemented in C5.HashedLinkedList< T >, C5.LinkedList< T >, C5.HashedArrayList< T >, C5.ArrayList< T >, C5.SortedArray< T >, C5.TreeBag< T >, C5.TreeSet< T >, C5.IList< T >, C5.GuardedCollection< T >, C5.HashSet< T >, C5.WrappedArray< T >, and C5.HashBag< T >.

new bool C5.ICollection< T >.Contains ( item)

Check if this collection contains (an item equivalent to according to the itemequalityComparer) a particular value.

Parameters
itemThe value to check for.
Returns
True if the items is in this collection.

Implemented in C5.HashedLinkedList< T >, C5.LinkedList< T >, C5.HashedArrayList< T >, C5.ArrayList< T >, C5.TreeBag< T >, C5.TreeSet< T >, C5.SortedArray< T >, C5.IList< T >, C5.GuardedCollection< T >, C5.WrappedArray< T >, C5.HashSet< T >, and C5.HashBag< T >.

bool C5.ICollection< T >.ContainsAll ( SCG.IEnumerable< T >  items)

Check whether this collection contains all the values in another collection. If this collection has bag semantics (

AllowsDuplicates==true) the check is made with respect to multiplicities, else multiplicities are not taken into account.

Parameters
itemsThe
Returns
True if all values in
items
is in this collection.

Implemented in C5.HashedLinkedList< T >, C5.LinkedList< T >, C5.TreeBag< T >, C5.HashedArrayList< T >, C5.TreeSet< T >, C5.ArrayList< T >, C5.SortedArray< T >, C5.GuardedCollection< T >, C5.HashSet< T >, C5.WrappedArray< T >, and C5.HashBag< T >.

int C5.ICollection< T >.ContainsCount ( item)

Count the number of items of the collection equal to a particular value. Returns 0 if and only if the value is not in the collection.

Parameters
itemThe value to count.
Returns
The number of copies found.

Implemented in C5.HashedLinkedList< T >, C5.LinkedList< T >, C5.TreeBag< T >, C5.TreeSet< T >, C5.HashedArrayList< T >, C5.ArrayList< T >, C5.SortedArray< T >, C5.HashSet< T >, C5.GuardedCollection< T >, C5.HashBag< T >, and C5.WrappedArray< T >.

new void C5.ICollection< T >.CopyTo ( T[]  array,
int  index 
)

Copy the items of this collection to a contiguous part of an array.

Parameters
arrayThe array to copy to
indexThe index at which to copy the first item

Implements C5.ICollectionValue< T >.

Implemented in C5.IList< T >, C5.WrappedArray< T >, and C5.HashBag< T >.

bool C5.ICollection< T >.Find ( ref T  item)

Check if this collection contains an item equivalent according to the itemequalityComparer to a particular value. If so, return in the ref argument (a binary copy of) the actual value found.

Parameters
itemThe value to look for.
Returns
True if the items is in this collection.

Implemented in C5.HashedLinkedList< T >, C5.LinkedList< T >, C5.HashedArrayList< T >, C5.ArrayList< T >, C5.TreeBag< T >, C5.TreeSet< T >, C5.SortedArray< T >, C5.GuardedCollection< T >, C5.WrappedArray< T >, C5.HashSet< T >, and C5.HashBag< T >.

bool C5.ICollection< T >.FindOrAdd ( ref T  item)

Check if this collection contains an item equivalent according to the itemequalityComparer to a particular value. If so, return in the ref argument (a binary copy of) the actual value found. Else, add the item to the collection.

Parameters
itemThe value to look for.
Returns
True if the item was found (hence not added).

Implemented in C5.HashedLinkedList< T >, C5.LinkedList< T >, C5.HashedArrayList< T >, C5.ArrayList< T >, C5.TreeBag< T >, C5.TreeSet< T >, C5.SortedArray< T >, C5.GuardedCollection< T >, C5.WrappedArray< T >, C5.HashSet< T >, and C5.HashBag< T >.

int C5.ICollection< T >.GetUnsequencedHashCode ( )

The unordered collection hashcode is defined as the sum of

h(hashcode(item)) over the items of the collection, where the function h is a function from int to int of the form t -> (a0*t+b0)^(a1*t+b1)^(a2*t+b2), where the ax and bx are the same for all collection classes.

The current implementation uses fixed values for the ax and bx, specified as constants in the code.

Returns
The unordered hashcode of this collection.

Implemented in C5.HashedLinkedList< T >, C5.LinkedList< T >, C5.HashedArrayList< T >, C5.ArrayList< T >, C5.GuardedCollection< T >, and C5.WrappedArray< T >.

new bool C5.ICollection< T >.Remove ( item)

Remove a particular item from this collection. If the collection has bag semantics only one copy equivalent to the supplied item is removed.

Parameters
itemThe value to remove.
Returns
True if the item was found (and removed).

Implemented in C5.HashedLinkedList< T >, C5.LinkedList< T >, C5.HashedArrayList< T >, C5.ArrayList< T >, C5.TreeBag< T >, C5.TreeSet< T >, C5.SortedArray< T >, C5.IList< T >, C5.GuardedCollection< T >, C5.WrappedArray< T >, C5.HashSet< T >, and C5.HashBag< T >.

bool C5.ICollection< T >.Remove ( item,
out T  removeditem 
)

Remove a particular item from this collection if found. If the collection has bag semantics only one copy equivalent to the supplied item is removed, which one is implementation dependent. If an item was removed, report a binary copy of the actual item removed in the argument.

Parameters
itemThe value to remove.
removeditemThe value removed if any.
Returns
True if the item was found (and removed).

Implemented in C5.HashedLinkedList< T >, C5.LinkedList< T >, C5.HashedArrayList< T >, C5.ArrayList< T >, C5.TreeBag< T >, C5.TreeSet< T >, C5.SortedArray< T >, C5.GuardedCollection< T >, C5.WrappedArray< T >, C5.HashSet< T >, and C5.HashBag< T >.

void C5.ICollection< T >.RemoveAll ( SCG.IEnumerable< T >  items)

Remove all items in another collection from this one. If this collection has bag semantics, take multiplicities into account.

Parameters
itemsThe items to remove.

Implemented in C5.HashedLinkedList< T >, C5.LinkedList< T >, C5.TreeBag< T >, C5.TreeSet< T >, C5.HashedArrayList< T >, C5.ArrayList< T >, C5.SortedArray< T >, C5.GuardedCollection< T >, C5.WrappedArray< T >, C5.HashSet< T >, and C5.HashBag< T >.

void C5.ICollection< T >.RemoveAllCopies ( item)
void C5.ICollection< T >.RetainAll ( SCG.IEnumerable< T >  items)

Remove all items not in some other collection from this one. If this collection has bag semantics, take multiplicities into account.

Parameters
itemsThe items to retain.

Implemented in C5.HashedLinkedList< T >, C5.LinkedList< T >, C5.TreeBag< T >, C5.TreeSet< T >, C5.HashedArrayList< T >, C5.ArrayList< T >, C5.SortedArray< T >, C5.GuardedCollection< T >, C5.WrappedArray< T >, C5.HashSet< T >, and C5.HashBag< T >.

bool C5.ICollection< T >.UnsequencedEquals ( ICollection< T >  otherCollection)

Compare the contents of this collection to another one without regards to the sequence order. The comparison will use this collection's itemequalityComparer to compare individual items.

Parameters
otherCollectionThe collection to compare to.
Returns
True if this collection and that contains the same items.

Implemented in C5.HashedLinkedList< T >, C5.LinkedList< T >, C5.HashedArrayList< T >, C5.ArrayList< T >, C5.GuardedCollection< T >, and C5.WrappedArray< T >.

bool C5.ICollection< T >.Update ( item)

Check if this collection contains an item equivalent according to the itemequalityComparer to a particular value. If so, update the item in the collection with a (binary copy of) the supplied value. If the collection has bag semantics, it depends on the value of DuplicatesByCounting if this updates all equivalent copies in the collection or just one.

Parameters
itemValue to update.
Returns
True if the item was found and hence updated.

Implemented in C5.HashedLinkedList< T >, C5.LinkedList< T >, C5.HashedArrayList< T >, C5.ArrayList< T >, C5.TreeBag< T >, C5.TreeSet< T >, C5.SortedArray< T >, C5.GuardedCollection< T >, C5.WrappedArray< T >, C5.HashSet< T >, and C5.HashBag< T >.

bool C5.ICollection< T >.Update ( item,
out T  olditem 
)

Check if this collection contains an item equivalent according to the itemequalityComparer to a particular value. If so, update the item in the collection with a (binary copy of) the supplied value. If the collection has bag semantics, it depends on the value of DuplicatesByCounting if this updates all equivalent copies in the collection or just one.

Parameters
itemValue to update.
olditemOn output the olditem, if found.
Returns
True if the item was found and hence updated.

Implemented in C5.HashedLinkedList< T >, C5.LinkedList< T >, C5.HashedArrayList< T >, C5.ArrayList< T >, C5.TreeBag< T >, C5.TreeSet< T >, C5.SortedArray< T >, C5.GuardedCollection< T >, C5.WrappedArray< T >, C5.HashSet< T >, and C5.HashBag< T >.

bool C5.ICollection< T >.UpdateOrAdd ( item)

Check if this collection contains an item equivalent according to the itemequalityComparer to a particular value. If so, update the item in the collection to with a binary copy of the supplied value; else add the value to the collection.

Parameters
itemValue to add or update.
Returns
True if the item was found and updated (hence not added).

Implemented in C5.HashedLinkedList< T >, C5.LinkedList< T >, C5.HashedArrayList< T >, C5.ArrayList< T >, C5.TreeBag< T >, C5.TreeSet< T >, C5.SortedArray< T >, C5.GuardedCollection< T >, C5.WrappedArray< T >, C5.HashSet< T >, and C5.HashBag< T >.

bool C5.ICollection< T >.UpdateOrAdd ( item,
out T  olditem 
)

Check if this collection contains an item equivalent according to the itemequalityComparer to a particular value. If so, update the item in the collection to with a binary copy of the supplied value; else add the value to the collection.

Parameters
itemValue to add or update.
olditemOn output the olditem, if found.
Returns
True if the item was found and updated (hence not added).

Implemented in C5.HashedLinkedList< T >, C5.LinkedList< T >, C5.HashedArrayList< T >, C5.ArrayList< T >, C5.TreeBag< T >, C5.TreeSet< T >, C5.SortedArray< T >, C5.GuardedCollection< T >, C5.WrappedArray< T >, C5.HashSet< T >, and C5.HashBag< T >.

Property Documentation

Speed C5.ICollection< T >.ContainsSpeed
get

The value is symbolic indicating the type of asymptotic complexity in terms of the size of this collection (worst-case or amortized as relevant).

See T:C5.Speed for the set of symbols.

A characterization of the speed of lookup operations (Contains() etc.) of the implementation of this collection.

new int C5.ICollection< T >.Count
get

The number of items in this collection

new bool C5.ICollection< T >.IsReadOnly
get

If true any call of an updating operation will throw an

ReadOnlyCollectionException

True if this collection is read-only.


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