Skip to content

M_CodeJam_Algorithms_UpperBound__2_4

Andrew Koryavchenko edited this page Jun 17, 2018 · 6 revisions

Algorithms.UpperBound(TElement, TValue) Method (IList(TElement), TValue, Int32, Int32)

Returns the minimum index i in the range [startIndex, endIndex - 1] such that list[i] > value or endIndex if no such i exists

Namespace: CodeJam
Assembly: CodeJam (in CodeJam.dll) Version: 2.1.0.0

Syntax

C#

public static int UpperBound<TElement, TValue>(
	this IList<TElement> list,
	TValue value,
	int startIndex,
	int endIndex
)
where TElement : Object, IComparable<TValue>

VB

<ExtensionAttribute>
Public Shared Function UpperBound(Of TElement As {Object, IComparable(Of TValue)}, TValue) ( 
	list As IList(Of TElement),
	value As TValue,
	startIndex As Integer,
	endIndex As Integer
) As Integer

F#

[<ExtensionAttribute>]
static member UpperBound : 
        list : IList<'TElement> * 
        value : 'TValue * 
        startIndex : int * 
        endIndex : int -> int  when 'TElement : Object and IComparable<'TValue>

Parameters

 

list
Type: System.Collections.Generic.IList(TElement)
The sorted list
value
Type: TValue
The value to compare
startIndex
Type: System.Int32
The minimum index
endIndex
Type: System.Int32
The upper bound for the index (not included)

Type Parameters

 

TElement
The list element type

Remarks

Should implement IComparable

TValue
The type of the value

Return Value

Type: Int32
The upper bound for the value

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type IList(TElement). When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).

See Also

Reference

Algorithms Class
UpperBound Overload
CodeJam Namespace

Clone this wiki locally