Connecting Tech Pros Worldwide Forums | Help | Site Map

Whats the point of SortedList.IndexOfKey

john conwell
Guest
 
Posts: n/a
#1: Feb 22 '06
So you pass in the Key and it returns the array index of the key. but you
cant do array index lookups. the indexer of the sortedlist does a binary
search based on the key. So whats the pointof this method? is there a way
to return a array item based on the index?

Mark R. Dawson
Guest
 
Posts: n/a
#2: Feb 22 '06

re: Whats the point of SortedList.IndexOfKey


Hi John,
the SortedList type has a GetByIndex method which allows you to enter the
ordinal position of an item in the list and retrieve the value stored at that
position.

Mark Dawson
http://www.markdawson.org


"john conwell" wrote:
[color=blue]
> So you pass in the Key and it returns the array index of the key. but you
> cant do array index lookups. the indexer of the sortedlist does a binary
> search based on the key. So whats the pointof this method? is there a way
> to return a array item based on the index?[/color]
john conwell
Guest
 
Posts: n/a
#3: Feb 22 '06

re: Whats the point of SortedList.IndexOfKey


Sorry, i should have been more specific. I'm talking about the 2.0 Generic
SortedList. The 1.1 SortedList does have a GetByIndex. the 2.0 Generic
SortedList does not.

"Mark R. Dawson" wrote:
[color=blue]
> Hi John,
> the SortedList type has a GetByIndex method which allows you to enter the
> ordinal position of an item in the list and retrieve the value stored at that
> position.
>
> Mark Dawson
> http://www.markdawson.org
>
>
> "john conwell" wrote:
>[color=green]
> > So you pass in the Key and it returns the array index of the key. but you
> > cant do array index lookups. the indexer of the sortedlist does a binary
> > search based on the key. So whats the pointof this method? is there a way
> > to return a array item based on the index?[/color][/color]
Mark R. Dawson
Guest
 
Posts: n/a
#4: Feb 23 '06

re: Whats the point of SortedList.IndexOfKey


In the SortedList you have the Values collection which can be referenced by
an ordinal position. I guess you could use your index value with that to
return the desired value.

Mark Dawson
http://www.markdawson.org


"john conwell" wrote:
[color=blue]
> Sorry, i should have been more specific. I'm talking about the 2.0 Generic
> SortedList. The 1.1 SortedList does have a GetByIndex. the 2.0 Generic
> SortedList does not.
>
> "Mark R. Dawson" wrote:
>[color=green]
> > Hi John,
> > the SortedList type has a GetByIndex method which allows you to enter the
> > ordinal position of an item in the list and retrieve the value stored at that
> > position.
> >
> > Mark Dawson
> > http://www.markdawson.org
> >
> >
> > "john conwell" wrote:
> >[color=darkred]
> > > So you pass in the Key and it returns the array index of the key. but you
> > > cant do array index lookups. the indexer of the sortedlist does a binary
> > > search based on the key. So whats the pointof this method? is there a way
> > > to return a array item based on the index?[/color][/color][/color]
Stoitcho Goutsev \(100\)
Guest
 
Posts: n/a
#5: Feb 23 '06

re: Whats the point of SortedList.IndexOfKey


John,

You have:
GetByIndex to ger value by index and GetKey to get key by index.


--
HTH
Stoitcho Goutsev (100)

"john conwell" <johnconwell@discussions.microsoft.com> wrote in message
news:200C6679-044C-4F1E-95F7-64C9FEE55E69@microsoft.com...[color=blue]
> So you pass in the Key and it returns the array index of the key. but you
> cant do array index lookups. the indexer of the sortedlist does a binary
> search based on the key. So whats the pointof this method? is there a
> way
> to return a array item based on the index?[/color]


Closed Thread