Connecting Tech Pros Worldwide Help | Site Map

Whats the point of SortedList.IndexOfKey

  #1  
Old February 22nd, 2006, 10:45 PM
john conwell
Guest
 
Posts: n/a
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?
  #2  
Old February 22nd, 2006, 11:05 PM
Mark R. Dawson
Guest
 
Posts: n/a

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]
  #3  
Old February 22nd, 2006, 11:55 PM
john conwell
Guest
 
Posts: n/a

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]
  #4  
Old February 23rd, 2006, 03:15 AM
Mark R. Dawson
Guest
 
Posts: n/a

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]
  #5  
Old February 23rd, 2006, 03:25 PM
Stoitcho Goutsev \(100\)
Guest
 
Posts: n/a

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Comments please. Control Freq answers 0 September 10th, 2006 09:25 PM
System.Collections.Generic.SortedDictionary - lookup and then iterateto next/previous in o(log(n)) time Paul Delhanty answers 6 November 17th, 2005 08:59 AM