Hi,
This is what i would like to do :
I have an Hashtable where all of my Keys are intergers.
The user choose a number, and i want to find the Closest minimal values
of my Keys.
For example :
mys Keys are : 0, 100, 250, 500.
The user enter the value 200, the programme should return 100.
The user enter the value 10, the programme should return 100.
The user enter the value 499, the programme should return 250.
Excuse my english, i hope i could be understand... :)
Thx!
Const. 3 2112
Const <ne**@ampdesign.net> wrote in news:43c579e8$0$31469$79c14f64@nan-
newsreader-07.noos.net: The user enter the value 200, the programme should return 100. The user enter the value 10, the programme should return 100. The user enter the value 499, the programme should return 250.
Unfortunately there is no built-in way to do this... but if you use a
SortedList instead of a Hashtable, then you can iterate through each of the
keys, and once you find a value greater than what you are looking for just
return the previous one.
-mdb
Const <ne**@ampdesign.net> wrote: This is what i would like to do : I have an Hashtable where all of my Keys are intergers.
The user choose a number, and i want to find the Closest minimal values of my Keys.
For example :
mys Keys are : 0, 100, 250, 500.
The user enter the value 200, the programme should return 100. The user enter the value 10, the programme should return 100. The user enter the value 499, the programme should return 250.
Excuse my english, i hope i could be understand... :)
Well, you could use a SortedList instead of a Hashtable, and then do a
binary chop to find the nearest value. Otherwise you'll have to go
through all the keys in turn.
--
Jon Skeet - <sk***@pobox.com> http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Michael Bray a écrit : Const <ne**@ampdesign.net> wrote in news:43c579e8$0$31469$79c14f64@nan- newsreader-07.noos.net:
The user enter the value 200, the programme should return 100. The user enter the value 10, the programme should return 100. The user enter the value 499, the programme should return 250.
Unfortunately there is no built-in way to do this... but if you use a SortedList instead of a Hashtable, then you can iterate through each of the keys, and once you find a value greater than what you are looking for just return the previous one.
-mdb
I'll try, thanks to you and Jon ! :) This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Rama S |
last post by:
Hi,
We need a query which retrieves option_code, for a plan from OPTION
table which are unique in (market, "ALL").
I have an example below
PLAN MARKET OPTION_CODE RATE...
|
by: Newbie |
last post by:
Hi,
Could someone please tell how MINUS operator works for comparing and
giving non-matching records in Table1? Does MINUS operator compares
all records of Table1 with all records of Table2 to...
|
by: Jiten |
last post by:
Hi
I have run a stored proc against a database to retrieve a list of date values. What i wanted to do is to add the values returned to an arraylist if the value is not null.
here is a small...
|
by: Jiten |
last post by:
Hi
I have run a stored proc against a database to retrieve a list of date values. What i wanted to do is to add the values returned to an arraylist if the value is not null.
here is a small...
|
by: Matthew Cook |
last post by:
I would like to overload the unary minus operator so that I can negate
an instance of a class and pass that instance to a function without
creating an explicit temporary variable. Here is an...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |