Interface ISearch
An object able to search for items in direct random access structures, such as lists and arrays, which are
monodimensional and implement the
Namespace: MoreStructures.Lists.Searching
Assembly: MoreStructures.dll
Syntax
public interface ISearch
Remarks
In .NET, random access structures usually have an indexer defined, which takes as an index the address of the
item in the data structure (usually an integer). Most random access structures (but not all) inherit
A notable exception is System.String, which has an indexer (System.String.Chars(System.Int32)), but does not
implement
Methods
| Improve this Doc View SourceFirst<T>(IEnumerable<T>, T, Nullable<IComparer<T>>, Nullable<Int32>, Nullable<Int32>)
Find the index of the first item in the sub-sequence of items of source
from
fromIndex
to toIndex
included, which is equal to
item
.
Declaration
int First<T>(IEnumerable<T> source, T item, IComparer<T>? comparer = null, int? fromIndex = null, int? toIndex = null)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<T> | source | The enumerable where to search for |
T | item | The item to search for. |
System.Nullable<IComparer<T>> | comparer | The comparer to be used when performing the search.
If not specified, |
System.Nullable<System.Int32> | fromIndex | The first index, marking the begin of the sub-sequence of |
System.Nullable<System.Int32> | toIndex | The last index, marking the end of the sub-sequence of |
Returns
Type | Description |
---|---|
System.Int32 | The first index of |
Type Parameters
Name | Description |
---|---|
T | The type of items of |
FirstAll<T>(IEnumerable<T>, Nullable<IComparer<T>>, Nullable<Int32>, Nullable<Int32>)
Find the indexes of the first occurrence of each item in the sub-sequence of items of source
from fromIndex
to toIndex
included.
Declaration
IDictionary<T, int> FirstAll<T>(IEnumerable<T> source, IComparer<T>? comparer = null, int? fromIndex = null, int? toIndex = null)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<T> | source | The enumerable. |
System.Nullable<IComparer<T>> | comparer | The comparer to be used when performing the search, to tell apart different items.
If not specified, |
System.Nullable<System.Int32> | fromIndex | The first index, marking the begin of the sub-sequence of |
System.Nullable<System.Int32> | toIndex | The last index, marking the end of the sub-sequence of |
Returns
Type | Description |
---|---|
IDictionary<T, System.Int32> | A |
Type Parameters
Name | Description |
---|---|
T | The type of items of |
Interval<T>(IEnumerable<T>, T, Nullable<IComparer<T>>, Nullable<Int32>, Nullable<Int32>)
Find the indexes of the first and last items in the sub-sequence of items of source
from
fromIndex
to toIndex
included, which is equal to
item
.
Declaration
(int first, int last) Interval<T>(IEnumerable<T> source, T item, IComparer<T>? comparer = null, int? fromIndex = null, int? toIndex = null)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<T> | source | The enumerable where to search for |
T | item | The item to search for. |
System.Nullable<IComparer<T>> | comparer | The comparer to be used when performing the search.
If not specified, |
System.Nullable<System.Int32> | fromIndex | The first index, marking the begin of the sub-sequence of |
System.Nullable<System.Int32> | toIndex | The last index, marking the end of the sub-sequence of |
Returns
Type | Description |
---|---|
System.ValueTuple<System.Int32, System.Int32> | The first and last index, marking the end of the sub-sequence of |
Type Parameters
Name | Description |
---|---|
T | The type of items of |
Last<T>(IEnumerable<T>, T, Nullable<IComparer<T>>, Nullable<Int32>, Nullable<Int32>)
Find the index of the last item in the sub-sequence of items of source
from
fromIndex
to toIndex
included, which is equal to
item
.
Declaration
int Last<T>(IEnumerable<T> source, T item, IComparer<T>? comparer = null, int? fromIndex = null, int? toIndex = null)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<T> | source | The enumerable where to search for |
T | item | The item to search for. |
System.Nullable<IComparer<T>> | comparer | The comparer to be used when performing the search.
If not specified, |
System.Nullable<System.Int32> | fromIndex | The first index, marking the begin of the sub-sequence of |
System.Nullable<System.Int32> | toIndex | The last index, marking the end of the sub-sequence of |
Returns
Type | Description |
---|---|
System.Int32 | The first and last index, marking the end of the sub-sequence of |
Type Parameters
Name | Description |
---|---|
T | The type of items of |
Nth<T>(IEnumerable<T>, T, Int32, Nullable<IComparer<T>>, Nullable<Int32>, Nullable<Int32>)
Find the index of the n-th occurence (0-based) of the item in the sub-sequence of items of
source
from fromIndex
to toIndex
included, which is
equal to item
.
Declaration
int Nth<T>(IEnumerable<T> source, T item, int occurrenceRank, IComparer<T>? comparer = null, int? fromIndex = null, int? toIndex = null)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<T> | source | |
T | item | |
System.Int32 | occurrenceRank | |
System.Nullable<IComparer<T>> | comparer | |
System.Nullable<System.Int32> | fromIndex | |
System.Nullable<System.Int32> | toIndex |
Returns
Type | Description |
---|---|
System.Int32 | The n-th index, marking the end of the sub-sequence of |
Type Parameters
Name | Description |
---|---|
T | The type of items of |