- Joined
- Jul 10, 2007
- Messages
- 6,306
Ok, so this is my problem.
First, I have a Range object that stores a minimum value and a maximum value (simple).
The max refers to the maximum value that the range object can have and the min refers to the minimum. I want to make subranges point to range objects. For example-
Make range 1 values of 500 to 6000 point to range 2 (29,2420)
1 (500,6000) -> 2
All of the pointers (just theoretical)
So, I want to be able to plug a value into a range and get all of the things that value points to. I also want to get it in order.
For example, plugging 600 into 1 would return 2,4,3
Plugging 2000 into 1 would return 2
Plugging 400 into 1 would return 0
Now, my only idea for doing this at the moment is populating a hashtable specific to the range with all of the links for that range and then looping through all of the links and returning whatever links the value happens to fit into.
1
So I plug 600 into 1
I just don't like the fact that I have to loop through all of these... is there a better way? Tx.
First, I have a Range object that stores a minimum value and a maximum value (simple).
JASS:
struct Range extends array
integer max
integer min
endstruct
The max refers to the maximum value that the range object can have and the min refers to the minimum. I want to make subranges point to range objects. For example-
Code:
Range 1: 0 to 10000
Range 2: 29 to 2420
Range 3: -240 to 3593
Range 4: -2402 to -1492
Make range 1 values of 500 to 6000 point to range 2 (29,2420)
1 (500,6000) -> 2
All of the pointers (just theoretical)
Code:
1 (500,6000) -> 2
2 (33, 114) -> 4
1 (600, 800) -> 4
1 (600, 600) -> 3
4 (-2400 to -1903) -> 1
So, I want to be able to plug a value into a range and get all of the things that value points to. I also want to get it in order.
For example, plugging 600 into 1 would return 2,4,3
Plugging 2000 into 1 would return 2
Plugging 400 into 1 would return 0
Now, my only idea for doing this at the moment is populating a hashtable specific to the range with all of the links for that range and then looping through all of the links and returning whatever links the value happens to fit into.
1
Code:
1[0] = CreateLink(500,6000,2)
1[1] = CreateLink(600,800,4)
1[2] = CreateLink(600,600,3)
So I plug 600 into 1
JASS:
globals
integer array links
integer i2 = 0
endglobals
////////////////
local integer i = 0
set i2 = 0
loop
exitwhen i == 2
if (600 >= 1[i].lowBound and 600 <= 1[i].highBonud) then
set links[i2] = 1[i]
set i2 = i2 + 1
endif
set i = i + 1
endloop
I just don't like the fact that I have to loop through all of these... is there a better way? Tx.