예제 #1
0
 /// <summary>
 /// Binary search for the value in the sorted container.
 /// </summary>
 /// <typeparam name="T">Source type of elements</typeparam>
 /// <param name="container">The container to perform search.</param>
 /// <param name="value">The value to search for.</param>
 /// <returns>Positive index of the specified value if value is found. Otherwise bitwise complement of index of first greater value.</returns>
 /// <remarks>Array must be sorted, otherwise value searched might not be found even when it is in array. IComparer corresponds to IComparer used by sort.</remarks>
 public static int BinarySearch <T>(this UnsafeList <T> container, T value)
     where T : unmanaged, IComparable <T>
 {
     return(container.BinarySearch(value, new DefaultComparer <T>()));
 }