Interface ICollection<T>
The simplest interface of a main stream generic collection with lookup, insertion and removal operations.
Inherited Members
Namespace: Lucene.Net.Support.C5
Assembly: Lucene.Net.dll
Syntax
public interface ICollection<T> : IExtensible<T>, ICollectionValue<T>, IShowable, IFormattable, ICollection<T>, IEnumerable<T>, IEnumerable
Type Parameters
Name | Description |
---|---|
T |
Properties
| Improve this Doc View SourceContainsSpeed
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 C5.Speed for the set of symbols.
Declaration
Speed ContainsSpeed { get; }
Property Value
Type | Description |
---|---|
Speed | A characterization of the speed of lookup operations ( etc.) of the implementation of this collection.
|
Count
Declaration
int Count { get; }
Property Value
Type | Description |
---|---|
System.Int32 | The number of items in this collection |
IsReadOnly
If true any call of an updating operation will throw an
ReadOnlyCollectionException
Declaration
bool IsReadOnly { get; }
Property Value
Type | Description |
---|---|
System.Boolean | True if this collection is read-only. |
Methods
| Improve this Doc View SourceAdd(T)
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.
Declaration
bool Add(T item)
Parameters
Type | Name | Description |
---|---|---|
T | item | The item to add. |
Returns
Type | Description |
---|---|
System.Boolean | True if item was added. |
Clear()
Remove all items from this collection.
Declaration
void Clear()
Contains(T)
Check if this collection contains (an item equivalent to according to the itemequalityComparer) a particular value.
Declaration
bool Contains(T item)
Parameters
Type | Name | Description |
---|---|---|
T | item | The value to check for. |
Returns
Type | Description |
---|---|
System.Boolean | True if the items is in this collection. |
ContainsAll(IEnumerable<T>)
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.
Declaration
bool ContainsAll(IEnumerable<T> items)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<T> | items | The |
Returns
Type | Description |
---|---|
System.Boolean | True if all values in is in this collection.
|
ContainsCount(T)
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.
Declaration
int ContainsCount(T item)
Parameters
Type | Name | Description |
---|---|---|
T | item | The value to count. |
Returns
Type | Description |
---|---|
System.Int32 | The number of copies found. |
CopyTo(T[], Int32)
Copy the items of this collection to a contiguous part of an array.
Declaration
void CopyTo(T[] array, int index)
Parameters
Type | Name | Description |
---|---|---|
T[] | array | The array to copy to |
System.Int32 | index | The index at which to copy the first item |
Find(ref T)
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.
Declaration
bool Find(ref T item)
Parameters
Type | Name | Description |
---|---|---|
T | item | The value to look for. |
Returns
Type | Description |
---|---|
System.Boolean | True if the items is in this collection. |
FindOrAdd(ref T)
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.
Declaration
bool FindOrAdd(ref T item)
Parameters
Type | Name | Description |
---|---|---|
T | item | The value to look for. |
Returns
Type | Description |
---|---|
System.Boolean | True if the item was found (hence not added). |
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.
Declaration
int GetUnsequencedHashCode()
Returns
Type | Description |
---|---|
System.Int32 | The unordered hashcode of this collection. |
ItemMultiplicities()
Declaration
ICollectionValue<KeyValuePair<T, int>> ItemMultiplicities()
Returns
Type | Description |
---|---|
ICollectionValue<KeyValuePair<T, System.Int32>> |
Remove(T)
Remove a particular item from this collection. If the collection has bag semantics only one copy equivalent to the supplied item is removed.
Declaration
bool Remove(T item)
Parameters
Type | Name | Description |
---|---|---|
T | item | The value to remove. |
Returns
Type | Description |
---|---|
System.Boolean | True if the item was found (and removed). |
Remove(T, out T)
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.
Declaration
bool Remove(T item, out T removeditem)
Parameters
Type | Name | Description |
---|---|---|
T | item | The value to remove. |
T | removeditem | The value removed if any. |
Returns
Type | Description |
---|---|
System.Boolean | True if the item was found (and removed). |
RemoveAll(IEnumerable<T>)
Remove all items in another collection from this one. If this collection has bag semantics, take multiplicities into account.
Declaration
void RemoveAll(IEnumerable<T> items)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<T> | items | The items to remove. |
RemoveAllCopies(T)
Remove all items equivalent to a given value.
Declaration
void RemoveAllCopies(T item)
Parameters
Type | Name | Description |
---|---|---|
T | item | The value to remove. |
RetainAll(IEnumerable<T>)
Remove all items not in some other collection from this one. If this collection has bag semantics, take multiplicities into account.
Declaration
void RetainAll(IEnumerable<T> items)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<T> | items | The items to retain. |
UniqueItems()
Declaration
ICollectionValue<T> UniqueItems()
Returns
Type | Description |
---|---|
ICollectionValue<T> |
UnsequencedEquals(ICollection<T>)
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.
Declaration
bool UnsequencedEquals(ICollection<T> otherCollection)
Parameters
Type | Name | Description |
---|---|---|
ICollection<T> | otherCollection | The collection to compare to. |
Returns
Type | Description |
---|---|
System.Boolean | True if this collection and that contains the same items. |
Update(T)
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.
Declaration
bool Update(T item)
Parameters
Type | Name | Description |
---|---|---|
T | item | Value to update. |
Returns
Type | Description |
---|---|
System.Boolean | True if the item was found and hence updated. |
Update(T, out T)
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.
Declaration
bool Update(T item, out T olditem)
Parameters
Type | Name | Description |
---|---|---|
T | item | Value to update. |
T | olditem | On output the olditem, if found. |
Returns
Type | Description |
---|---|
System.Boolean | True if the item was found and hence updated. |
UpdateOrAdd(T)
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.
Declaration
bool UpdateOrAdd(T item)
Parameters
Type | Name | Description |
---|---|---|
T | item | Value to add or update. |
Returns
Type | Description |
---|---|
System.Boolean | True if the item was found and updated (hence not added). |
UpdateOrAdd(T, out T)
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.
Declaration
bool UpdateOrAdd(T item, out T olditem)
Parameters
Type | Name | Description |
---|---|---|
T | item | Value to add or update. |
T | olditem | On output the olditem, if found. |
Returns
Type | Description |
---|---|
System.Boolean | True if the item was found and updated (hence not added). |