Class BinarySearch
An object able to search in logarithmic time for items in direct random access structures, such as lists and
arrays, which are monodimensional, implement the interface and are sorted in ascending
order according to the provided comparer (which is the property enabling the search to be carried out in O(log(n))
time.
Inheritance
System.Object
BinarySearch
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Assembly: MoreStructures.dll
Syntax
public class BinarySearch : ISearch
Methods
|
Improve this Doc
View Source
First<T>(IEnumerable<T>, T, Nullable<IComparer<T>>, Nullable<Int32>, Nullable<Int32>)
This specific implementation assumes that source
is sorted in ascending order.
Declaration
public 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 |
|
T |
item |
|
System.Nullable<IComparer<T>> |
comparer |
|
System.Nullable<System.Int32> |
fromIndex |
|
System.Nullable<System.Int32> |
toIndex |
|
Returns
Type |
Description |
System.Int32 |
|
Type Parameters
|
Improve this Doc
View Source
FirstAll<T>(IEnumerable<T>, Nullable<IComparer<T>>, Nullable<Int32>, Nullable<Int32>)
This specific implementation assumes that source
is sorted in ascending order.
Declaration
public 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 |
|
System.Nullable<IComparer<T>> |
comparer |
|
System.Nullable<System.Int32> |
fromIndex |
|
System.Nullable<System.Int32> |
toIndex |
|
Returns
Type |
Description |
IDictionary<T, System.Int32> |
|
Type Parameters
|
Improve this Doc
View Source
Interval<T>(IEnumerable<T>, T, Nullable<IComparer<T>>, Nullable<Int32>, Nullable<Int32>)
This specific implementation assumes that source
is sorted in ascending order.
Declaration
public (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 |
|
T |
item |
|
System.Nullable<IComparer<T>> |
comparer |
|
System.Nullable<System.Int32> |
fromIndex |
|
System.Nullable<System.Int32> |
toIndex |
|
Returns
Type |
Description |
System.ValueTuple<System.Int32, System.Int32> |
|
Type Parameters
|
Improve this Doc
View Source
Last<T>(IEnumerable<T>, T, Nullable<IComparer<T>>, Nullable<Int32>, Nullable<Int32>)
This specific implementation assumes that source
is sorted in ascending order.
Declaration
public 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 |
|
T |
item |
|
System.Nullable<IComparer<T>> |
comparer |
|
System.Nullable<System.Int32> |
fromIndex |
|
System.Nullable<System.Int32> |
toIndex |
|
Returns
Type |
Description |
System.Int32 |
|
Type Parameters
|
Improve this Doc
View Source
Nth<T>(IEnumerable<T>, T, Int32, Nullable<IComparer<T>>, Nullable<Int32>, Nullable<Int32>)
This specific implementation assumes that source
is sorted in ascending order.
Declaration
public 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 |
|
Type Parameters
Implements
Extension Methods